Skip to content

Latest commit

 

History

History
238 lines (200 loc) · 4.59 KB

File metadata and controls

238 lines (200 loc) · 4.59 KB

Linux Ubuntu

1 System :

Navigation

Print current directory path: pwd
Current directory: ./
Root directory: /
home directory: cd ~
previous directory: cd -
List with details (permissions, size, date): ls -l
List with human-readable sizes: ls -lh
Show hidden files (starting with .): ls -a
List by time, newest last: ls -ltr
List by size, largest first: ls -lS

Listing, Filtering

List only .txt files: ls *.txt
List files containing "read": ls *read*
Filter list output: ls | grep "pattern"
Show only Python files: ls -l | grep ".py$"
Show directory tree structure: tree
Limit tree depth to 2 levels: tree -L 2

File View

Display entire file: cat file.txt
View file page-by-page (q to quit): less file.txt
Show first 10 lines: head file.txt
Show first 20 lines: head -n 20 file.txt
Show last 10 lines: tail file.txt
Follow file in real-time (logs): tail -f logfile.log

Directory Management

Create nested directories: mkdir -p path/to/dir
Remove empty directory: rmdir dirname
Delete file: rm file.txt
Delete directory and contents: rm -r dirname
Force delete (use carefully!): rm -rf dirname
Copy file: cp file dest
Copy directory recursively: cp -r dir1 dir2
Rename/move file: mv oldname newname
Create empty file or update timestamp: touch file.txt

Search

Find all .c files from current dir: find . -name "*.c"
Find files/folders with 'read' anywhere in the name, case insensitive: find . -name "*.c"
Find Only directories containing 'log': find ./ -type d -iname "*log*"
Find files starting with "read": find /path -type f -name "read*"
Find directories starting with "lib": find /path -type d -name "lib*"
Search for text in file: grep "text" file.txt
Search recursively in directory: grep -r "pattern" /path
Case-insensitive search: grep -i "pattern" file
Show path to command executable: which command

File Info

Show file type: file filename
Show detailed file information: stat filename
Show directory size: du -sh dirname
Show absolute path of file: readlink -f file

2) Commands

When bash sees \ at the end of a line, it treats the next line as part of the same command: \

3) Network

Network devices overview:

ip addr

Netplan

Locate the Netplan configuration file:

Typically, these files are located in /etc/netplan/. The filename might be something like 01-netcfg.yaml or 50-cloud-init.yaml.

sudo nano /etc/netplan/01-netcfg.yaml

Modify an entry for your network interface

network:
  version: 2
  ethernets:
    enp2s0:
      dhcp4: no
      addresses: [10.255.255.1/24]
      gateway4: <your_gateway_ip>
      nameservers:
        addresses: [<dns_ip_1>, <dns_ip_2>]

sudo netplan apply

NetworkManager

Identify the Connection Name:

nmcli con show See the ports specifications: nmcli device show enp2s0
nmcli device show enp1s0

Assuming your connection name is Wired connection 1

nmcli con mod "Wired connection 1" ipv4.addresses 10.255.255.1/24 nmcli con mod "Wired connection 1" ipv4.gateway <your_gateway_ip> nmcli con mod "Wired connection 1" ipv4.dns "<dns_ip_1>,<dns_ip_2>" nmcli con mod "Wired connection 1" ipv4.method manual

Restart the Network Interface:

nmcli con down "Wired connection 1" nmcli con up "Wired connection 1"

3 Auto Start:

sudo chmod +x /home/linux/select_app/selector.py

sudo nano /etc/systemd/system/yourscript.service

[Unit]
Description=Mediapipe
After=network.target

[Service]
ExecStart=/usr/bin/python3 /home/linux/hand-gesture-control-mediapipe-artnet/app.py
WorkingDirectory=/home/linux/hand-gesture-control-mediapipe-artnet
StandardOutput=inherit
StandardError=inherit
Restart=always
User=linux

[Install]
WantedBy=multi-user.target

[Service]
Environment="DISPLAY=:0"

sudo systemctl daemon-reload

sudo systemctl enable yourscript.service

sudo systemctl disable yourscript.service

sudo systemctl start yourscript.service

sudo systemctl status yourscript.service

journalctl -u yourscript.service

Review services:
systemctl list-unit-files --type=service --state=enabled
systemctl list-units --type=service --state=running

4 Others

Unrequire password with "sudo" commands:
sudo visudo
linux ALL=(ALL) NOPASSWD: /bin/systemctl start home.service, /bin/systemctl stop home.service

change keyboard layout:
setxkbmap cz