Selected, commonly used tools:
pwd
- returns current working directory
Allows to list files and directories
Description | Command | Notes |
---|---|---|
Shows files and directories in current directory | ls |
|
Shows files and directories in current directory as a list | ls -l |
|
Shows files and directories in current directory with sizes in human-readable format | ls -h |
Description | Command | Notes |
---|---|---|
Disk space usage | df |
|
Disk space usage in human-readable format | df -h |
Human-friendly refers to using KB/MB/GB/TB units |
inode usage | df -i |
Programs can't write to filesystem without free inodes |
Disk space usage with file system type | df -T |
Description | Command | Notes |
---|---|---|
Disk usage at specific path | du |
|
Disk space at specific path - count sums for directories | du -c |
|
Disk space at specific path - display output in human-friendly format | du -h |
Human-friendly refers to using KB/MB/GB/TB units |
Disk space sum at specific path | du -s |
Description | Command | Notes |
---|---|---|
Copy file input to output | cp input output |
|
Recursively copy files from input to output | cp -r input output |
This switch is commonly used to copy all subdirectories and files within |
Description | Command | Notes |
---|---|---|
Move file input to output | mv input output |
Description | Command | Notes |
---|---|---|
Removes file | rm file |
❗ This command is dangerous |
Removes files recursively in path | rm -r path |
❗ This command is extremely dangerous |
Description | Command | Notes |
---|---|---|
Find string in files in current directory | grep string * |
|
Find string in files in current directory or its subdirectories | grep -r string * |
|
Find string in files in current directory and display line number | grep -n string * |
|
Find whole-word string in files in current directory | grep -w string * |
|
Find regular expression string in files in current directory | grep -e string * |
Description | Command | Notes |
---|---|---|
Change file owner to user | chown user file |
|
Change file owner to user and group to group | chown user:group file |
|
Change directory owner to user for directory and its subdirectories | sudo chown -R user directory |
Permissions are typically noted by 3 numbers; leftmost being user, middle being group and rightmost being others.
Number on each position is a sum of desired permissions: 4 (read), 2 (write) and 1 (execute).
Note that directories require execution permission to be opened!
Description | Command | Notes |
---|---|---|
Make file permissions | chmod +x file |
|
Change file permissions to 600 (owner only read/write) | chmod 600 file |
|
Recursively change files permissions | chmod -R 600 directory |
Description | Command | Notes |
---|---|---|
Search for file with string in name | find -name "*string*" -type f |
|
Search for directories with string in name | find -name "*string*" -type d |
Allows executing other commands as root. Operating as root is considered a bad practice and can lead to system instability - even without any mistakes!
Description | Command | Notes |
---|---|---|
Shows sudo usage | sudo |
|
Executes cmd as root | sudo cmd |
❗ Depending on cmd it's either harmless or (on setups with bad UEFI implementation) instantly breaks hardware |
Executes cmd as user | sudo -u user cmd |
Last update: 2024-06-12