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.
- 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)
List files with details
List files including hidden files
List size of the contents of directories
du -sh *
cd .. (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)
Remove directory (directory must be empty)
Remove a file
Remove a directory with files
rm -r directory
Find a directory named example
find / -type d -name "example"
View file in text editor. There are many choices but I find nano to be the easiest to use.
Copy a file
cp file.txt filecopy.txt
Rename a file
mv file.txt newfilename.txt
Move a file
mv 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
fdisk -l or
Check disk space
Check modification/access date of file
Read the last 10 lines of a log file and watch for new lines
tail -f example.log
Create an empty file
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 recursively
grep -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.
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-up
sudo systemctl enable SERVICE_NAME
Download a file to this directory
Show IP addresses
Show IP Addresses
Change a password
Combining commands (Use “&&” per example)
cd .. && ls (go back a directory and list directory)
Restart the OS now
Shutdown the OS now
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.