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 <directory> # Change directory
mkdir <directory> # Create a new directory
rmdir <directory> # Remove an empty directory
rm -rf <directory> # Delete a directory and its contents
π File Operations
touch <file> # Create an empty file
cat <file> # View file content
less <file> # View file content page by page
head -n <num> <file> # Show first βnβ lines
tail -n <num> <file> # Show last βnβ lines
mv <source> <dest> # Move/rename a file
cp <source> <dest> # Copy a file
rm <file> # Delete a file
2οΈβ£ User & Permission Management
whoami # Show current user
who # List logged-in users
id # Display user & group ID
chmod 755 <file> # Change file permissions
chown user:group <file> # Change file ownership
passwd # Change password
adduser <username> # Add a new user
deluser <username> # 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 <PID> # Terminate a process
killall <name> # Kill all processes by name
pkill <pattern> # Kill processes by pattern
nohup <command> & # Run command in background
jobs # List background jobs
fg %<job_number> # Resume background job
4οΈβ£ Networking Commands
ip addr show # Show network interfaces
ping <host> # Test network connectivity
netstat -tulnp # Show open ports & connections
ss -tulnp # Alternative to `netstat`
dig <domain> # Fetch DNS info
wget <url> # Download file from URL
curl -O <url> # Fetch data from URL
scp <source> <user>@<host>:<dest> # 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 <device> <dir> # Mount a filesystem
umount <device> # 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 <pkg> # Install a package
apt remove <pkg> # 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 <pattern> <file> # Search for text in a file
awk '{print $1}' <file> # Process text with awk
sed 's/old/new/g' <file> # Replace text in a file
cut -d' ' -f1 <file> # Extract columns from text
sort <file> # Sort file contents
uniq <file> # Remove duplicate lines
π Version Control with Git
git clone <repo_url> # Clone a repository
git init # Initialize a new repo
git add <file> # Stage changes
git commit -m "msg" # Commit changes
git push origin <branch> # Push to remote repo
git pull origin <branch> # 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 !
Top comments (0)