As one of the most popular operating systems in the world, Linux offers immense flexibility and customization through its powerful command line interface. Mastering basic Linux commands is essential for leveraging the operating system‘s capabilities and managing your system productively.
This comprehensive guide covers the top 25 must-know Linux commands with detailed explanations, syntax, and examples for Linux beginners and system administrators.
File Management Commands
File management forms the core of many common Linux tasks. Here are some of the most important Linux commands for managing files and directories.
ls – List Directory Contents
The ls command is used to view the contents of a directory. Running ls by itself will show files and subdirectories in the current directory.
$ ls
documents downloads music pictures
You can view the contents of a different directory by passing the directory path as an argument:
$ ls /home/user/documents
report.pdf presentation.pptx spreadsheet.xlsx
Common ls options:
ls -l– Use a long listing format showing permissions, size, owner etc.ls -a– Show hidden files and directoriesls -la– Combine the two options above
cd – Change Directory
The cd command is used to move into a directory. To access your home directory, use:
$ cd ~
You can also directly move to any path:
$ cd /home/user/documents
Use cd .. to go up one directory level.
mkdir – Make Directory
The mkdir command creates a new directory. To make a directory called temp under the current directory:
$ mkdir temp
You can also create nested directories in one command:
$ mkdir -p sites/blog/temp
Here the -p option ensures the parent sites and blog directories are created automatically if they don‘t exist.
rm – Remove Files
The rm command deletes files and directories. To remove a file called report.pdf:
$ rm report.pdf
Use recursive deleting with care – rm -r temp will remove the entire temp directory with all its content.
mv – Move and Rename
The mv command moves or renames files and directories. To rename the file presentation.pptx to sales.pptx:
$ mv presentation.pptx sales.pptx
You can also move files between directories:
$ mv report.pdf /home/user/documents/business
And move multiple files with wildcards:
$ mv *.jpg /home/user/pictures
cp – Copy Files
The cp command copies files. To copy resume.docx to the backups directory:
$ cp resume.docx backups
Recursively copy a directory with:
$ cp -r documents reports
Advanced use cases involve combining cp with wildcard matching.
Process Management
In addition to managing files, mastering Linux process commands is vital to monitor system health and productivity.
ps – Process Status
The ps command provides a snapshot of currently running processes. Common invocations:
$ ps aux # Show all running processes
$ ps aux | grep browser # Filter for browser processes only
$ ps -ef | grep [p]ython # Filter for python processes
kill – Terminate Processes
The kill command ends a process by its PID. First find the PID with ps, then terminate it with kill:
$ ps aux | grep firefox
jane 3356 1.5 2.3 201684 98764 ? Sl 15:04 2:10 firefox
$ kill 3356
For a more forceful terminate use kill -9.
top – Process Monitoring
The top command displays dynamic real-time information about running processes. It provides an interactive interface for process monitoring:
$ top
top - 15:17:35 up 35 min, 3 users, load average: 0.39, 0.33, 0.12
Tasks: 311 total, 2 running, 309 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.4 us, 5.3 sy, 0.0 ni, 83.8 id, 0.5 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3900.4 total, 1706.6 free, 921.9 used, 1271.8 buff/cache
MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 2818.8 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
76015 jane 20 0 532784 49508 41456 S 11.3 1.3 1:07.93 firefox
76002 jane 20 0 4353676 274772 114808 S 5.6 7.1 0:04.18 plugin-containe
Type q to exit.
File Permissions
One unique aspect of Linux is the ability to exert fine-grained control over file permissions. Here are important commands related to permissions management.
chmod – Modify Permissions
The chmod command changes a file‘s permissions. Permissions are controlled by read, write and execute bits.
To give myfile.txt read and write permissions for the owner, read-only for the group, and no permissions for others:
$ chmod 640 myfile.txt
Symbolic modes provide an easier way:
$ chmod u=rw,g=r,o= myfile.txt
chown – Change Ownership
The chown command changes file owner and group. To make jane the owner of myfile.txt:
$ chown jane myfile.txt
You can also modify the group:
$ chown jane:devs myfile.txt
Only the superuser can change ownership. Useful for transferring files between users.
chgrp – Change Group
The chgrp command changes just the file group. Making myfile.txt owned by the devs group:
$ chgrp devs myfile.txt
Useful shortcut when changing group across many files.
Network and System Info
The commands below help you monitor system resources, troubleshoot network issues and interact with remote servers.
df – Disk Space Usage
The df command provides disk space usage summary for mounted filesystems:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 3966572 0 3966572 0% /dev
tmpfs 803900 6588 797312 1% /run
/dev/sda1 30255644 2184536 26801856 8% /
Common options:
df -h– Human readable output with unit suffixesdf -T– Also display filesystem type
free – Memory Usage
The free command displays system memory usage statistics:
$ free
total used free shared buff/cache available
Mem: 4051904 1154584 509900 91968 2439420 2768428
Swap: 2097148 0 2097148
ping – Network Connectivity
The venerable ping tool checks connectivity to a server. It uses ICMP echo packets to test reachability across an IP network:
$ ping linuxize.com
PING linuxize.com (209.222.8.221) 56(84) bytes of data.
64 bytes from host.linuxize.com (209.222.8.221): icmp_seq=1 ttl=63 time=0.800 ms
Ping continues sending packets until stopped with Ctrl+C. Useful to diagnose network issues.
curl – Transfer Data with URLs
The curl tool transfers data using various network protocols. Most commonly used to:
- Make HTTP requests like GET or POST
- Transfer files via FTP or SFTP
Basic usage – use curl to get a web page:
$ curl https://www.linux.com
<html>
<body>Linux news and resources</body>
</html>
Curl supports loads of advanced options – proxy use, authentication, headers etc. One of the most versatile Linux commands out there.
Text Processing
Linux offers unparalleled text processing capabilities. Below are some text related commands new users should know.
cat – Print File Contents
The humble cat does one job, but does it well – print files to standard output.
$ cat file.txt
Hello Linux!
Welcome to the Linux command line.
cat can also combine files, useful when reading logs:
$ cat access.log auth.log > combined_logs.txt
grep – Find Text Patterns
The grep filter searches text files for specified patterns.
To print lines in app.log containing the word "error":
$ grep error app.log
Commonly combined with pipes like so:
$ dmesg | grep firmware
head/tail – View File Ends
To print the first 10 lines of install.log use head:
$ head install.log
Conversely, print the last 10 lines with tail:
$ tail install.log
Both are handy companions to tools like grep.
cut – Parse Columns
The cut tool extracts sections of text from lines – useful for parsing columnar data.
Say file.csv contains:
Date,Name,Sales
01/02/2023,John,15000
01/02/2023,Jane,20000
Extract just the Sales column with:
$ cut -d ‘,‘ -f3 file.csv
Conclusion
That wraps up 25 of the most useful Linux commands for beginners. Linux offers a vast collection of tools for system administrators and power users. Mastering the commands listed in this guide will give you control over the most common Linux tasks.
Refer to the quick examples above whenever you need a refresher. Over time, these commands will become second nature, allowing you to comfortably navigate Linux systems as an expert user.



