
Any Linux systems administrator needs to be proficient with a wide range of commands for user management, file handling, system monitoring, networking, security and more. This article covers a range of commands that are essential for managing a Linux server. Keep in mind that some commands will depend on the particular Linux distribution you’re using.
Managing user accounts and groups
Creating user accounts, setting up initial passwords and determining how often they should be changed, setting up user groups as needed, and locking and closing accounts are all important tasks. A Linux sysadmin should be familiar with the following commands:
- useradd, adduser, userdel and usermod – to set up, delete or modify user accounts
- groupadd, groupdel, groupmod and gpasswd – to create and manage user groups
- passwd – to change passwords
- id, whoami and groups – to view user identity and group information
- chage – to manage user password aging and account expirations
Managing files and directories
Linux sysadmins need to move around the file system, set up directories, locate files and collect information on files. The following commands will be needed:
- cd, pwd and ls – to navigate the file systems and view directory contents
- cp, mv, rm, mkdir and rmdir – to copy files, move files into a different file system location, remove files and create or remove directories
- find, locate, which and whereis – to search for files based on various criteria
- stat and file – to view information about files
- touch – to create empty files or update file timestamps
Managing file permissions and ownership
Ensuring that files, depending on their intended use, can be read or executed and have proper ownership is another important sysadmin job. The following commands are important:
- chmod, chown and chgrp – to make files executable, readable etc. and to change file and group ownership
- umask – to change the default permissions when files are created
- ls -l, getfacl and setfacl – to view and modify ACLs (access control lists)
Process and system monitoring
The commands for installing and managing system packages will vary depending on the Linux distribution, but these commands are important to know:
- apt and dpkg – for installing packages on Debian/Ubuntu systems
- yum, dnf and rpm – for installing packages on Red Hat and CentOS
- snap and flatpak – for installing particular packages on Linux systems
Testing and verifying network connections
The following commands will provide information on network connections:
- ip, ifconfig, ip a and ip r – to view and modify network interfaces and routes
- ping, traceroute, netstat and ss – to test connectivity
- nmap, telnet, curl, wget, dig and nslookup – to test ports and resolve domains
- hostname, nmcli, ethtool and tcpdump – to view host and network configuration and diagnostics
Viewing log files and services
To view and work with log data, the following commands can be used:
- journalctl – View system logs
- systemctl and service – To manage system and init services
- logger – write to a system log
- rsyslog and logrotate – to manage logs and log rotation
File compression and archiving
Being able to compress files and manage file archives is important both to save space and preserve critical data. The following commands are important for this work:
- tar – create a file archive or extract contents from a tar archive
- gzip – compress a file
- gunzip – uncompress a gzipped file
- bzip2 – compress and uncompress files
- xz, zip and unzip – compress and uncompress files (xz -d to uncompress files compressed with xz)
Notice that there are several commands for compressing files and corresponding commands to uncompress them.
Scheduling tasks to be run at specific dates and times
The following commands can be used to set up tasks to be run at specific times – once or regularly:
- cron and crontab – to schedule and view recurring tasks
- at and batch – to schedule one-time tasks
Managing disks and file systems
File systems on Linux systems can be managed with the following commands:
- mount and umount – to mount and unmount file systems
- lsblk, blkid, fdisk and parted – manage disks and partitions
- mkfs, fsck and tun2fs – to create and check file systems
- lsof and fuser – List open files and related processes
Backing up and recovering data
The commands below are used to back up and recover data on Linux.
- rsync, scp, dd, tar and cpio – to copy, clone, and back up data
- timeshift, borg and restic – Snapshot backup and restore utilities
Managing system security and access controls
The following commands are critical for managing system security:
- sudo and su – run commands with elevated privilege
- ssh and sshd – using and configuring secure shell access
- iptables, firewalld and ufw – managing system firewall
- fail2ban, auditctl and semanage – intrusion protection and auditing security
Wrap-up
There are quite a few commands you will need to know if you’re going to be managing a Linux server. This post is intended to introduce them in a very brief manner, but each of the commands listed will require that you become familiar with their use and the particular arguments the commands will require.
Source:: Network World