The Linux command line interface allows you to control and manage your system efficiently. As a Linux system administrator or developer, knowing the most useful Linux commands is essential for optimizing work and system performance.
In this comprehensive guide, we cover the top 25 Linux commands for beginners to get started with.
1. ls
The ls command lists the contents of the current working directory. It shows all files and subdirectories in the location you execute it.
$ ls
Documents Pictures Videos
You can view hidden dotfiles in the output by passing the -a flag:
$ ls -a
.config .cache Documents Pictures .profile Videos
List files in a specific directory by providing the path:
$ ls /home/user/Documents
reports.docx notes.txt

2. cd
The cd command navigates between directories. Execute it along with the path to the destination directory.
For example, to change the working directory to ~/Pictures:
$ cd ~/Pictures
To go back to the parent directory:
$ cd ..
Print the current working directory at any time with pwd.
3. mkdir
The mkdir command creates a new directory. Provide the desired directory name:
$ mkdir Projects
Create nested directories with one command by separating names with spaces:
$ mkdir Music/New Albums Movies/2019

4. rmdir
Remove empty directories using the rmdir command. Deleting the temp/ directory for instance would be:
$ rmdir temp/
Attempt to delete non-empty directories will result in an error. Delete folder contents first before removing parent directories.
5. touch
The touch command creates blank new files instantly. For example, building project scaffolding can be done by:
$ touch index.html script.js styles.css
6. cp
To copy files and directories use the cp command. Provide the source and destination as arguments:
$ cp -r folder1 folder2
The -r flag makes copy recursive on directories.
7. mv
The mv command moves and renames files or directories. For example, to rename script.py to automate.py:
$ mv script.py automate.py
Move several files into a directory:
$ mv file.txt file2.txt ~/Documents

8. rm
Deleting a file permanently is done using rm. Remove unimportant temp.txt for example with:
$ rm temp.txt
Be very careful running rm on directories, as the contained files and subdirectories delete recursively.
9. cat
Print file contents to the standard output with the cat command. View notes.txt for instance with:
$ cat notes.txt
Important meeting on Wednesday.
Need to prepare documents.
Concatenate several files and print as output:
$ cat file1.txt file2.txt
[contents of file1 and file2]
10. less
Paginate through text files with less instead of showing the full contents instantly like cat. Browse lengthy logs for example with:
$ less log.txt
[navigate file]
Search forwards and backwards using / and ?. Quit by pressing q.
11. head/tail
Print the first or last 10 lines of a text file using head and tail respectively:
$ head log.txt
$ tail log.txt
Customize count of lines to show by appending -n:
$ tail -20 log.txt
12. grep
The grep command searches for matching text patterns within files. Search notes.txt for occurrences of "August" for example:
$ grep "August" notes.txt
Meeting rescheduled to August 5th.
August deadline needs preparation.
Useful grep options:
-cto print count of matching lines only-ifor case-insensitive matches-vto show non-matching lines
13. sudo
The sudo command runs an application with root privileges. For example, editing sysctl.conf:
$ sudo nano /etc/sysctl.conf
Append commands with sudo when admin permissions required. Grant access by entering user password when prompted.
14. ps
The ps command shows currently running system processes along with process IDs (PID). Passing aux displays comprehensive information:
$ ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.3 19304 6732 ? Ss Jan06 0:16 /usr/bin/systemd
Filter to search for a process:
$ ps aux | grep "[p]rocessname"
15. kill
End unresponsive applications and system processes with the kill command. Specify PID obtained from ps to terminate gracefully:
$ kill 4853
Force instant shutdown of a process by sending the KILL signal:
$ kill -9 4853
16. ping
The networking ping command verifies connectivity to a remote host by sending ICMP echo request packets and waiting for response.
Ping host at IP address 8.8.8.8 for example:
$ ping 8.8.8.8
64 bytes from 8.8.8.8: seq=0 ttl=37 time=16.264 ms
Stop after a count of 5 packets with:
$ ping 8.8.8.8 -c 5
17. df
Query disk space usage statistics of the file system with the df command:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 3977768 0 3977768 0% /dev
tmpfs 807340 8564 798776 2% /run
/dev/sda1 48767288 44341908 2622332 95% /
Human-readable size format can be shown with -h.
18. du
Show disk usage statistics of a directory using du:
$ du Music/
16 Music/Rock
32 Music/Pop
48 Music/
Pass -h for human-readable printed sizes. Reduce depth with --max-depth=1.
19. tar
The tar command archives and extracts bundles of files in .tar format:
- Create archive:
$ tar -cvf archive.tar folder/ - Extract archive contents:
$ tar -xvf archive.tar
Some useful options:
-ccreates archive-xextracts archive-vverbose output-farchive filename
20. chmod
The chmod command modifies access permissions of files and directories. The permissions are separated into 3 classes:
- u – owning user
- g – owning group
- o – other users
And 3 access types:
- r – read
- w – write
- x – execute
For example, grant user read and execute on script.sh with:
$ chmod u=rx script.sh
Set permissions recursively with -R.
21. chown
The file/directory owner and the group can be altered with chown. For example, grant user bob ownership of folder:
$ chown bob folder
Recursively assign group admins on folder:
$ chown -R :admins folder
22. find
The find command recursively searches for matching files and directories under the given start path. For instance, locate *.jpg images under /home:
$ find /home -name *.jpg
/home/user1/Desktop/photo.jpg
/home/user2/Pictures/image.jpg
Customize search constraint:
$ find . -size +2MB
23. ssh
The ssh command provides secure encrypted connection to remote servers. Logging in to a server 192.168.5.1 for example:
$ ssh [email protected]
Enter passphrase for key ‘/home/user/.ssh/id_rsa‘:
Last login: Sat Jan 14 08:23:34 2022 from 192.168.5.5
Optionally specify alternative port and private key file path.
24. man
By appending a command name with man, you can access its manual page. Manuals provide help descriptions, usage information and examples.
$ man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]
Scroll documentation by line. Quit by pressing q.
25. uname
The uname command prints details about the current machine and operating system. Extracting kernel name for instance:
$ uname -s
Linux
Some options are:
-ashow all information-rkernel release number-mmachine hardware name
And there you have it — 25 essential Linux commands for system admins and developers! With mastery of these, working proficiently on Linux shouldn‘t be a problem. Refer to the manuals when in doubt.


