Linux Command Cheat Sheet

Linux command cheat sheet article contains the Linux commands you frequently use and Linux commands that you need for interviews, exams… etc. with pop up links to man pages. You can bookmark this article and use it when you required while you practicing exams, interviews or while you work.

Basic Commands

lsList directory content
ls -a (all)Lists hidden files as well (Do not ignore entries starting with .)
ls -lUse long listing format (with detailed information like permission, size, owner …etc)
ls -alGet all files and directories in the current directory in long listing format (list hidden files as well)
ls -R
cp [source] [destination]Copy file or directory
mv [source] [destination]Move files or directories (Rename)
rm [file_name]Remove file or directory

Directory Operation Commands

mkdir [directory_name]Make a directory
rmdirDelete directory
pwdShow current directory
cd [directory_name]Navigate to particular directory in current directory
cd [path] [directory_name]Navigate to particular directory directory
cd or cd ~Navigate to home directory
cd ..Go up one level in the directory tree
cd /Navigate to root directory
mvRename a directory

File Operation Commands

touch [filename]Creates a new file
cat [filename]Display the file content
cat file1 file2 > file3Join two files and store the output content of both files in the new file (file1 + file2 -> file3)
mv file new_file_nameRename file to new_file_name
head [file_name]Print first 10 lines of the file
tail [file_name]Print last 10 lines of the file

Search Operation Commands

grep -oPrint only the matching part of the matching line or file
grep -wPrint only the lines and file names that are matching the whole word
grep -iPrint the search results ignoring case sensitive
grep -cPrint the count of the number of matches
grep -nPrint line numbers while displaying the output
grep -rSearch recursively, in all files under each directory
grep -vPrint invert of the match, Search only the lines that do not contain the given word
locate [search_name]Search files with specific name
find [file_name]Search files with specific name
find -emptySearch empty files and directories
find -user [user_name]Search files owned by [user_name]
find -mmin [num]Search files modified less than [num] minute ago
find -name [name]Search the files, file name starting with [name]

Keep this Linux command cheat sheet bookmarked with you and it will be helpful when you mostly need it.

You can find 10 Basic Linux Command that will frequently use mostly with examples from here.

Leave a Reply

Your email address will not be published. Required fields are marked *