Linux commonly used Commands: From Basic
to Advanced
1 Introduction
This document provides a concise guide to Linux commands, categorized
into basic, intermediate, and advanced levels. Each command includes a
brief description and example usage. This guide is designed for beginners
to advanced users seeking a quick reference.
2 BasicCommands
These commands are essential for navigating and managing files, directo-
ries, and system information.
2.1 NavigatingtheFileSystem
• pwd: Displays the current directory.
1 pwd
2 % Output: /home/user
• ls: Lists files and directories.
1 ls -l % Detailed listing
2 ls -a % Show hidden files
• cd: Changes the current directory.
1 cd /path/to/directory
2 cd .. % Move up one directory
2.2 FileandDirectoryManagement
• mkdir: Creates a new directory.
1 mkdir new_folder
• touch: Creates an empty file.
Siva Banavathu
1 touch file.txt
• cp: Copies files or directories.
1 cp file.txt /path/to/destination/
2 cp -r folder /path/to/destination/
2.3 ViewingandEditingFiles
• cat: Displays file contents.
1 cat file.txt
• nano: Simple text editor.
1 nano file.txt % Save: Ctrl+O, Exit: Ctrl+X
3 Intermediate Commands
These commands introduce process management, text processing, and net-
working.
3.1 ProcessManagement
• ps: Lists running processes.
1 ps aux % Show all processes
• top: Displays real-time processes.
1 top % Press ’q’ to quit
3.2 TextProcessing
• grep: Searches for patterns in files.
1 grep "error" log.txt
2 grep -r "error" /path/ % Recursive search
• awk: Processes text files.
1 awk ’{print $1}’ file.txt % Print first column
3.3 Networking
• ping: Checks connectivity to a host.
1 ping google.com
• curl: Transfers data from/to a server.
1 curl -O https://example.com/file.txt
Siva Banavathu
4 AdvancedCommands
These commands are for system administration, advanced networking, and
scripting.
4.1 SystemAdministration
• sudo: Runs commands as superuser.
1 sudo apt update % Update package lists
• crontab: Schedules recurring tasks.
1 crontab -e
2 % Example: 0 2 * * * /path/to/script.sh % Run daily at 2 AM
4.2 AdvancedNetworking
• nmap: Scans network for hosts/services.
1 nmap 192.168.1.1
• iptables: Configures firewall rules.
1 iptables -A INPUT -p tcp --dport 22 -j ACCEPT % Allow SSH
5 TipsforUsingLinuxCommands
• Use man <command> for detailed documentation.
• Combine commands with pipes (|) and redirection (>, »).
• Practice in a safe environment to avoid accidental system changes.
6 ExampleWorkflow
To find and compress all .log files modified in the last day:
1 find /var/log -type f -name "*.log" -mtime -1 | xargs tar -zcvf logs
.tar.gz
Siva Banavathu
📁 File and Directory Management
Command Description
ls List directory contents
cd Change directory
pwd Print working directory
mkdir Create a directory
rmdir Remove empty directory
rm Remove files or directories
cp Copy files or directories
mv Move or rename files
touch Create empty files
find Search for files in a directory
locate Find files by name (uses a database)
tree View directory structure as a tree
📄 File Viewing & Manipulation
Command Description
cat Concatenate and display file
less View file content page-by-page
more View file content page-by-page (older)
head View the beginning of a file
tail View the end of a file
nano, vim, vi Text editors
cut, awk, sed Text processing tools
diff Compare two files
wc Count words, lines, characters
Siva Banavathu
🧑💻 User Management
Command Description
whoami Show current user
id Display user ID and group ID
adduser, useradd Add a user
passwd Change password
usermod Modify user account
deluser, userdel Delete a user
groupadd Add a new group
groups Show groups of a user
🔐 Permissions & Ownership
Command Description
chmod Change file permissions
chown Change file owner
chgrp Change group ownership
umask Default permission setting
Siva Banavathu
💻 System Monitoring & Processes
Command Description
ps Show running processes
top, htop Interactive process viewer
kill Kill a process by PID
killall Kill processes by name
nice, renice Set process priority
uptime Show how long system has been running
free Show memory usage
df Disk space usage
du Estimate file/directory size
vmstat System performance stats
🌐 Networking
Command Description
ping Check network connectivity
ifconfig / ip addr Show network interfaces
netstat / ss Network connections
curl, wget Download from URL
host, dig, nslookup DNS lookup
scp, rsync Copy files over SSH
ssh Connect to remote server
ftp, sftp File transfer protocols
Siva Banavathu
📦 Package Management
Debian/Ubuntu (APT)
Command Description
apt update Refresh package list
apt upgrade Upgrade installed packages
apt install Install a package
apt remove Remove a package
dpkg -i Install a .deb file
Red Hat/CentOS (YUM/DNF)
| yum, dnf | Red Hat package managers |
🧰 Disk & Filesystem
Command Description
mount, umount Mount/unmount filesystems
lsblk List block devices
blkid Display block device attributes
fdisk, parted Partition disks
mkfs Create filesystem
fsck Filesystem check
tune2fs Tune ext filesystems
Siva Banavathu
🔄 Archiving & Compression
Command Description
tar Archive files
zip, unzip Compress/decompress zip files
gzip, gunzip Compress/decompress gz files
xz, unxz Compress/decompress xz files
⏲️ Scheduling Tasks
Command Description
cron, crontab Schedule recurring tasks
at Schedule one-time task
systemctl Manage services and daemons
🔧 System & Boot
Command Description
uname -a System info
hostname Show/set hostname
reboot, shutdown Restart/shutdown system
dmesg Boot messages
journalctl View system logs
lsmod, modprobe Kernel modules
Siva Banavathu
🧪 Scripting
Command Description
bash Start a Bash shell
sh Start shell
. / source Run script in current shell
alias / unalias Create/remove shortcuts
🧱 Development & Compilation
Command Description
gcc, g++ Compile C/C++ code
make Build from Makefile
ldd List shared object dependencies
strace Trace system calls
🧹 Cleanup & Maintenance
Command Description
history Show command history
clear Clear terminal screen
alias Create command shortcut
uptime System load info
📙 To Learn More
Command Description
man <command> Manual page for a command
<command> --help Show command help
info <command> More detailed help
Siva Banavathu