There are so many Linux commands that it can be difficult to remember them all, especially for beginners. That’s why I’ve created a handy Linux commands cheat sheet. Use this as a quick reference for when you just can’t remember the right command. It happens to me more often than I’d like to admit.
The Linux command set is extremely robust. Very frequently there are multiple Linux CLI commands to reach similar results. I have found these to be the most convenient for me. This isn’t meant to be an exhaustive list. It’s more of a beginners guide to Linux. I’m only providing common commands that are used frequently.
Notes
- Some commands may need Sudo or SU prefixed before them for permissions reasons. This is especially true if you are not logged in as root. You would use “sudo command” or “su command” for example.
- Append ” –help” to any command for options and syntax help.
Linux Commands Cheat Sheet
Display current directory (print working directory)pwd
List filesls
List files with detailsls -l
List files including hidden filesls -a
List size of the contents of directoriesdu -sh *
Change directorycd ..
(return to parent directory)cd exampledirectory
(enter a subdirectory)cd /rootdirectory/path/to/somewhere/
(jump to an absolute path from root)cd /
(go to file system root)
Make directorymkdir newdirectory
Remove directory (directory must be empty)rmdir directory
Remove a filerm file.txt
Remove a directory with filesrm -r directory
Find a directory named examplefind / -type d -name "example"
View file in text editor. There are many choices but I find nano to be the easiest to use.nano
Copy a filecp file.txt filecopy.txt
Rename a filemv file.txt newfilename.txt
Move a filemv file.txt anotherdirectory/file.txt
Change permissions of a file/directory (-R for recursively)chmod -R 777 directoryorfile
Change owner of a file/directory (-R for recursively)chown -R user:group fileordirectory
View partitionsfdisk -l
or lsblk
Check disk spacedf -h
Check modification/access date of filestat filename
Read the last 10 lines of a log file and watch for new linestail -f example.log
Create an empty filetouch example.txt
Create a zip archive. The 5 signifies the level of compression. 0 is none and 9 is the most. This will recursively compress subdirectory into example.zip.zip -5 -r example.zip subdirectory
Empty the contents of a file. This can be very useful for clearing log files without having to delete the file, recreate it, and adjust permissions.cat /dev/null > logfile.log
Search for text within all files in this directory and recursivelygrep -r exampletext
View resources and a list of processes ordered by top CPU usage. Tip: When top is running press shift-i to calculate percentages for multiple CPU cores.top
Work with services. Some services will be under the service command instead of systemctl.systemctl start SERVICE_NAME
systemctl stop SERVICE_NAME
systemctl restart SERVICE_NAME
systemctl status SERVICE_NAME
Start (enable) service at boot-upsudo systemctl enable SERVICE_NAME
Download a file to this directorywget https://someplace.com/somefile.txt
Show IP addressesip addr
Show IP Addressesip
addr
Change a passwordpasswd username
Combining commands (Use “&&” per example)cd .. && ls
(go back a directory and list directory)
Restart the OS nowreboot now
Shutdown the OS nowshutdown now
Conclusion
This list should get you going if you are a beginner or help you remember easy Linux commands that you’ve forgotten. I hope this Linux commands cheat sheet has been useful to you.