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.


CTRL c Interrupt and kill a process
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
tar -cf archive.tar file1 file2 file3 Create plain tar archive
tar -czf archive.tar.gz file1 file2 file3 Create gzip archive
tar -cjf 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 Extract bzip tar archive
zip -r directory/ file1 file2 file3 Create zip archive
unzip 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
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 foo
See grep explained for more options
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
history List recently run commands
man command Help page for a command
clear or CTRL L Clear the terminal screen

You might also find these basic Vi/Vim and Package Manager commands useful.
If there are other commonly used commands that you think are missing, do let me know.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s