Whether you’re a developer, sysadmin, or Linux beginner, these 50 fundamental commands form the backbone of efficient terminal usage. Each entry includes practical examples and clear explanations.
🗂️ File & Directory Operations
-
pwd
(Print Working Directory)
Shows your current directory path.
Example:pwd
→/home/user/documents
-
ls
(List)
Displays directory contents. Use-l
for details or-a
for hidden files.
Example:ls -la /var/log
-
cd
(Change Directory)
Navigates between folders.cd ~
returns to home;cd ..
moves up.
Example:cd ./projects/python
-
mkdir
(Make Directory)
Creates new directories. Add-p
to build nested paths.
Example:mkdir -p backup/2024/january
-
touch
Creates empty files or updates timestamps.
Example:touch report.txt
-
cp
(Copy)
Copies files/directories. Use-r
for folders.
Example:cp -r config/ ~/backup/
-
mv
(Move)
Moves/renames files.
Example:mv oldname.txt newname.txt
-
rm
(Remove)
Deletes files. Caution: Irreversible! Add-r
for directories.
Example:rm -r obsolete_folder/
-
find
Searches for files by name, size, or type.
Example:find /home -name "*.jpg"
📄 File Viewing & Editing
-
cat
(Concatenate)
Displays file contents. Combine with>
to create files.
Example:cat notes.txt
-
less
/more
Views large files page-by-page.
Example:less /var/log/syslog
-
head
/tail
Shows first/last lines of a file.tail -f
tracks live updates.
Example:tail -f error.log
-
nano
/vim
Terminal text editors. Nano is beginner-friendly; Vim offers advanced features.
Example:namo config.cfg
🔍 Searching & Filtering
-
grep
Finds text patterns in files. Use-i
for case-insensitive search.
Example:grep -i "error" system.log
-
awk
Processes text/data (e.g., extract columns).
Example:awk '{print $1}' data.csv
-
sed
Stream editor for find/replace operations.
Example:sed 's/old/new/g' file.txt
-
sort
Sorts lines alphabetically/numerically.
Example:sort users.txt
-
uniq
Removes duplicate lines (use withsort
).
Example:sort log.txt | uniq
💻 System Monitoring
-
top
/htop
Real-time system resource viewer (CPU, memory, processes). -
df
(Disk Free)
Shows disk space usage. Add-h
for human-readable format.
Example:df -h
-
du
(Disk Usage)
Reports file/directory space consumption.
Example:du -sh ~/downloads/
-
free
Displays RAM usage.
Example:free -m
(output in MB) -
uname
Prints system kernel info.
Example:uname -a
⚙️ Process Management
ps
(Process Status)
Lists running processes.ps aux
shows all.kill
Terminates processes by PID.kill -9
forces termination.
Example:kill 4512
bg
/fg
Moves jobs to background/foreground.jobs
Displays background jobs.
🔐 Permissions & Ownership
chmod
Changes file permissions (read/write/execute).
Example:chmod +x script.sh
(makes it executable)chown
Changes file owner.
Example:chown user:group file.txt
sudo
(SuperUser Do)
Executes commands with admin privileges.
🌐 Networking
ping
Tests network connectivity to a host.
Example:ping google.com
curl
/wget
Downloads files from URLs.
Example:wget https://example.com/file.zip
ssh
(Secure Shell)
Connects to remote servers securely.
Example:ssh user@192.168.1.5
scp
(Secure Copy)
Transfers files over SSH.
Example:scp file.txt user@remote:/path/
ifconfig
/ip
Configures network interfaces (useip addr
for modern systems).
📦 Compression & Archives
tar
Creates/extracts.tar
archives.
Example:tar -czvf archive.tar.gz /folder
gzip
/gunzip
Compresses/decompresses.gz
files.zip
/unzip
Handles ZIP archives.
🛠️ Utilities
echo
Prints text/variables.
Example:echo $PATH
date
Shows/sets system date/time.history
Lists previously executed commands.alias
Creates command shortcuts.
Example:alias ll='ls -al'
man
(Manual)
Displays command documentation.
Example:man grep
whatis
Summarizes a command’s purpose.which
Locates a command’s executable path.
Example:which python
shutdown
/reboot
Powers off or restarts the system.
👥 User Management
passwd
Changes user passwords.useradd
/usermod
Creates/modifies user accounts.su
(Switch User)
Changes user context.
Example:su - root
id
Shows user/group IDs.
Pro Tips for Beginners:
- Chain commands with
|
(pipe):cat log.txt | grep "ERROR"
- Redirect output with
>
(overwrite) or>>
(append). - Press Tab to auto-complete paths/commands.
- Use
Ctrl+C
to stop any running command.
Master these, and you’ll navigate Linux like a pro! 🐧💻