From Chaos to Control: A Practical Linux Cheat Sheet for Managing Servers 

By Rimpi Mathur, Technical Architect

Whether you’re a system administrator, developer, or someone who occasionally receives the dreaded “Server Disk Full” alert at 2 AM, knowing a few essential Linux commands can save hours of troubleshooting. 

Linux powers a significant portion of the world’s servers, and while graphical tools exist, the command line remains the fastest and most powerful way to diagnose and resolve issues. This article walks through practical Linux commands that every IT professional should know, with a focus on identifying disk space problems, managing files, and performing common administrative tasks. 

1. The First Step: Identify Disk Space Usage 

One of the most common server issues is running out of disk space. The first question to answer is: 

Which directory is consuming the storage? 

Start by switching to the root user if you have administrative privileges: 

sudo su

Check the overall disk usage: 

df -h

This command displays the total, used, and available space on all mounted file systems in a human-readable format. 

To see which directories are taking up space: 

du -h --max-depth=1

This provides a summary of disk usage for each directory without listing every nested file. 

To sort directories by size: 

du -h --max-depth=1 | sort -h 

Now you can quickly identify the largest directory. 

If /var appears to be the culprit, drill down further: 

du -h --max-depth=1 /var

Move into the directory: 

cd /var 
pwd 

pwd displays your current working directory, ensuring you’re in the correct location before making changes. 

2. Listing and Cleaning Files 

View the contents of a directory: 

Is

To list files with detailed information sorted by modification time: 

ls -lt 

This is especially useful for identifying old log files or large files that can be archived or deleted. 

Search files containing a specific year or string: 

grep -r "2019" .

This recursively searches the current directory and its subdirectories. 

grep -r "20260[1\|2\|3]" 

This recursively searches the current directory and its subdirectories for everything that starts with 2026 and ends with 1, 2 or 3.  

For ex: 

202601 

202602 

202603 

Delete a specific file: 

yes | rm filename 

Delete all log files in the current directory: 

yes | rm *.log 

Delete an entire directory and its contents: 

yes | rm -R directory_name 

Important: Always double-check the directory before running delete commands. A misplaced rm -R can permanently remove critical files. 

3. Copying, Moving, and Organizing Files 

Create a new directory: 

mkdir myfolder 

Copy files: 

cp /path/to/source/file.txt /path/to/destination/ 

Move files: 

mv /path/to/source/file.txt /path/to/destination/ 

The mv command can also rename files: 

mv oldname.txt newname.txt 

If you need to preserve a few files before deleting an entire directory, simply copy or move them elsewhere and then remove the directory. 

4. Finding Files and Learning Commands 

Locate a file or directory: 

find / -name filename 

Need help with a command? 

man ls 

The man command opens the manual page and provides comprehensive documentation. 

To view a file one page at a time: 

more filename 

5. Working with Archives and Downloads 

Extract or compress files: 

tar

Download files from the internet: 

wget https://example.com/file.zip 

Or use: 

curl https://example.com 

curl is particularly useful for interacting with APIs and transferring files using URLs. 

6. Network and Connectivity Commands 

View IP address information: 

ip addr 

Display network connections: 

netstat 

Connect securely to another server: 

ssh user@hostname 

SSH is one of the most commonly used Linux utilities for remote server administration. 

7. Process Management 

Display running processes: 

ps

Monitor processes interactively: 

top

Terminate a process: 

kill PID

Forcefully terminate a process: 

kill -9 PID 

Gracefully request a process to stop: 

kill -15 PID 

Understanding the difference between graceful and forced termination can help prevent data corruption and application issues. 

8. Environment Variables and Useful Utilities 

Display the current user: 

whoami 

Find the location of an executable: 

which java 

Display environment variables: 

env 

Print a specific environment variable: 

printenv $JAVA_HOME 

Export a variable: 

export JAVA_HOME=/usr/lib/jvm/java 

Reload environment variables from a file: 

source ~/.bashrc 

Other handy commands: 

cat filename     # Display file contents 
echo "Hello"     # Print text 
clear            # Clear terminal 

9. System Shutdown and Restart 

Shut down the machine: 

poweroff 

Restart the machine: 

restart 

Use these commands carefully, especially on production servers where active users or applications may be affected. 

Need help optimizing your Linux infrastructure? Whether you’re troubleshooting production servers, improving system performance, or modernizing your infrastructure, TekStream’s experts can help you build a more resilient and efficient environment.

Connect with our team to learn how we can help.

Conclusion 

Linux may appear intimidating at first, but mastering a handful of commands can dramatically improve your ability to manage servers efficiently. From diagnosing disk space issues and cleaning up files to monitoring processes and configuring environments, these commands form the foundation of day-to-day Linux administration. 

About the Author

As a certified AWS SysOps Administrator, Rimpi Mathur has over twenty-four years of experience with AWS and Oracle portal and web application support and development which includes integration with multiple backend systems. Her experience includes requirements gathering, technical design, development, installing/configuring environments and deploying applications. Rimpi has a working knowledge of AWS, Ansible, AJAX, CSS, RDS, Hibernate, HTML, Java, REST, JavaScript, Spring, SQL, PostgreSQL, Aurora Global Database, Terraform, CloudFormation, SonarQube, Docker, WebLogic Portal, and Web Services. Previous clients worked with include Clearnova, Westfield Insurance and Satyam Computers.