Introduction
A System Administrator (sysadmin) is responsible for maintaining, configuring, and ensuring the reliable operation of a UNIX system. The system administrator has special privileges and uses the root (superuser) account to manage the system.
The Root User (Superuser)
- The root user has UID (User ID) = 0.
- Root has unrestricted access to all files, commands, and system resources.
- The root prompt is typically
#while a normal user prompt is$. - Caution: Using root carelessly can damage the system. Always use with care.
Accessing Root Privileges
1. Direct Login as Root:
- Login with username
rootand its password. - Not recommended for security reasons.
2. Using su (Switch User):
su— Switches to root user (requires root password).su - username— Switches to a specific user.
3. Using sudo (Superuser Do):
- Allows a permitted user to execute a command as root.
sudo command— Runs a single command with root privileges.- The user must be listed in the
/etc/sudoersfile. - Preferred method as it provides an audit trail.
Key System Administration Tasks
1. User Management:
useradd username— Create a new user.userdel username— Delete a user.usermod -aG group username— Add user to a group.passwd username— Set or change a user's password.- User info is stored in
/etc/passwdand/etc/shadow.
2. Group Management:
groupadd groupname— Create a new group.groupdel groupname— Delete a group.- Group info is stored in
/etc/group.
3. File System Management:
mount /dev/sda1 /mnt— Mount a file system.umount /mnt— Unmount a file system.df -h— Check disk space usage.du -sh /path— Check size of a directory.fsck /dev/sda1— File system consistency check and repair.
4. Process Management:
ps aux— List all running processes.top/htop— Real-time process monitoring.kill PID— Terminate a process by PID.kill -9 PID— Force kill a process.nice -n value command— Run a process with modified priority.renice value PID— Change priority of a running process.
5. System Monitoring:
uptime— System uptime and load averages.free -h— Memory usage.vmstat— Virtual memory statistics.iostat— I/O statistics.dmesg— Kernel ring buffer messages.
6. Backup and Recovery:
tar -cvf backup.tar /directory— Create a backup archive.tar -xvf backup.tar— Restore from a backup.cpio— Another backup utility in UNIX.crontab -e— Schedule automated backups using cron jobs.
7. Network Administration:
ifconfig/ip addr— View network interfaces.ping host— Test connectivity.netstat— Network connections and statistics.ssh user@host— Secure remote login.scp file user@host:/path— Secure file copy.
8. System Startup and Shutdown:
shutdown -h now— Halt the system immediately.shutdown -r now— Reboot the system.init 0— Shutdown (runlevel 0).init 6— Reboot (runlevel 6).
Important Configuration Files
| File | Purpose |
|---|---|
/etc/passwd | User account information |
/etc/shadow | Encrypted user passwords |
/etc/group | Group information |
/etc/sudoers | Sudo privileges configuration |
/etc/fstab | File systems to mount at boot |
/etc/hosts | Static hostname to IP mappings |
/etc/crontab | System-wide cron job schedule |
/var/log/syslog | System log file |
/var/log/auth.log | Authentication log |
Summary
- The system administrator manages the UNIX system using root privileges.
sudois the preferred way to execute administrative commands.- Key tasks include user/group management, file system maintenance, process control, backup, and network administration.
- Important config files are located in
/etc/directory.