Essential Linux Commands for DevOps Professionals.

Mudit Mathur
5 min readJun 27, 2023

--

Linux Commands

Introduction:
As a DevOps professional, having a solid understanding of Linux commands is crucial for effectively managing systems, automating tasks, and deploying applications. In this blog post, we will explore 20 essential Linux commands that every DevOps professional should know. These commands will help you streamline your workflow, improve productivity, and ensure efficient operations in your DevOps environment.

1.ssh: Securely Connect to Remote Servers
The ssh command allows you to establish a secure connection to remote servers or machines. It is a fundamental tool for managing remote systems and performing various administrative tasks. Simply use the following syntax:

ssh user@host

2. scp: Secure File Transfer
When you need to transfer files securely between local and remote systems, scp comes to the rescue. It ensures encrypted file transfer using SSH protocol. Use the following command structure:

scp file.txt user@host:/path/to/destination

3. rsync: Efficient File Synchronization and Backup
Rsync is a powerful command for synchronizing and backing up files and directories. It efficiently transfers only the differences between source and destination, minimizing data transfer. The basic usage is:

rsync -avz source/ destination/

4. wget: Download Files from the Web
When you need to download files from the web or through HTTP/FTP protocols, wget is your go-to command. It is a versatile tool that supports recursive downloading and resuming interrupted downloads. Simply use the following command:

wget https://lnkd.in/g-fDHMwW

5. curl: Interact with APIs and Make HTTP Requests
Curl is a command-line tool for making HTTP requests and interacting with APIs. It supports a wide range of protocols and provides extensive options for customizing requests. Use the following command structure to make a basic request:

curl https://lnkd.in/g8qDdG74

6. top: Real-Time System Resource Monitoring
The top command displays real-time information about system resource usage, including CPU, memory, and processes. It provides valuable insights into system performance and helps identify resource-intensive processes. Simply run the following command:

top

7. htop: Enhanced System Monitoring with a User-Friendly Interface
Htop is an improved alternative to top, offering an enhanced user interface and an interactive process viewer. It provides a more intuitive and user-friendly way to monitor system resources. Just run the following command:

htop

8. df: Check Disk Space Usage
To keep track of disk space usage on file systems, the df command is indispensable. It provides a summary of disk space usage, including information about available, used, and mounted file systems. Use the following command to display disk space usage in a human-readable format:

df -h

9. du: Analyze Disk Usage of Files and Directories
When you need to determine the disk usage of specific files or directories, the du command is your ally. It helps you identify space-consuming files and folders. Use the following command to get the disk usage of a directory:

du -sh /path/to/directory

10. grep: Search for Patterns in Files or Output
Grep is a versatile command for searching for patterns in files or output. It enables you to find specific lines or extract relevant information from large datasets. Use the following command structure to search for a pattern in a file:

grep "pattern" file.txt

11. find: Search for Files and Directories
The find command is a powerful tool for searching files and directories based on various criteria. It offers extensive options for fine-grained searches, such as searching by name, size, or modification time. Use the following command to search for a file by name:

find /path/to/search -name "filename"

12. chmod: Change File Permissions
To manage file permissions, the chmod command comes in handy. It allows you to change the permissions of files and directories, granting or revoking read, write, and execute rights. Use the following command to set file permissions:

chmod 644 file.txt

13. chown: Modify File Ownership
When you need to modify file ownership, the chown command is essential. It enables you to change the owner and group of a file or directory. Use the following command to modify file ownership:

chown user:group file.txt

14. tar: Archive and Extract Files
The tar command is indispensable for creating compressed archives or extracting files from archives. It supports various compression formats and allows you to bundle multiple files and directories together. Use the following commands to create an archive and extract files from it:

tar -cvzf archive.tar.gz files/
tar -xvzf archive.tar.gz

15. systemctl: Manage System Services
Systemctl is a powerful command for managing system services and controlling their behavior. It allows you to start, stop, restart, enable, or disable services in your Linux environment. Use the following commands to manage services:

systemctl start service
systemctl stop service
systemctl restart service

16. journalctl: View System Logs and Journal Entries
The journalctl command provides a convenient way to view system logs and journal entries. It allows you to access detailed information about system events, services, and processes. Use the following command to view logs for a specific service:

journalctl -u service

17. iptables: Configure Firewall Rules and Network Address Translation
When it comes to configuring firewall rules and network address translation, iptables is a powerful tool. It helps you control incoming and outgoing network traffic, ensuring network security. Use the following command to add a rule that allows incoming TCP traffic on port 80:

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

18. crontab: Schedule Recurring Tasks or Jobs
The crontab command allows you to schedule recurring tasks or jobs in your Linux system. It offers a flexible and powerful way to automate routine operations. Use the following command to edit the crontab file and define scheduled tasks:

crontab -e

19. awk: Process Text-Based Data and Perform Pattern Scanning
Awk is a versatile command-line tool for processing text-based data and performing pattern scanning. It allows you to extract specific fields, manipulate data, and generate custom reports. Use the following command to print the first field of a file:

awk '{print $1}' file.txt

20. sed: Stream Editor for Text Manipulation
The sed command is a powerful stream editor for performing text manipulation operations. It enables you to substitute, delete, or insert text in files or streams. Use the following command to substitute a pattern with another in a file:

sed 's/foo/bar/' file.txt

Conclusion:
Mastering these essential Linux commands will significantly enhance your capabilities as a DevOps professional. They cover a broad range of tasks, including remote access, file management, system monitoring, and automation. Remember to consult the documentation and man pages for each command to explore their full potential and further expand your Linux proficiency. With these commands in your toolkit, you’ll be well-equipped to handle various DevOps challenges and streamline your workflows.

About The Author
Mudit Mathur
DevOps Engineer — I
LinkedIn: https://www.linkedin.com/in/mudit--mathur/

--

--