All Linux users acknowledge the contributive power of the command-line/terminal environment. It is a wild card when it comes to accomplishing almost 90% of computing tasks associated with any Linux operating system distribution.
By default, any Linux distribution is prepackaged with numerous commands that are useful in meeting day-to-day computing objectives. This list of commands might seem endless and therefore intimidating to newcomers with a thirst for Linux.
Also, expert Linux users might forget the usage syntax associated with such commands. This article guide provides a reference manual for Linux commands which will be priceless during your Linux computing routines.
To make these Linux commands more memorable or easy to reference, we will categorically address them:
1. ls Command
Lists files and directories present in the current folder/directory:
To view more details like the owner, group, size, and relevant timestamps to the listed files and directories.
$ ls -l
You can also list the files of a specific file/directory.
$ ls -l bin
To view hidden files (if any) within a directory. Hidden files’ naming convention starts with a period e.g.
$ ls -a
2. pwd Command
The pwd (print working directory) commands points a user to the absolute path of the current working directory:
3. cd Command
Effective in navigating to a different directory location by specifying its absolute path:
$ cd Apps $ cd /home/dnyce $ cd Documents $ cd ~ $ cd -
4. file Command
Reveals the type of file/directory existing on our Linux machine:
$ file bin $ file emm.jpg $ file passwd
Linux File Manipulation Commands
5. mdkir Command
Creates a new non-existing directory:
$ mkdir new $ ls
6. touch Command
Creates a new blank file.
$ touch new.txt $ ls -l new.txt
7. cat Command
Creates a new file and lets you key in the needed text. Save the file content by pressing
Ctrl + c on your keyboard.
$ cat > file
Open an existing file content in read-only mode.
$ cat file
8. rm Command
Delete a file.
$ rm new.txt $ ls
Deletes a directory with files and other sub-directories
$ rm -r new
9. mv Command
Renames an existing file/directory.
$ mv file renamed_file $ mv newer renamed_newer
10. cp Command
Copies an existing file/directory to a targeted location:
$ cp renamed_file backup $ cp renamed_newer backup $ ls -l backup
Linux File System Search Commands
11. find Command
Locate the instances of a file or directory name from the current working directory.
$ find backup $ find * renamed_file
Linux Basic Administration Commands
12. whoami Command
Prints currently logged in system user.
$ whoami dnyce
13. sudo Command
Enables the execution of root/sudoer-user-privileged commands.
$ sudo apt update
14. reboot Command
Restart your machine.
15. shutdown Command
Power off your machine.
Linux File System Storage Commands
16. df Command
See used and available storage space on mounted partitions.
$ df $ df -h
17. fdisk Command
Retrieve information on all active storage/partitions.
$ sudo fdisk -l
18. du Command
Prints disk usage info of the current working directory.
19. mount Command
Mount an ISO file or storage device:
$ sudo mount file_to_mount target_mount_location
20. umount Command
Unmount a mounted ISO file or Storage device:
$ sudo umount mounted_location
Linux File Compression Commands
21. tar Command
Makes uncompressed tar archive.
$ tar cf name.tar target_directory
Makes a gzip-compressed tar archive.
$ tar cfz backup.tar backup
Extract a tar archive.
$ tar xf backup.tar
22. gzip Command
Makes gzip compression out of a file.
$ gzip renamed_file
23. gunzip Command
Decompresses a gzip compressed file.
$ gunzip renamed_file.gz
Linux Networking Commands
24. ip Command
Displays all active interface info like IP address.
$ ip a
Displays default gateway IP address.
$ ip r
25. ping Command
Test reachability of network device via its IP.
$ ping 192.168.100.3
26. ssh Command
Enables users to connect to remote machines via their IP.
$ ssh 192.168.100.3
Linux File Permission Commands
27. chmod Command
Changes file/directory permissions like read (r), write (w), and execute (x). A plus sign
(+) grants permission, a minus sign
(-) removes permission, an equal sign
(=) grants and removes all others.
$ chmod +x script.sh $ chmod -x script.sh $ chmod =x script.sh
28. chown Command
Changes file/directory ownership.
$ chown root script.sh
29. chgrp Command
Change file/directory group ownership.
$ chgrp root script.sh
Linux User Management Commands
30. useradd Command
Create a new user account (low-level utility).
$ sudo useradd new_user
31. adduser Command
Create a user account (high-level utility).
$ sudo adduser new_user
32. deluser Command
Remove the user account.
$ sudo deluser new_user
33. usermod Command
Modify user account like login.
$ sudo usermod -i john_doe second_user
34. groupadd Command
Add user group.
$ sudo groupadd linuxshelltips
35. delgroup Command
Remove the user group.
$ sudo delgroup linuxshelltips
Linux Hardware Information Commands
36. lshw Command
Provides an informative display of all attached hardware components.
37. lsusb Command
Lists all plugged-in USB devices.
38. dmidecode Command
Provides motherboard, chassis, BIOS, etc info.
$ sudo dmidecode
Other Useful Linux Commands
||Can display a line of text and even write text to a file.|
||Search for specific patterns within a file.|
||Prints a complete user manual associated with the usage of a Linux command.|
||Traces all files on the Linux system matching a specific name pattern.|
||Used to peruse through a large text file from the Linux terminal.|
||Will print the first 10 lines of a text file.|
||Will print the last 10 lines of a text file.|
||Closes the terminal window.|
||List commands executed currently logged in Linux user.|
||Clear all printouts on the Linux terminal screen.|
||Display available signals.|
||Display all running processes with their process Ids (PID).|
||Terminate a running process via its PID.|
||Delays the execution of a Linux command by specifying a periodic value in seconds (s), minutes (m), or hours (h).|
||create a shortcut name for a command.|
This Linux commands cheat sheet article should pave the way for you to categorically master the usage of the Linux terminal environment in the simplest way possible. Know of other cool Linux commands to add to this cheat sheet? Feel free to leave a comment or feedback.