Streamline Deployments: Your Essential Linux Command Toolkit for Ops
Master crucial Linux commands to monitor, manage, and troubleshoot your applications in server environments. A hands-on guide for DevOps pros.
Deploying and managing applications requires more than just writing code. When your application goes live, you need to be ready to monitor its health, manage its processes, and troubleshoot issues swiftly. For technical learners and aspiring DevOps professionals, a solid grasp of Linux command-line tools is non-negotiable.
Linux is the backbone of most server environments, and understanding its core commands empowers you to take control. With 2 courses specifically on Linux and 2 on Deployment available for learners on Tully, you're in good company if you're looking to level up these skills. Let's dive into the essential commands that will streamline your deployments and make you a more effective operator.
Monitoring System Health
Keeping an eye on your server's vitals is key to proactive management. These commands give you immediate insights.
CPU, Memory, and Processes: top and htop
top provides a real-time, dynamic view of a running system. It shows process activity, CPU usage, memory consumption, and more. htop is an enhanced, interactive version, often preferred for its user-friendly interface and features like easy process killing and customizable displays.
```bash top
Or, if installed, for a more interactive view:
htop ```
Disk Usage: df and du
Is your server running out of space? df (disk free) reports filesystem disk space usage, showing you available and used space across mounted filesystems. To dig into specific directories, du (disk usage) estimates file space usage.
``bash df -h # Human-readable format du -sh /var/log # Total size of the /var/log directory ``
Memory Consumption: free
While top gives you memory per process, free provides an aggregate summary of total, used, and free physical and swap memory. This helps you quickly assess overall memory pressure.
``bash free -h # Human-readable format ``
Managing Application Processes
Applications are processes, and you need to know how to start, stop, and inspect them.
Listing Processes: ps
ps (process status) shows you the currently running processes. Combine it with aux for a detailed list including processes from all users and grep to filter for a specific application.
``bash ps aux | grep my_app # Find processes related to 'my_app' ``
Terminating Processes: kill
If an application process is misbehaving or stuck, kill is your tool to stop it. You'll need the Process ID (PID), usually found with ps.
``bash kill 12345 # Terminate process with PID 12345 kill -9 12345 # Forcefully terminate (use with caution) ``
Managing Services: systemctl
Most modern Linux distributions use systemd to manage system services. systemctl allows you to start, stop, restart, enable, and check the status of services like web servers, databases, or your custom applications.
``bash systemctl status nginx # Check status of Nginx systemctl restart my_app_service # Restart your application service ``
Networking Essentials
Your deployed applications need to communicate. These commands help diagnose network-related issues.
Open Ports and Connections: ss
ss (socket statistics) is a powerful tool to inspect network sockets. It's faster and more feature-rich than the older netstat for showing active connections, listening ports, and routing tables.
``bash ss -tuln # Show all TCP/UDP listening ports numerically ``
Connectivity Check: ping
Simple but effective, ping tests network reachability to another host. It sends ICMP echo request packets and waits for replies, indicating if a connection exists and its latency.
``bash ping google.com # Test connectivity to Google ``
Testing HTTP/S Endpoints: curl
curl is indispensable for making HTTP requests. Use it to test your application's API endpoints, retrieve web pages, or debug network interactions from the command line.
``bash curl -v https://your-app.com/api/status # Verbose output for debugging ``
File and Log Management
Logs are the breadcrumbs of your application's behavior. Knowing how to navigate and read them is paramount.
Listing Files and Directories: ls
The fundamental command to list directory contents. Use flags to get more detail.
``bash ls -l # Long listing format ls -a # Show all files, including hidden ones ``
Viewing and Following Logs: cat, less, tail
cat: Displays the entire content of a file.less: Allows you to view file content page by page, useful for large files.tail: Displays the last part of a file. Crucially, tail -f (follow) allows you to monitor a log file in real-time as new lines are added.
``bash cat /var/log/syslog less /var/log/auth.log tail -f /var/log/nginx/access.log # Monitor Nginx access logs live ``
Filtering Log Output: grep
When logs are overwhelming, grep (global regular expression print) is your best friend. It searches for patterns within text, letting you filter for errors, specific user actions, or other relevant events.
``bash tail -f /var/log/my_app/app.log | grep "ERROR" # Find errors in real-time ``
Locating Files: find
Need to locate a configuration file or a specific log file you can't remember the path to? find searches for files in a directory hierarchy based on various criteria.
``bash find /etc -name "nginx.conf" # Find nginx.conf in /etc directory ``
Elevate Your Ops Skills
These commands are just the tip of the iceberg, but they form a powerful foundation for anyone involved in deployments and operations. Mastering them means you can quickly diagnose issues, ensure your applications are running smoothly, and respond effectively in critical situations. For more in-depth learning, consider diving into Linux Command Line Mastery: The Terminal, Files, and Shell Scripting to strengthen your foundational skills. You might also explore how these commands fit into modern deployment pipelines with courses like Docker and Containers: From Zero to Deploying Your First App or managing infrastructure with Cloud Computing with AWS: Deploy Your First App.
Ready to put these commands into practice? Tully offers 8 courses in the technical domain, and you can explore more at the Linux topic hub. Start your next learn-by-doing course on Tully today and build skills that truly stick.
Start learning on Tully Courses — learn anything by doing it.