NAME : GOMATHI M. T.
REG. NO. : EC2532251010234
CLASS : I – MCA ‘A’ SEC
SUBJECT : OPERATING SYSTEM WEEK 5
ASSESSMENT
TOPICS : System Admin Commands
SYSTEM ADMIN COMMANDS
These are some basic system administration commands in Linux that every system
administrator should be familiar with. These commands are essential for managing
users, groups, services, processes, and system resources.
1. User Management
• Add User
bash
CopyEdit
sudo useradd username # Create a new user
sudo useradd -m username # Create a new user and create their home directory
• Set User Password
bash
CopyEdit
sudo passwd username # Set or change a user's password
• Delete User
bash
CopyEdit
sudo userdel username # Delete a user
sudo userdel -r username # Delete a user and their home directory
• Add User to Group
bash
CopyEdit
sudo usermod -aG groupname username # Add user to a specific group
• List All Users
bash
CopyEdit
cat /etc/passwd # Lists all users on the system
• Change User Info
bash
CopyEdit
sudo usermod -c "New Name" username # Change the user's description
sudo usermod -l new_username old_username # Change a username
• Group Management
o Add a new group:
bash
CopyEdit
sudo groupadd groupname
o Delete a group:
bash
CopyEdit
sudo groupdel groupname
o Add user to a group:
bash
CopyEdit
sudo usermod -aG groupname username
2. System Monitoring
• Top (Real-time Process Monitoring)
bash
CopyEdit
top # Displays real-time process activity
• htop (Interactive Process Viewer)
bash
CopyEdit
htop # Requires installation (use 'sudo apt install htop' on
Debian-based systems)
• System Resource Usage
bash
CopyEdit
free -h # Displays memory usage (RAM)
df -h # Displays disk space usage
du -sh /path/to/directory # Displays disk usage for a specific directory
• Process Status
bash
CopyEdit
ps aux # List all running processes
• System Uptime
bash
CopyEdit
uptime # Displays system uptime, load, and the number of users
• Check System Logs
bash
CopyEdit
tail -f /var/log/syslog # View system logs in real-time
journalctl -xe # View logs from `systemd`
3. Disk Management
• Check Disk Partitions
bash
CopyEdit
fdisk -l # List all partitions
• Mount/Unmount a Filesystem
bash
CopyEdit
sudo mount /dev/sdX /mnt # Mount a disk or partition to /mnt
sudo umount /mnt # Unmount a disk from /mnt
• Check Disk Space
bash
CopyEdit
df -h # Check disk space usage in a human-readable format
• Format a Disk/Partition
bash
CopyEdit
sudo mkfs.ext4 /dev/sdX # Format a partition with the ext4 filesystem
• Check and Repair Filesystem
bash
CopyEdit
sudo fsck /dev/sdX # Check and repair filesystem issues
• Resize Partition (with resize2fs)
bash
CopyEdit
sudo resize2fs /dev/sdX # Resize an ext4 partition
4. Service Management (Using systemd)
• Start a Service
bash
CopyEdit
sudo systemctl start service_name # Start a service
• Stop a Service
bash
CopyEdit
sudo systemctl stop service_name # Stop a service
• Restart a Service
bash
CopyEdit
sudo systemctl restart service_name # Restart a service
• Check the Status of a Service
bash
CopyEdit
sudo systemctl status service_name # Get the current status of a service
• Enable a Service (Start Automatically at Boot)
bash
CopyEdit
sudo systemctl enable service_name # Enable a service to start at boot
• Disable a Service (Do Not Start at Boot)
bash
CopyEdit
sudo systemctl disable service_name # Disable a service from starting at boot
• View Logs for a Service
bash
CopyEdit
sudo journalctl -u service_name # View logs for a specific service
5. File Permissions and Ownership
• Change File Permissions
bash
CopyEdit
sudo chmod 755 filename # Change file permissions (rwx for owner, rx
for group and others)
sudo chmod u+x filename # Add execute permission to the file for the
user
• Change File Owner
bash
CopyEdit
sudo chown user:group filename # Change owner and group of the file
• Change File Group
bash
CopyEdit
sudo chgrp groupname filename # Change the group of a file
6. Package Management (Depends on the Distribution)
For Debian/Ubuntu (apt):
• Update Package List
bash
CopyEdit
sudo apt update # Update the local package database
• Upgrade Packages
bash
CopyEdit
sudo apt upgrade # Upgrade all installed packages
• Install a Package
bash
CopyEdit
sudo apt install package_name # Install a package
• Remove a Package
bash
CopyEdit
sudo apt remove package_name # Remove a package
• Search for a Package
bash
CopyEdit
apt search package_name # Search for a package
For Red Hat/CentOS/Fedora (yum/dnf):
• Update Package List
bash
CopyEdit
sudo yum update # Update the system (for older RHEL/CentOS)
sudo dnf update # Update the system (for newer Fedora/RHEL 8+)
• Install a Package
bash
CopyEdit
sudo yum install package_name # Install a package
sudo dnf install package_name # For newer systems
• Remove a Package
bash
CopyEdit
sudo yum remove package_name # Remove a package
sudo dnf remove package_name # For newer systems
7. Backup and Restore
• Create a Backup (Using tar)
bash
CopyEdit
sudo tar -czvf backup.tar.gz /path/to/directory # Backup a directory into a
tarball
• Restore a Backup
bash
CopyEdit
sudo tar -xzvf backup.tar.gz -C /path/to/restore # Restore a tarball backup
• Create a Backup (Using rsync)
bash
CopyEdit
sudo rsync -avh /path/to/source/ /path/to/destination/ # Copy files/directories
with rsync
8. Network Management
• Check Network Status
bash
CopyEdit
ifconfig # Display network interfaces
ip a # Display network interfaces (modern alternative to
ifconfig)
• Test Connectivity (Ping a Host)
bash
CopyEdit
ping google.com # Test network connectivity to a host
• View Active Network Connections
bash
CopyEdit
sudo netstat -tuln # Display active network connections
• Check Open Ports
bash
CopyEdit
sudo lsof -i -P -n # List open network ports and connections
• Configure IP Address
bash
CopyEdit
sudo ip addr add 192.168.1.100/24 dev eth0 # Assign IP address to network
interface
9. Cron Jobs (Scheduled Tasks)
• View Cron Jobs
bash
CopyEdit
crontab -l # List the current user's cron jobs
• Edit Cron Jobs
bash
CopyEdit
crontab -e # Edit the current user's cron jobs
• System-Wide Cron Jobs
bash
CopyEdit
sudo nano /etc/crontab # System-wide cron jobs (root only)
10. Shutdown and Reboot
• Reboot the System
bash
CopyEdit
sudo reboot # Reboot the system
• Shutdown the System
bash
CopyEdit
sudo shutdown -h now # Shutdown the system immediately
sudo shutdown -r now # Reboot the system immediately