Show Menu

Linux Commands Cheat Sheet Cheat Sheet by

This cheat sheet is built with around 20 common Linux commands. Some commands include options.

File Commands

- list files in the directory
ls -al
- list long formatted files with hidden files
- return to home directory
- display current working directory
touch file
- create or update file
mkdir dir
- create a new directory dir
rm file
- remove file
nano file
- edit the file using Nano's editor
mv file1 file2/dir
- rename file1 to file2 or move file1 to dir
rmdir dir
- remove empty directory dir
rm -r dir
- remove directory dir
cp file1 file2
- copy file1 to file2
cp -r dir1 dir2
- copy directory dir1 to dir2 and create dir2 if it does not exist

File Permis­sions

chmod file
- change file permission
chmod u-w file
- remove the writable permission from file to user
chmod 777 file
- give read, write, execute permission to all
 ­ ­Ope­rator for chmod
add the specified modes
Remove the specified modes from file or dir
Set the specified modes
chown user:group file
- change the ownership of file

Users and Groups

groupadd group
- add a new group
useradd -g group nUser
- add a new user to group
usermod -g group eUser
- add an existing user to group
lid -g group
- list all the users in the group
All the above commands require superuser privil­eges.


ping host
- ping host
wget file
- download file

System Info

- display the login username
uname -a
- display all the system inform­ation
whereis app
- show possible locations of app
which app
- shows the full path of the app
df -h
- show file system disk space usage with human-­rea­dable storage size
du -d0 -h dir
- display the directory space usage without displaying subdir­ect­ories

Process Management

- display current active processes
- display all running processes
kill pid
- kill a process by ID
killall procname
- kill a process by a name


tar -cvf file.tar files/dir
- create a tar file to archive the files/dir and display the progress in the terminal.
tar -xzvf file.tar.gz -C dir
- extract a tar using Gzip to directory dir
tar -czf file.gz file.tar
- compress the file.tar to file.gz using Gzip
gzip file
- compress file and rename it to file.gz
gzip -d file.gz
- decompress file.gz back to file


grep pattern files
- search for pattern in files, * denotes all the files
grep -r pattern dir
- search for the pattern in dir
grep -i pattern file
- ignore the case and search for the pattern
command | grep pattern
- search for the pattern in the output of command
locate file
- find all instances of file by name
A regular expression is used to describes a particular search pattern .


> file
- output operator to overwrite the file
>> file
- append operator to append the text at the end of the file
- pipe operator to take the output from the preceding command to be the input of the following command


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          screen Cheat Sheet
          Bash Keyboard Shortcuts
          bash Shortcuts Cheat Sheet