Blog / The Most Used Linux Commands: Keys to Optimise Your Server

The Most Used Linux Commands: Keys to Optimise Your Server

by SW Team

At SW Hosting, we are committed to providing educational and useful content for all server administrators. In this guide, we share with you some of the most essential Linux commands that can help you optimise the administration of your servers.

Your Cloud SO from $8.51/month

Get the most out of your project with the fastest disks and most powerful CPUs in the Cloud.

1. File and Directory Management Commands

File management is one of the most basic but essential tasks when working with servers. With these commands you can browse, copy or move files efficiently.

  • ls: Lists the contents of a directory. It is essential for exploring your file system.

    ls -l
    

    The -l option displays details such as permissions, owners and file sizes.

  • cd: Change directory.

    cd /route/from/directory
    
  • cp: Copying files or directories from one location to another.

    cp file.txt /route/destination
    
  • mv: Move or rename files.

    mv file.txt /new/route
    
  • rm: Delete files or directories. Use with caution

    rm file.txt
    
  • find: Searches for files or directories within the system.

    find /route -name "file.txt"
    

These commands will allow you to efficiently manage the files within your server, which is essential for maintaining organisation and performance.

2. Commands for User and Permissions Management

Managing users and permissions correctly is essential to maintaining the security of your server. Here are some key commands:

  • adduser and deluser: Add or delete users.

    adduser nombre_usuario
    deluser nombre_usuario
    
  • passwd: Change a user's password.

    passwd name_user
    
  • chmod: Change file or directory permissions to ensure security.

    chmod 755 file.txt
    
  • chown: Change the owner of a file or directory.

    chown user:grup file.txt
    

3. Commands for System Monitoring

To make sure your server is running properly, it is important to monitor its performance in real time. These commands will help you:

  • top: Displays running processes in real time.

    top
    
  • htop: It is a more interactive version of top that allows you to manage processes in a more intuitive way.

  • df: Displays disk space usage.

    df -h
    
  • du: Displays the size of a specific file or directory.

    du -sh /route/of/directory
    
  • free: Displays memory usage.

    free -h
    

These commands allow you to monitor system health to prevent potential performance problems before they become serious.

4. Process Management Commands

Efficient process management is vital to server stability. These commands will help you keep track of what is running:

  • ps: List the running processes.

    ps aux
    
  • kill: Terminate a process using its PID.

    kill 1234
    
  • killall: Terminate processes by name.

    killall name_process
    
  • systemctl: Manages services on systems with systemd.

    systemctl status service
    

5. Network Commands

Network connectivity is crucial to the operation of any server. Here are some useful commands for managing the network:

  • ping: Verify connectivity with another device.

    ping www.google.com
    
  • netstat: Displays active network connections and their statistics.

    netstat -tuln
    
  • curl: Make HTTP requests from the command line.

    curl -I www.swhosting.com
    
  • scp: Securely copy files between servers.

    scp file.txt user@server:/route/destination
    

6. Commands for Security

Securing your server is essential. Use these commands to enforce security:

  • iptables: Manage firewall rules.

    iptables -L
    
  • ssh: Remotely access another server.

    ssh user@server
    
  • fail2ban: Protect your server against unauthorised access attempts.

    fail2ban-client status
    

7. Automation and Scripting

Task automation is key to managing servers efficiently:

  • crontab: Schedule automatic tasks.

    crontab -e
    
  • bash: Run scripts to automate processes.

    ./script.sh
    
    Your Cloud SO from $8.51/month

    Get the most out of your project with the fastest disks and most powerful CPUs in the Cloud.

Conclusion

Mastering these commands will allow you to manage and secure your server more efficiently, resulting in better performance and increased security. At SW Hosting, we not only provide advanced platforms, but we are also committed to helping you get the most out of your resources. If you need further guidance or have any questions, our team of experts is here to help you optimise your infrastructure.

i
Email send icon