Simple Linux Server Management Tasks

A Beginner's Guide for Simple Linux Server Management Tasks
December 17, 2024 by
Simple Linux Server Management Tasks
Hamed Mohammadi
| No comments yet

Managing a Linux server might sound intimidating at first, but it often involves straightforward tasks that anyone can learn with a bit of guidance. If you’re a beginner, understanding basic server commands like logging in, checking system health, or rebooting the machine is a solid starting point. In this post, we’ll walk through essential Linux server management tasks that every administrator or enthusiast should know.

1. Logging into Your Server Using SSH

SSH (Secure Shell) is the most common method for accessing a remote Linux server securely. It encrypts the connection between your computer and the server, keeping your data safe.

Steps to Log in:

  • Open your terminal (Linux/Mac) or use tools like PuTTY (Windows).
  • Use the following command to connect:
    ssh username@server_ip
    
    Replace username with your server’s user account and server_ip with the server’s IP address.
  • If you’re connecting for the first time, the system will prompt you to verify the server’s fingerprint. Type yes and press Enter.
  • Enter the password for the user account when prompted.

Using SSH with a Custom Port:

If your server uses a port other than the default (22), specify it with the -p flag:

ssh username@server_ip -p 2222

2. Checking Server Status and Uptime

After logging into your server, you might want to check its health or status.

  • Check Uptime:
    To see how long the server has been running and its load averages:

    uptime
    
  • System Information:
    Use the uname command to get basic system details:

    uname -a
    
  • Check Disk Space:
    To see available and used disk space:

    df -h
    
  • Check Memory Usage:
    View memory usage with:

    free -h
    

3. Shutting Down the Server

At times, you may need to shut down your Linux server gracefully, especially before maintenance or upgrades.

  • To shut down immediately:

    sudo shutdown now
    
  • To schedule a shutdown after a delay (e.g., 10 minutes):

    sudo shutdown +10
    

    Users on the system will see a message about the pending shutdown.

  • To cancel a scheduled shutdown:

    sudo shutdown -c
    

4. Rebooting the Server

Rebooting is necessary after applying updates, changing configurations, or troubleshooting issues.

  • To reboot the server immediately:
    sudo reboot
    

Alternatively, use the shutdown command with the -r flag:

sudo shutdown -r now

This will restart the server and bring it back online.

5. Managing Users on the Server

If you’re managing multiple users on a Linux server, it’s helpful to know basic user management tasks.

  • Create a New User:

    sudo adduser username
    
  • Set/Change User Password:

    sudo passwd username
    
  • List All Users:
    You can view all users by checking the /etc/passwd file:

    cat /etc/passwd
    
  • Switch Between Users:
    Use the su command to switch to another user:

    su - username
    

6. Viewing and Managing Processes

Monitoring and managing processes helps ensure your server is running smoothly.

  • List Running Processes:
    Use the top command to see a dynamic list of running processes:

    top
    
  • Find a Specific Process:
    Use ps and grep to search for a specific process:

    ps aux | grep process_name
    
  • Kill a Process:
    If a process becomes unresponsive, terminate it using its process ID (PID):

    sudo kill PID
    
  • Kill a Process by Name:
    Use pkill to kill processes by name:

    sudo pkill process_name
    

7. Checking and Reading Server Logs

Logs help diagnose issues and monitor activity on your server.

  • System Logs:
    View system logs located in /var/log/syslog or /var/log/messages using:

    sudo tail -n 50 /var/log/syslog
    
  • Authentication Logs:
    To monitor SSH login attempts:

    sudo cat /var/log/auth.log
    
  • Follow Live Logs:
    To monitor logs in real-time:

    sudo tail -f /var/log/syslog
    

8. Updating the Server

Keeping your server up-to-date ensures security patches and performance improvements are applied.

  • Update Package Lists:
    For Debian/Ubuntu-based systems:

    sudo apt update
    
  • Upgrade Installed Packages:
    To upgrade all installed software:

    sudo apt upgrade
    
  • Clean Up Unused Packages:
    Remove unnecessary packages to free up space:

    sudo apt autoremove
    

For Red Hat-based systems, use yum or dnf:

sudo yum update

Conclusion

Mastering simple Linux server management tasks like logging in via SSH, shutting down, rebooting, and monitoring system health is essential for anyone managing servers. These fundamental commands will help you interact with your server confidently and efficiently.

As you become familiar with these tasks, you can start exploring more advanced areas like automation, scripting, and security hardening. Linux server management is a valuable skill—start small, practice regularly, and soon you’ll manage your server like a pro.

Ready to take the next step? Explore tools like Fail2Ban, firewalls, and cron jobs to automate tasks and secure your server further!

Simple Linux Server Management Tasks
Hamed Mohammadi December 17, 2024
Share this post
Tags
Archive

Please visit our blog at:

https://zehabsd.com/blog

A platform for Flash Stories:

https://readflashy.com

A platform for Persian Literature Lovers:

https://sarayesokhan.com

Sign in to leave a comment