Linux: Essential Commands Every DevOps Engineer Should Know

September 05, 2024



In the world of DevOps, Linux is the backbone of many environments. As a DevOps engineer, your ability to navigate, manage, and troubleshoot Linux systems efficiently is crucial. Here are some essential Linux commands that every DevOps professional should have at their fingertips:

1. File and Directory Management

- ls: List files and directories.
- cd: Change the current directory.
- mkdir: Create new directories.
- rm: Remove files or directories (`rm -r` for directories).
- cp: Copy files and directories.
- mv: Move or rename files and directories.

2. File Content Manipulation

- cat: Display the contents of a file.
- less/more: View file content page by page.
- grep: Search for specific patterns within files.
- awk / sed: Powerful text processing tools.

3. System Monitoring
- top / htop: Display real-time system processes and resource usage.
- df: Check disk space usage.
- du: Check directory space usage.
-free: Display memory usage.
- uptime: Show how long the system has been running.

4. User and Permissions Management
- chmod: Change file permissions.
- chown: Change file owner and group.
- sudo: Execute commands with superuser privileges.
- useradd / usermod / userdel: Manage user accounts.

5. Networking
- ifconfig / ip addr: Display network interfaces and IP addresses.
- ping: Test network connectivity.
- netstat / ss: Display network connections, routing tables, interface statistics, etc.
- scp/ rsync: Securely copy files between servers.

6. Process Management
- ps: Display running processes.
- kill: Terminate a process by its ID.
- nohup: Run a command that keeps running even after logout.
- bg/fg: Background and foreground process management.

7. Package Management
- apt-get / yum/ dnf: Install, update, and manage packages.
- dpkg/ rpm: Low-level package management.

8. Disk and Filesystem Management

- fdisk/ parted: Manage disk partitions.
- mount/ umount: Mount and unmount filesystems.
- fsck: Filesystem check and repair.

9. Log Management
- tail / less: View the end of log files.

- journalctl: Query and display logs from the systemd journal.
- dmesg: Print kernel ring buffer messages.

10. Scripting
- bash: Execute shell scripts.
- cron: Schedule regular tasks.





Foundational Knowledge for DevOps Professionals

1. How DNS Works

- Answer: DNS (Domain Name System) translates human-readable domain names (like google.com) into IP addresses that computers use to identify each other on the network. It involves components like DNS servers, resolvers, and records.

2. Common Ports

- Answer: Ports are endpoints for communication on an IP network. Common ports include HTTP (80), HTTPS (443), FTP (21), SSH (22), and SMTP (25).

3. How Networking/Routing Works

- Answer: Networking involves connecting computers to share resources, using protocols like TCP/IP. Routing is the process of selecting paths in a network along which to send network traffic, managed by routers.

4. How to Check Running Processes

- Answer: On a Linux machine, you can use commands like `ps`, `top`, or `htop` to list and monitor running processes.

5. How to Diagnose a Slow Linux Machine

- Answer: Diagnose performance issues by checking CPU usage (`top`), memory usage (`free`), disk I/O (`iostat`), and network activity (`netstat`).

6. How a Web Server Works Under the Hood

- Answer:A web server handles HTTP requests from clients (browsers), processes them (often involving backend scripts), and serves the requested content. Popular web servers include Apache, Nginx, and IIS.

7. Different Record Types and Their Purpose

- Answer: DNS records include:
- A:Maps a domain to an IPv4 address.
- AAAA:Maps a domain to an IPv6 address.
- CNAME: Canonical name record, aliasing one domain to another.
- MX:Mail exchange record, directs email to a mail server.
- TXT:Text record, often used for verification purposes.

8. Difference Between a Stateless and Stateful Firewall

- Answer: A stateless firewall filters packets based on predefined rules without considering the state of the connection, while a stateful firewall tracks the state of active connections and makes decisions based on the context of traffic.

9. What Happens When You Send a Request to google.com

- Answer:The browser:
1. Resolves the domain to an IP address using DNS.
2. Establishes a TCP connection to the server.
3. Sends an HTTP request to the server.
4. Receives and renders the HTTP response.

10. How to Check Disk Space/Free Memory on a Linux Machine

- Answer:Use `df` to check disk space and `free` to check memory usage.

No comments:

Powered by Blogger.