
Linux is an incredibly powerful and flexible operating system, and learning it opens up endless possibilities for both personal and professional growth. However, as a beginner, navigating the Linux command line can feel overwhelming.
1. Basic Commands
What Are They?
These commands are your first step into the Linux world, helping you navigate the file system and perform simple operations.
Common Commands:
Command | Description | Example |
---|---|---|
cd | Change the current directory. | cd /home |
pwd | Display the current directory path. | pwd |
ls | List files and directories. | ls -l |
mkdir | Create a new directory. | mkdir my_folder |
rm | Remove files or directories. | rm file.txt |
cp | Copy files or directories. | cp file1.txt file2.txt |
mv | Move or rename files or directories. | mv oldname.txt newname.txt |
touch | Create an empty file. | touch newfile.txt |
2. File Management
Why It Matters
Efficient file management is essential for navigating your system and organizing your data.
Common Commands:
Command | Description | Example |
---|---|---|
find | Search for files and directories. | find / -name filename |
locate | Quickly find files by name. | locate myfile |
which | Locate the executable path of a command. | which python3 |
du | Estimate the size of files or directories. | du -h folder_name |
df | Display disk space usage. | df -h |
chmod | Change file permissions. | chmod 755 script.sh |
chown | Change file ownership. | chown user:user file.txt |
3. Text Editing
What You’ll Do
Linux supports a variety of text editors for creating and modifying files.
Common Commands:
Command | Description | Example |
---|---|---|
nano | A simple, beginner-friendly text editor. | nano file.txt |
vim | Advanced editor for programming and text editing. | vim script.sh |
gedit | GUI text editor for GNOME environments. | gedit notes.txt |
4. Networking
Connect and Explore
Networking commands help you configure, troubleshoot, and explore your network.
Common Commands:
Command | Description | Example |
---|---|---|
ping | Test connectivity to a host. | ping google.com |
traceroute | Trace the route to a network host. | traceroute example.com |
ssh | Securely log in to remote systems. | ssh user@host |
scp | Copy files securely between systems. | scp file.txt user@host:/path |
5. System Administration
Manage Your System
These commands allow you to control users, services, and system settings.
Common Commands:
Command | Description | Example |
---|---|---|
sudo | Run commands with administrative privileges. | sudo apt update |
passwd | Change user passwords. | passwd username |
systemctl | Manage system services. | systemctl restart apache2 |
6. System Monitoring
Keep an Eye on Performance
Monitor processes and resources with these powerful commands.
Common Commands:
Command | Description | Example |
---|---|---|
top | Display real-time system processes. | top |
htop | Interactive process viewer. | htop |
free | Check memory usage. | free -h |
df | View available disk space. | df -h |
7. Disk Management
Manage Storage
Partition, format, and manage disk usage with these commands.
Common Commands:
Command | Description | Example |
---|---|---|
fdisk | Partition your hard drive. | sudo fdisk /dev/sda |
mkfs | Format a drive with a specific file system. | mkfs.ext4 /dev/sda1 |
lsblk | Display information about storage devices. | lsblk |
8. Security
Stay Safe
Protect your system with these essential security commands.
Common Commands:
Command | Description | Example |
---|---|---|
chmod | Modify file permissions. | chmod 644 file.txt |
chown | Change file ownership. | chown root:root file.txt |
ssh-keygen | Generate SSH keys for secure access. | ssh-keygen -t rsa |
9. Backup and Recovery
Protect Your Data
Backup and recovery commands help safeguard your files and restore them when needed.
Command | Description | Example |
---|---|---|
tar | Archive files into a .tar file. | tar -cvf archive.tar files/ |
gzip | Compress files using the gzip algorithm. | gzip file.txt |
bzip2 | Compress files using the bzip2 algorithm. | bzip2 file.txt |
zip | Create a compressed archive. | zip archive.zip files/ |
unzip | Extract files from a .zip archive. | unzip archive.zip |
rsync | Sync files between directories or systems. | rsync -avz source/ dest/ |
cp | Copy files or directories. | cp -r backup/ original/ |
dd | Create a disk image or clone a drive. | dd if=/dev/sda of=backup.img |
10. Package Management
Install and Manage Software
Package managers make installing and updating software easy on Linux.
Command | Description | Example |
---|---|---|
apt | Manage packages on Debian-based systems. | sudo apt install package |
yum | Manage packages on Red Hat-based systems. | sudo yum install package |
dnf | Modern replacement for yum . | sudo dnf update |
zypper | Package manager for openSUSE. | zypper install package |
pacman | Manage packages on Arch Linux. | sudo pacman -S package |
snap | Install software from Snapcraft. | sudo snap install app |
flatpak | Universal package manager for Linux. | flatpak install app |
11. Compression and Archiving
Save Space and Organize
Compress and extract files with these powerful commands.
Command | Description | Example |
---|---|---|
gzip | Compress files. | gzip file.txt |
gunzip | Decompress .gz files. | gunzip file.txt.gz |
bzip2 | Compress files using bzip2. | bzip2 file.txt |
bunzip2 | Decompress .bz2 files. | bunzip2 file.txt.bz2 |
zip | Compress files into a .zip archive. | zip archive.zip file.txt |
unzip | Extract files from a .zip archive. | unzip archive.zip |
tar | Archive and compress files. | tar -czvf archive.tar.gz dir |
12. Development Tools
Code Like a Pro
Linux is developer-friendly, and these commands make coding and compiling easier.
Command | Description | Example |
---|---|---|
gcc | Compile C programs. | gcc -o output program.c |
make | Build software from source code. | make |
gdb | Debug programs. | gdb ./program |
python | Run Python scripts. | python script.py |
java | Run Java programs. | java Program |
node | Run Node.js applications. | node app.js |
13. Logs and Troubleshooting
Diagnose and Fix Issues
Access system logs and troubleshoot problems with these commands.
Command | Description | Example |
---|---|---|
dmesg | View kernel messages. | dmesg | grep error |
journalctl | View logs managed by systemd . | journalctl -xe |
tail | View the last few lines of a file. | tail -f /var/log/syslog |
grep | Search for patterns in files. | grep 'error' log.txt |
strace | Trace system calls made by a process. | strace ./program |
lsof | List open files by processes. | lsof -i :8080 |
14. Disk and Filesystem Management
Master Storage and Filesystem Commands
Disk management is critical for organizing and optimizing your system’s storage.
Command | Description | Example |
---|---|---|
fdisk | Partition a disk. | sudo fdisk /dev/sda |
mkfs | Format a partition with a filesystem. | mkfs.ext4 /dev/sda1 |
fsck | Check and repair a filesystem. | sudo fsck /dev/sda1 |
mount | Mount a filesystem. | mount /dev/sda1 /mnt |
umount | Unmount a filesystem. | umount /mnt |
df | Display disk usage of file systems. | df -h |
du | Show disk usage of directories and files. | du -sh /home/user |
lsblk | List information about block devices. | lsblk |
blkid | Show filesystem UUIDs and labels. | blkid |
parted | Manage partitions. | sudo parted /dev/sda |
15. Networking and Internet Commands
Stay Connected
These commands let you manage and troubleshoot network configurations and connections.
Command | Description | Example |
---|---|---|
ifconfig | Display and configure network interfaces. | ifconfig eth0 |
ip | Show/manipulate network settings. | ip addr show |
netstat | Display active connections and listening ports. | netstat -tuln |
route | Show and manipulate the routing table. | route -n |
ping | Test connectivity to a host. | ping google.com |
traceroute | Trace the path packets take to a host. | traceroute google.com |
curl | Fetch data from a URL. | curl https://example.com |
wget | Download files from a URL. | wget https://example.com/file |
ssh | Remote login to a server. | ssh user@192.168.1.1 |
scp | Copy files over SSH. | scp file.txt user@remote:/path |
16. Security and Permissions
Keep Your System Safe
Linux allows granular control over user access and permissions with these commands.
Command | Description | Example |
---|---|---|
chmod | Change file permissions. | chmod 755 script.sh |
chown | Change file owner. | chown user:group file.txt |
passwd | Update a user’s password. | passwd |
sudo | Run commands with root privileges. | sudo apt update |
ufw | Manage the firewall (Uncomplicated Firewall). | sudo ufw enable |
iptables | Configure the firewall rules. | sudo iptables -L |
openssl | Create and manage SSL/TLS certificates. | openssl genrsa -out key.pem |
ssh-keygen | Generate SSH key pairs for secure connections. | ssh-keygen -t rsa |
gpg | Encrypt and sign files. | gpg -c file.txt |
auditctl | Manage audit rules for security logging. | auditctl -l |
17. System Monitoring
Keep an Eye on Performance
Monitoring tools help diagnose issues and optimize system performance.
Command | Description | Example |
---|---|---|
top | Display real-time system processes. | top |
htop | Interactive process viewer. | htop |
vmstat | Show system resource usage. | vmstat 1 |
iostat | Display CPU and I/O statistics. | iostat |
free | Show memory usage. | free -h |
ps | Display running processes. | ps aux |
kill | Terminate a process by ID. | kill 1234 |
pidstat | Display CPU usage per process. | pidstat |
sar | Collect, report, and save system activity data. | sar -u 5 |
iotop | Show I/O usage by processes. | sudo iotop |
18. File Search and Manipulation
Locate and Edit Files Quickly
Efficiently find and manipulate files with these commands.
Command | Description | Example |
---|---|---|
find | Search for files by name or attribute. | find / -name file.txt |
locate | Quickly locate files by name. | locate file.txt |
grep | Search text in files. | grep 'keyword' file.txt |
sed | Stream editor for modifying file content. | sed 's/old/new/g' file.txt |
awk | Process and analyze text files. | awk '{print $1}' file.txt |
cut | Remove sections of a file. | cut -d: -f1 /etc/passwd |
sort | Sort file content alphabetically. | sort file.txt |
uniq | Remove duplicate lines in a file. | uniq file.txt |
diff | Compare the content of two files. | diff file1.txt file2.txt |
cmp | Compare two files byte by byte. | cmp file1.txt file2.txt |
Thanks for reading our blog hope you guy’s like this