Mastering Linux commands is essential for DevOps professionals. Whether managing servers, automating tasks, or troubleshooting, these commands will streamline your workflow.


1️⃣ File & Directory Management

📂 Navigating the Filesystem

pwd                   # Show current directory
ls                    # List files & directories
cd         # Change directory
mkdir      # Create a new directory
rmdir      # Remove an empty directory
rm -rf     # Delete a directory and its contents

📄 File Operations

touch           # Create an empty file
cat             # View file content
less            # View file content page by page
head -n    # Show first ‘n’ lines
tail -n    # Show last ‘n’ lines
mv <source>     # Move/rename a file
cp <source>     # Copy a file
rm              # Delete a file

2️⃣ User & Permission Management

whoami                # Show current user
who                   # List logged-in users
id                    # Display user & group ID
chmod 755       # Change file permissions
chown user:group   # Change file ownership
passwd                # Change password
adduser     # Add a new user
deluser     # Delete a user
sudo <command>        # Run command as superuser

3️⃣ Process Management

ps aux                # List running processes
top                   # Show system resource usage
htop                  # Interactive process viewer (if installed)
kill             # Terminate a process
killall         # Kill all processes by name
pkill        # Kill processes by pattern
nohup <command> &     # Run command in background
jobs                  # List background jobs
fg %      # Resume background job

4️⃣ Networking Commands

ip addr show          # Show network interfaces
ping            # Test network connectivity
netstat -tulnp        # Show open ports & connections
ss -tulnp             # Alternative to `netstat`
dig           # Fetch DNS info
wget             # Download file from URL
curl -O          # Fetch data from URL
scp <source> @:  # Secure copy between servers

5️⃣ Disk & Storage Management

df -h                 # Show disk usage
du -sh <dir>          # Show directory size
lsblk                 # List block devices
fdisk -l              # Show partitions
mount  <dir>  # Mount a filesystem
umount        # Unmount a filesystem
fsck                  # Check & repair filesystem

6️⃣ Logs & Monitoring

tail -f /var/log/syslog  # Monitor system logs
journalctl -xe          # View system logs
dmesg                   # Kernel messages
uptime                  # Show system uptime
free -m                 # Check memory usage
vmstat                  # Show performance stats

7️⃣ Package Management

apt update            # Update package list
apt upgrade           # Upgrade installed packages
apt install      # Install a package
apt remove       # Remove a package

8️⃣ Archiving & Compression

tar -cvf archive.tar <dir>    # Create a tar archive
tar -xvf archive.tar          # Extract a tar archive
tar -czvf archive.tar.gz <dir>  # Create compressed tar archive
tar -xzvf archive.tar.gz      # Extract compressed tar archive
zip -r archive.zip <dir>      # Create a zip file
unzip archive.zip             # Extract a zip file

9️⃣ Text Processing

grep     # Search for text in a file
awk '{print $1}'   # Process text with awk
sed 's/old/new/g'  # Replace text in a file
cut -d' ' -f1      # Extract columns from text
sort               # Sort file contents
uniq               # Remove duplicate lines

🔟 Version Control with Git

git clone    # Clone a repository
git init               # Initialize a new repo
git add          # Stage changes
git commit -m "msg"    # Commit changes
git push origin   # Push to remote repo
git pull origin   # Pull latest changes
git status             # Show repo status
git log                # View commit history

Conclusion

Mastering these Linux commands will make DevOps tasks easier, from automation to troubleshooting. Keep practicing, and take your Linux skills to the next level! 🚀

Learn Let Learn !