DEV Community

Cover image for Linux Essential Commands for DevOps Enthusiasts
Shiva Shanmugam
Shiva Shanmugam

Posted on

2 1

Linux Essential Commands for DevOps Enthusiasts

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
Enter fullscreen mode Exit fullscreen mode

πŸ“„ 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

πŸ”Ÿ 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
Enter fullscreen mode Exit fullscreen mode

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)