TechPulse by Khalequzzaman
Posted on
System Administration

Essential Sysadmin Commands and Instructions: A Beginner’s Guide

Author

System administration is a critical skill for managing servers, troubleshooting issues, and ensuring the smooth operation of IT infrastructure. Whether you’re a beginner or looking to refresh your knowledge, mastering basic sysadmin commands is the first step toward becoming proficient. In this post, we’ll cover essential Linux commands and instructions that every sysadmin should know.


1. Navigating the File System

Understanding how to navigate the file system is fundamental. Here are some basic commands:

  • pwd: Print the current working directory.

    pwd  
    
  • ls: List files and directories in the current directory.

    ls          # List files  
    ls -l       # Detailed list  
    ls -a       # Include hidden files  
    
  • cd: Change directory.

    cd /path/to/directory   # Move to a specific directory  
    cd ..                  # Move up one level  
    cd ~                   # Go to the home directory  
    
  • mkdir: Create a new directory.

    mkdir new_directory  
    
  • rmdir: Remove an empty directory.

    rmdir empty_directory  
    

2. Managing Files

Sysadmins frequently work with files. Here are some essential commands:

  • touch: Create an empty file.

    touch newfile.txt  
    
  • cp: Copy files or directories.

    cp file1.txt /path/to/destination  
    cp -r directory1 /path/to/destination  # Copy a directory recursively  
    
  • mv: Move or rename files or directories.

    mv file1.txt /path/to/destination  
    mv oldname.txt newname.txt  
    
  • rm: Remove files or directories.

    rm file1.txt  
    rm -r directory1  # Remove a directory and its contents  
    
  • cat: Display the contents of a file.

    cat file1.txt  
    
  • nano or vim: Edit files using a text editor.

    nano file1.txt  
    vim file1.txt  
    

3. Viewing and Monitoring System Resources

Monitoring system performance is a key responsibility of a sysadmin.

  • top: Display real-time system processes and resource usage.

    top  
    
  • htop: An interactive version of top (may need to be installed).

    htop  
    
  • df: Check disk space usage.

    df -h  # Human-readable format  
    
  • du: Check the size of files and directories.

    du -sh /path/to/directory  # Summarize size in human-readable format  
    
  • free: Check memory usage.

    free -h  # Human-readable format  
    

4. Managing Users and Permissions

Sysadmins often need to manage users and file permissions.

  • useradd: Add a new user.

    sudo useradd username  
    
  • passwd: Set or change a user’s password.

    sudo passwd username  
    
  • usermod: Modify user properties.

    sudo usermod -aG groupname username  # Add user to a group  
    
  • chmod: Change file permissions.

    chmod 755 file1.txt  # Set read, write, execute permissions  
    
  • chown: Change file ownership.

    sudo chown username:groupname file1.txt  
    

5. Networking Commands

Networking is a core part of sysadmin tasks.

  • ping: Check connectivity to a host.

    ping google.com  
    
  • ifconfig or ip: Display network interface information.

    ifconfig  
    ip addr show  
    
  • netstat: Display network connections and statistics.

    netstat -tuln  # Show listening ports  
    
  • ssh: Connect to a remote server securely.

    ssh username@remote_host  
    
  • scp: Securely copy files between systems.

    scp file1.txt username@remote_host:/path/to/destination  
    

6. Package Management

Installing and managing software is a common sysadmin task.

  • apt (Debian/Ubuntu): Package management for Debian-based systems.

    sudo apt update          # Update package list  
    sudo apt install package # Install a package  
    sudo apt remove package  # Remove a package  
    
  • yum or dnf (CentOS/RHEL): Package management for Red Hat-based systems.

    sudo yum install package  # Install a package  
    sudo yum remove package   # Remove a package  
    

7. System Logs and Troubleshooting

Logs are invaluable for troubleshooting issues.

  • tail: View the end of a file (useful for logs).

    tail -n 20 /var/log/syslog  # Display the last 20 lines  
    tail -f /var/log/syslog     # Follow log updates in real-time  
    
  • journalctl: View system logs (for systems using systemd).

    journalctl -xe  # Display detailed logs  
    
  • dmesg: View kernel messages.

    dmesg | less  
    

8. Backup and Restore

Regular backups are essential for data protection.

  • tar: Create compressed archives.

    tar -czvf backup.tar.gz /path/to/directory  # Create a compressed archive  
    tar -xzvf backup.tar.gz                    # Extract an archive  
    
  • rsync: Sync files and directories.

    rsync -av /source/directory /destination/directory  
    

Conclusion

Mastering these basic sysadmin commands is the foundation of effective system administration. Whether you’re managing a single server or an entire infrastructure, these tools will help you troubleshoot issues, optimize performance, and keep your systems running smoothly.