As a system administrator, Linux proficiency is not just a bonus but a necessity. Understanding the fundamental Linux commands not only enables efficient system management but also ensures system stability, security, and optimal performance. This article covers essential Linux commands every sysadmin should master, providing you with the tools you need for effective system management.
1. Navigating the Filesystem
– `ls`: Lists files and directories in the current directory. Variations like `ls -l` provide detailed information, while `ls -a` includes hidden files.
– `cd`: Changes the current directory. Use `cd /path/to/directory` to navigate to a specific directory or `cd ..` to move up one directory.
– `pwd`: Displays the current working directory.
2. File and Directory Management
– `cp`: Copies files or directories. For example, `cp source_file destination_file` for files and `cp -r source_directory destination_directory` for directories.
– `mv`: Moves or renames files and directories. For example, `mv old_name new_name` renames a file.
– `rm`: Removes files or directories. Use `rm file_name` for files and `rm -r directory_name` for directories.
– `mkdir`: Creates a new directory. For example, `mkdir new_directory`.
3. Viewing and Editing Files
– `cat`: Concatenates and displays file content. For example, `cat file_name` shows the content of the file.
– `more` and `less`: Paginate file content for easier reading. Use `more file_name` or `less file_name`.
– `nano`, `vi`, `vim`: Text editors for command-line text editing. For instance, `nano file_name` or `vi file_name`.
4. System Monitoring and Management
– `top`: Real-time monitoring of system processes, providing CPU and memory usage information.
– `htop`: An enhanced version of `top` with better user interface and additional features.
– `ps`: Displays current processes. Use `ps aux` for a detailed list of all running processes.
– `df`: Shows disk space usage. For example, `df -h` displays human-readable format.
– `du`: Estimates file and directory space usage. Use `du -sh directory_name` for a summary.
5. User and Permission Management
– `useradd` and `userdel`: Adds and deletes users. For instance, `useradd new_user` and `userdel user_name`.
– `passwd`: Changes or sets a user’s password. For example, `passwd user_name`.
– `chmod`: Changes file or directory permissions. Use `chmod 755 file_name` for setting permissions.
– `chown`: Changes file owner and group. For example, `chown user:group file_name`.
6. Package Management
– `apt-get` (Debian/Ubuntu): Manages packages. Use `apt-get install package_name` for installing, `apt-get remove package_name` for removing, and `apt-get update` for updating package lists.
– `yum` (CentOS/RHEL): Similar to `apt-get`, `yum` handles package management. For example, `yum install package_name`.
– `dnf` (Fedora): The newer package manager for Fedora, replacing `yum`. Use `dnf install package_name`.
7. Network Management
– `ifconfig` and `ip`: Configure network interfaces. For instance, `ifconfig eth0` or `ip a`.
– `ping`: Tests connectivity to another host. Use `ping hostname_or_ip`.
– `netstat`: Displays network connections, routing tables, and interface statistics. For example, `netstat -tuln` shows listening ports.
– `ssh`: Connects to a remote machine securely. For example, `ssh user@remote_host`.
8. Backup and Archiving
– `tar`: Archives files. For instance, `tar -cvf archive_name.tar directory_name` creates an archive.
– `gzip` and `gunzip`: Compresses and decompresses files. Use `gzip file_name` and `gunzip file_name.gz`.
9. Scheduling Tasks
– `cron`: Schedules tasks to run at specified times. Edit the cron jobs with `crontab -e`. For detailed scheduling, refer to `man 5 crontab`.
10. Accessing Manual Pages
– `man`: Displays the manual for a command. For example, `man ls` provides the manual for the `ls` command.
Gaining a firm understanding of these commands is crucial for any sysadmin. For a comprehensive dive into managing Virtual Private Servers (VPS), check out a great starter kit for learning VPS management. Mastering these commands ensures that you can handle everyday sysadmin tasks efficiently and effectively, building a robust foundation for more advanced system administration skills.