Day 3: Essential Linux Commands with Examples ๐Ÿ’ป๐Ÿ“œ

Saurabh NamdeoSaurabh Namdeo
3 min read

Welcome to Day 3 of your DevOps journey! Today, weโ€™ll explore some essential Linux commands that every DevOps professional should know. These commands help you monitor system performance, manage files and users, and perform various administrative tasks. Let's dive in with practical examples to make everything clear!


1. uptime โฑ๏ธ

The uptime command tells you how long the system has been running since the last reboot, along with the current time, number of users logged in, and the system load averages.

Example:

Explanation:

  • 19:42:34 Current time

  • System has been running for 0 days and 1 hours 07 minutes

  • 4 users: Number of users logged in

  • load average: 0.00, 0.00, 0.00: System load averages for the last 1, 5, and 15 minutes

2. top ๐Ÿ“Š

The top command provides a real-time view of system processes, showing information like CPU and memory usage, running processes, and more.

Example:

Explanation:

  • This command opens an interactive display of system processes, allowing you to monitor which processes are consuming the most resources.

3. free ๐Ÿง 

The free command displays the amount of free and used memory in the system, including physical memory (RAM) and swap space.

Example:

Explanation:

  • -h: Stands for "human-readable", showing memory in MB, GB, etc.

4. chmod ๐Ÿ”’

The chmod command changes the permissions of files or directories. Permissions define who can read, write, or execute a file.

Example:

Explanation:

  • read ; 4 , write : 2, execute : 1.

  • 755: Sets permissions to rwxr-xr-x, meaning the owner (user1) can read, write, and execute the file, while the group and others can only read and execute.

5. chown ๐Ÿท๏ธ

The chown command changes the owner and/or group of a file or directory.

Example:

$ chown user1:group1 file1

Explanation:

  • user1:group1: Sets the owner of file1 to user1 and the group to group1.

6. ssh ๐Ÿ”

The ssh (Secure Shell) command allows you to connect to a remote machine securely over the network.

Example:

$ ssh user2@remote-server.com

Explanation:

  • This command connects saurabh to the remote server as user2.

7. scp ๐Ÿ“ค

The scp (Secure Copy) command is used to copy files between hosts on a network securely.

Example:

$ scp file1 user2@remote-server.com:/path/to/destination

Explanation:

  • This command copies file1 from the local system to the remote server at the specified path.

8. systemctl ๐Ÿ”„

The systemctl command is used to control the systemd system and service manager. It can start, stop, restart, or check the status of services.

Example:

$ systemctl status sshd

Explanation:

  • This command checks the status of the SSH service.

9. grep ๐Ÿ”

The grep command searches for specific patterns in files or output.

Example:

$ grep "search-term" file1

Explanation:

  • This command searches for the term "search-term" in file1.

10. find ๐Ÿ”Ž

The find command searches for files and directories in a directory hierarchy.

Example:

$ find /path/to/search -name "file1"

Explanation:

  • This command searches for file1 starting from /path/to/search.

11. awk ๐Ÿงฎ

The awk command is a powerful text-processing tool used for pattern scanning and processing.

Example:

$ awk '{print $1}' file1

Explanation:

  • This command prints the first column of each line in file1.

12. sed โœ‚๏ธ

The sed command is a stream editor used to perform basic text transformations on an input stream (a file or input from a pipeline).

Example:

$ sed 's/old-text/new-text/' file1

Explanation:

  • This command replaces the first occurrence of old-text with new-text in file1.

These commands are fundamental tools in a Linux environment. They empower you to monitor, manage, and manipulate your system efficiently. Practice these commands using the examples provided to get comfortable with them as you continue your DevOps journey!


0
Subscribe to my newsletter

Read articles from Saurabh Namdeo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Saurabh Namdeo
Saurabh Namdeo