Master these fundamental commands that form the backbone of daily administration:
# Process management ps aux | grep [process] kill -9 [PID] systemctl status|start|stop|restart [service] journalctl -xe # File operations grep -r "pattern" /path/ find / -name "filename" -type f -mtime +30 rsync -avzP source/ user@remote:dest/ chmod 755 file.sh chown user:group file
Network troubleshooting commands you'll use constantly:
# Basic connectivity ping -c 4 example.com traceroute example.com mtr example.com # Advanced diagnostics ss -tulnp netstat -plant tcpdump -i eth0 port 80 nmap -sV 192.168.1.0/24 # Firewall management (iptables) iptables -L -n -v iptables -A INPUT -p tcp --dport 22 -j ACCEPT iptables-save > /etc/iptables.rules
Critical storage commands for daily operations:
# Disk space management df -hT du -sh * lsblk fdisk -l # LVM operations pvdisplay vgdisplay lvdisplay lvresize -L +10G /dev/vg0/lv_root # Mount management mount /dev/sdb1 /mnt/data umount -l /mnt/data /etc/fstab entries debugging
Distribution-specific package commands:
# Debian/Ubuntu apt update && apt upgrade apt-cache search package dpkg -l | grep package apt-get install --reinstall package # RHEL/CentOS yum update yum provides */command rpm -qa | grep package yum history undo [ID]
Essential security commands:
# User management adduser newuser passwd -l username chage -l username visudo # SSH security ssh-keygen -t rsa -b 4096 ssh-copy-id user@remote /etc/ssh/sshd_config modifications: PermitRootLogin no PasswordAuthentication no
Key services every admin should know:
# Apache/Nginx apachectl configtest nginx -t grep -r "DocumentRoot" /etc/apache2/ # Database (MySQL/MariaDB) mysql -u root -p SHOW PROCESSLIST; GRANT ALL PRIVILEGES ON db.* TO 'user'@'localhost'; # Samba shares smbclient -L //server -U user testparm -s
Common scripting patterns:
#!/bin/bash # Backup script example DATE=$(date +%Y%m%d) mysqldump -u root -p database > /backups/db_$DATE.sql tar -czf /backups/web_$DATE.tar.gz /var/www/ find /backups/ -type f -mtime +30 -delete
Quick problem-solving commands:
# System logs tail -f /var/log/syslog dmesg | grep -i error # Performance top htop iotop iftop vmstat 1 10
Understanding Linux file systems and permissions is fundamental. You should be able to:
# Check disk usage
df -h
du -sh *
# Modify permissions
chmod 755 /path/to/file
chown user:group /path/to/file
# Find files with specific permissions
find / -type f -perm 4000 -ls
Different distributions use different package managers:
# Debian/Ubuntu
apt update
apt install package
apt remove package
# RHEL/CentOS
yum install package
dnf remove package
# Arch
pacman -S package
pacman -R package
Network configuration and troubleshooting:
# Check network interfaces
ip a
ifconfig
# Test connectivity
ping google.com
traceroute google.com
# Check open ports
netstat -tulnp
ss -tulnp
Monitoring and controlling processes:
# View running processes
top
htop
ps aux
# Kill processes
kill -9 PID
pkill process_name
Working with system services:
# Systemd commands
systemctl start service
systemctl stop service
systemctl enable service
journalctl -u service -f
Basic security practices:
# Firewall management
ufw allow 22/tcp
iptables -L
# SSH configuration
vim /etc/ssh/sshd_config
ssh-keygen -t rsa
Working with system logs:
# View logs
tail -f /var/log/syslog
journalctl -xe
# Search logs
grep "error" /var/log/messages
Automating tasks with scripts:
#!/bin/bash
# Backup script example
backup_dir="/backups"
mkdir -p $backup_dir
tar -czf $backup_dir/backup_$(date +%Y%m%d).tar.gz /path/to/backup
find $backup_dir -type f -mtime +30 -delete
Working with Apache/Nginx:
# Apache virtual host
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/example.com
ServerName example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# Nginx server block
server {
listen 80;
server_name example.com;
root /var/www/example.com;
index index.html;
}
Basic MySQL/MariaDB operations:
# Login to MySQL
mysql -u root -p
# Common commands
CREATE DATABASE dbname;
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
Scheduling tasks:
# Edit crontab
crontab -e
# Example entries
0 3 * * * /path/to/backup.sh
*/15 * * * * /path/to/monitor.sh
System performance checks:
# CPU usage
mpstat 1 5
# Memory usage
free -m
vmstat 1 5
# Disk I/O
iostat -x 1 5
Quick fixes for common problems:
# Disk full issues
du -sh * | sort -h
find / -type f -size +100M -exec ls -lh {} \;
# High load
uptime
ps aux --sort=-%cpu | head