Comprehensive Linux Command Cheat Sheet
This cheat sheet compiles essential Linux command‑line tools—including navigation (cd, pwd, ls), file manipulation (cp, mv, rm, cat), searching (find, grep), permission management (chmod, chown), archiving (tar), text processing (cut), and redirection or piping—each with common options and practical usage examples for everyday system administration.
Linux provides a rich set of command‑line tools for file management, process control, networking, compression, and more. This guide lists common commands such as cd , pwd , ls , cp , mv , rm , cat , find , chmod , chown , chgrp , grep , paste , sort , comm , tar , jps , kill , killall , top , touch , mkdir , ps , ping , ifconfig , redirection operators, pipes, and cut , together with typical options and example usages.
cd – change directory
Switches the current working directory.
cd .. # return to parent directory
cd ../.. # return two levels up
cd ~ # go to home directory
cd - # go back to previous directorypwd – print working directory
Displays the absolute path of the current directory.
ls – list directory contents
Shows files and sub‑directories.
ls # list files
ls -l # detailed view
ls -a # include hidden files
ls -R # recursive listing
ls [0-9] # show names containing numberscp – copy files
Copies files or directories.
-a : preserve attributes
-p : preserve mode, ownership and timestamps
-i : prompt before overwrite
-r : copy directories recursively
-u : copy only when source is newermv – move/rename files
Moves or renames files or directories.
-f : force overwrite without prompting
-i : interactive prompt before overwrite
-u : replace only when source is newerrm – remove files
Deletes files or directories.
-f # ignore nonexistent files, never prompt
-i # prompt before each removal
-r # recursive removal of directories
rm -rf # forceful recursive deletecat – concatenate and display files
Shows file contents and can concatenate multiple files.
cat file1 # display file
cat -n file1 # number lines
more file1 # paginate output
head -n 2 file1 # first two lines
tail -n 2 file1 # last two linesfind – search for files
Searches the filesystem for files matching criteria.
find / -name file1 # search from root
find / -user user1 # files owned by user1
find /usr/bin -type f -atime +100 # not accessed in 100 dayschmod – change file mode
Modifies read/write/execute permissions.
chmod ugo+rwx directory # give all permissions to everyonechown – change file owner
Changes the owner (and optionally group) of a file.
chown user1 file1
chown -R user1 directory1
chown user1:group1 file1grep – pattern search
Searches for lines matching a regular expression.
grep Aug /var/log/messages # find "Aug" in log
grep ^Aug /var/log/messages # lines starting with "Aug"
grep [0-9] /var/log/messages # lines containing digitstar – archive and compress
Creates or extracts archive files; supports gzip, bzip2, etc.
-c : create archive
-t : list archive contents
-x : extract archive
-j : use bzip2
-z : use gzip
-v : verbose output
-f filename : specify archive fileRedirection and pipes
Redirect output with > , append with >> , read input with < , and chain commands with | .
ls > file.txt # write listing to file
date >> file.txt # append date to file
sort < file.txt # sort contents of file
ls | grep file # filter listingcut – extract columns
Extracts specific fields or characters from each line.
cut -c 1,3 file.txt # characters 1 and 3
cut -d ':' -f 2,4 file.txt # fields 2 and 4 using ':' as delimiter
cut -c 1,3 --complement file.txt # all but characters 1 and 3These commands form the core toolbox for daily Linux system administration and scripting.
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.