Linux commands for System Administration
Hereโs aย list of basic Linux commands for system administration, along with examples and short explanations for each:
Sure! Here’s a list of basic Linux commands for system administration, along with examples and short explanations for each:
๐๏ธ 1. File and Directory Management
| Command | Description | Example |
|---|---|---|
ls | List directory contents | ls -l /home/user/ |
cd | Change directory | cd /var/log |
pwd | Show current directory | pwd |
mkdir | Create directory | mkdir /opt/testdir |
rm | Remove files or directories | rm file.txt rm -r folder/ |
cp | Copy files/directories | cp file1.txt file2.txt |
mv | Move/rename files | mv oldname.txt newname.txt |
๐งโ๐ป 2. User Management
| Command | Description | Example |
|---|---|---|
adduser or useradd | Add new user | adduser john |
passwd | Set or change user password | passwd john |
deluser or userdel | Delete user | userdel john |
usermod | Modify user account | usermod -aG sudo john |
whoami | Display current user | whoami |
id | Show user ID and groups | id john |
๐ง 3. System Information
| Command | Description | Example |
|---|---|---|
uname -a | System info | uname -a |
top | Real-time process monitoring | top |
htop | Interactive process viewer (needs install) | htop |
df -h | Disk usage | df -h |
free -h | Memory usage | free -h |
uptime | System uptime | uptime |
hostname | Show/set system hostname | hostname |
โ๏ธ 4. Process Management
| Command | Description | Example |
|---|---|---|
ps aux | Show all running processes | ps aux |
kill | Kill process by PID | kill 1234 |
killall | Kill process by name | killall firefox |
nice | Start process with priority | nice -n 10 myscript.sh |
๐ 5. File Permissions
| Command | Description | Example |
|---|---|---|
chmod | Change file permissions | chmod 755 script.sh |
chown | Change file owner | chown user:group file.txt |
ls -l | View permissions | ls -l |
๐ฆ 6. Package Management (Debian/Ubuntu)
| Command | Description | Example |
|---|---|---|
apt update | Refresh package list | sudo apt update |
apt upgrade | Upgrade packages | sudo apt upgrade |
apt install | Install package | sudo apt install nginx |
apt remove | Remove package | sudo apt remove nginx |
๐ 7. Service Management (SystemD)
| Command | Description | Example |
|---|---|---|
systemctl start | Start service | sudo systemctl start nginx |
systemctl stop | Stop service | sudo systemctl stop nginx |
systemctl status | Check status | sudo systemctl status nginx |
systemctl enable | Enable service at boot | sudo systemctl enable nginx |
๐ 8. Network Commands
| Command | Description | Example |
|---|---|---|
ip a | Show IP addresses | ip a |
ping | Ping a host | ping google.com |
netstat -tuln | Show listening ports | netstat -tuln |
ss -tuln | Alternative to netstat | ss -tuln |
curl | Transfer data from URL | curl https://example.com |
๐ 9. Archiving and Compression
| Command | Description | Example |
|---|---|---|
tar | Archive files | tar -czvf backup.tar.gz /home/user/ |
gzip | Compress file | gzip file.txt |
unzip | Unzip file | unzip file.zip |
๐งช 10. Log Monitoring
| Command | Description | Example |
|---|---|---|
tail -f | Live view of logs | tail -f /var/log/syslog |
cat | View file content | cat /etc/passwd |
less | Scrollable file viewer | less /var/log/dmesg |