Linux Commands
Here is yet another Linux commands cheat sheet with a different flavor.
- It’s not a formal reference list but commands that I use regularly.
- It’s not meant to be an exhaustive list but more of the absolutely required ones to stay out of trouble.
- Knowing the command is often not sufficient. You have to figure out the right options. So I’ve also specified the relevant options.
For a man page explanation of the commands, use the link and copy/paste the command.
Commands
| TERMINAL | |
|---|---|
CTRL c | Interrupt and kill a process |
CTRL s | Suspend/Lock the terminal Resume/Unlock the terminal |
| SYSTEM INFORMATION | |
uname -a | Show basic system information |
cat /etc/*release* | Show basic distribution information |
hostname | Name of computer |
whoami | Current logged in user name |
| FILES AND DIRECTORIES LISTING | |
pwd | Show current working directory |
ls | List files in a directory |
ls -a | Include files starting with . or “hidden” files |
ls -la | Show date and size information of all files |
ls -lS | Sort by file size, largest first |
ls -lSr | Sort by file size, smallest first |
ls -lt | Sort by modification time, newest first |
ls -ltr | Sort by modification time, newest last |
ls -lh | Show file sizes in Kilo, Mega, Giga |
tree | List contents of directories in a tree-like format |
tree -L N | List contents of directories in a tree-like format, limit to N levels |
| DIRECTORY MANIPULATION | |
cd path/to/directory | Change the current working directory |
mkdir directory | Create a directory |
mkdir -p /path/to/directory | Create a directory and the sub-directories |
rmdir directory | Delete an empty directory |
rm -rv directory | Delete a directory and all contents under it recursively |
cp -rv directory destination-directory | Copy a directory to a new location |
mv -r directory destination-directory | Move a directory to a new location |
mv directory new-directory | Rename a directory |
| FILE MANIPULATION | |
rm file | Delete a file |
cp file destination/directory | Copy a file to the destination directory |
mv file destination/directory | Move a file to the destination directory |
mv file new-file | Rename a file |
| ARCHIVES | |
tar -cf archive.tar file1 file2 file3 | Create plain tar archive |
tar -czf archive.tar.gz file1 file2 file3 | Create gzip archive |
tar -cjf archive.tar.bz file1 file2 file3 | Create bzip tar archive |
tar -xf archive.tar | Extract plain tar archive |
tar -xzf archive.tar.gz | Extract gzip archive |
tar -xjf archive.tar.bz | Extract bzip tar archive |
zip -r archive.zip directory/ file1 file2 file3 | Create zip archive |
unzip archive.zip | Extract zip archive |
| DISK, DIRECTORY AND FILE DISK USAGE/SIZES | |
df -h | Show all file system disk space usage |
du -hs /path/to/directory | Show size of directory |
du -hd N /path/to/directory | Show sizes of sub-directories N levels deep |
ls -lh /path/to/directory | Show file sizes in Kilo, Mega, Giga |
| SEARCH | |
find path/to/directory -iname "*.jpg" | Find files in a directory and its sub-directories |
grep -r "foo" /path/to/directory | Find files recursively which contains the string fooSee grep explained for more options |
| PROCESSES | |
ps -ef | grep process-name | Find process with process-name and get process-id for it |
kill process-id | Terminate process with process-id |
kill -9 process-id | Force terminate process with id process-id |
top | List running processes like Windows Task Manager |
| DEVELOPER TOOLS | |
nm | List symbols in object file, equivalent of Windows dumpbin.exe |
ldd | List shared library dependencies, equivalent of Windows depends.exe |
| REMOTE OPERATIONS | |
ssh user@host | Connect to a remote machine using secure shell ssh |
scp path/to/local/file user@host:path/to/remote/directory | Copy local file to remote machine |
scp user@host:path/to/remote/file path/to/local/directory | Copy remote file to local machine |
scp -r path/to/local/directory user@host:path/to/remote/directory | Copy local directory recursively to remote machine |
scp -r user@host:path/to/remote/directory path/to/local/directory | Copy remote directory recursively to local machine |
| UTILITIES | |
history | List recently run commands |
man command | Help page for a command |
clear or CTRL L | Clear the terminal screen |


No responses yet