DevOps Engineer’s Comprehensive Linux Commands Cheat Sheet

Praveen Dandu
3 min readJul 19, 2023

--

Introduction:
As a DevOps engineer, mastering Linux commands is crucial for seamless system management and optimization. In this comprehensive cheat sheet, we’ll cover essential Linux commands for file operations, process management, file permissions, SSH, searching, system information, network configuration, and compression. Whether you’re a seasoned pro or a Linux novice, this guide will serve as your go-to reference for streamlining your daily tasks and enhancing your productivity.

  1. File Commands:
  • `ls`: List files and directories in the current directory.
    Example:
ls
ls /path/to/directory
  • `cd`: Change directory.
    Example:
cd /path/to/directory
  • `pwd`: Print the current working directory.
    Example:
pwd
  • `touch`: Create an empty file.
    Example:
touch newfile.txt
  • `mkdir`: Create a new directory.
    Example:
mkdir new_directory
  • `cp`: Copy files or directories.
    Example:
cp file.txt /path/to/destination
cp -r directory /path/to/destination
  • `mv`: Move or rename files or directories.
    Example:
mv file.txt /path/to/destination
mv oldname.txt newname.txt
  • `rm`: Remove files or directories.
    Example:
rm -r directory
rm file.txt
  • `find`: Search for files and directories.
    Example:
find /path/to/search -name "*.txt"

2. Process Management:

  • `ps`: Show running processes.
    Example:
ps aux
  • `top`: Monitor real-time system processes.
    Example:
top
  • `kill`: Terminate processes by PID.
    Example:
kill PID
  • `killall`: Terminate processes by name.
    Example:
killall process_name
  • `bg`: Send processes to the background.
    Example:
bg %job_id
  • `fg`: Bring processes to the foreground.
    Example:
fg %job_id
  • `nice`: Set process priority.
    Example:
nice -n 10 command
  • `htop`: Interactive process viewer.
    Example:
htop

3. File Permissions:

  • `chmod`: Change file permissions.
    Example:
chmod 644 file.txt
  • `chown`: Change file ownership.
    Example:
chown user:group file.txt
  • `chgrp`: Change group ownership.
    Example:
chgrp new_group file.txt
  • `umask`: Set default file permissions.
    Example:
umask 022
  • `lsattr`: List file attributes.
    Example:
lsattr file.txt
  • `chattr`: Change file attributes.
    Example:
chattr +i file.txt

4. SSH (Secure Shell):

  • `ssh`: Connect to a remote server securely.
    Example:
ssh user@remote_host
  • `scp`: Copy files between local and remote systems.
    Example:
scp file.txt user@remote_host:/path/to/destination
  • `sftp`: Securely transfer files between systems.
    Example:
sftp user@remote_host
  • `ssh-keygen`: Generate SSH key pairs.
    Example:
ssh-keygen -t rsa
  • `ssh-add`: Add SSH keys to the SSH agent.
    Example:
ssh-add /path/to/private_key

5. Searching:

  • `grep`: Search for text in files.
    Example:
grep "search_text" file.txt
  • `find`: Search for files and directories based on various criteria.
    Example:
find /path/to/search -name "*.txt"
  • `locate`: Find files and directories using a pre-built database.
    Example:
locate file.txt
  • `ack`: A code-focused grep alternative.
    Example:
ack "search_text" file.txt
  • `ag`: A faster code search tool.
    Example:
ag "search_text" file.txt

6. System Information:

  • `uname`: Display system information.
    Example:
uname -a
  • `df`: Show disk space usage.
    Example:
df -h
  • `du`: Estimate file and directory space usage.
    Example:
du -h /path/to/directory
  • `free`: Display memory usage.
    Example:
free -h
  • `top`: Monitor real-time system processes.
    Example:
top
  • `lshw`: List hardware information.
    Example:
lshw
  • `lsblk`: List block devices.
    Example:
lsblk

7. Network Configuration:

  • `ifconfig`: Show network interface configuration (deprecated, use `ip` command instead).
    Example:
ifconfig
  • `ip`: Display and manipulate network interfaces.
    Example:
ip addr show
  • `ping`: Send ICMP echo requests to test network connectivity.
    Example:
ping google.com
  • `traceroute`: Trace the route to a host.
    Example:
traceroute google.com
  • `netstat`: Show network statistics.
    Example:
netstat -tuln
  • `ss`: Utility to investigate sockets.
    Example:
ss -tuln

8. Compression:

  • `tar`: Archive files.
    Example:
tar -cvzf archive.tar.gz file.txt
  • `gzip`: Compress files using gzip.
    Example:
gzip file.txt
  • `gunzip`: Decompress gzip files.
    Example:
gunzip file.txt.gz
  • `zip`: Compress files into a zip archive.
    Example:
zip archive.zip file.txt
  • `unzip`: Extract files from a zip archive.
    Example:
unzip archive.zip
  • `bzip2`: Compress files using bzip2.
    Example:
bzip2 file.txt
  • `bunzip2`: Decompress bzip2 files.
    Example:
bunzip2 file.txt.bz2

Conclusion:
Mastering Linux commands is essential for DevOps engineers to efficiently manage and optimize systems. This cheat sheet covers various file operations, process management, file permissions, SSH, searching, system information, network configuration, and compression commands. By using this guide as your reference, you’ll enhance your productivity and become a more effective DevOps professional. Happy command-line hacking!

--

--

Praveen Dandu
Praveen Dandu

Written by Praveen Dandu

🚀 DevOps Engineer | Automating Infrastructure, Streamlining Deployments | Continuous Integration & Delivery Specialist https://www.linkedin.com/in/pravin24/

No responses yet