0% found this document useful (0 votes)
20 views10 pages

Essential Linux Admin Commands

The document outlines essential Linux system administration commands for managing users, groups, services, processes, and system resources. It covers topics such as user and group management, system monitoring, disk management, service management, file permissions, package management, backup and restore, network management, cron jobs, and system shutdown/reboot. Each section provides specific command syntax and usage examples for effective system administration.

Uploaded by

tvganesann
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views10 pages

Essential Linux Admin Commands

The document outlines essential Linux system administration commands for managing users, groups, services, processes, and system resources. It covers topics such as user and group management, system monitoring, disk management, service management, file permissions, package management, backup and restore, network management, cron jobs, and system shutdown/reboot. Each section provides specific command syntax and usage examples for effective system administration.

Uploaded by

tvganesann
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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 [Link] /path/to/directory # Backup a directory into a
tarball

• Restore a Backup

bash
CopyEdit
sudo tar -xzvf [Link] -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 [Link] # 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 [Link]/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

Common questions

Powered by AI

Service log analysis in Linux can significantly enhance system management by allowing administrators to monitor service activities, diagnose issues, and track historical performance . The command 'sudo journalctl -u service_name' retrieves logs for specific services, providing detailed insights into their operations . This information helps in identifying bottlenecks, understanding failures, and ensuring services run optimally, thereby improving overall system reliability .

Handling services in Linux involves commands such as 'sudo systemctl start service_name' to start a service, 'sudo systemctl stop service_name' to halt a service, and 'sudo systemctl status service_name' to check the current status . Proper service management affects system performance and reliability by ensuring necessary services run efficiently while unneeded ones do not consume resources . Automating service starts with 'systemctl enable service_name' enhances reliability, especially during reboots, by ensuring critical services are consistently active .

Resizing a partition using Linux commands, such as 'sudo resize2fs /dev/sdX', allows modification of the partition size within an ext4 filesystem . This is crucial for optimizing disk space usage and allocating resources according to current needs. Before performing this action, it is essential to ensure data backup, verify filesystem integrity with 'sudo fsck /dev/sdX', and check for sufficient disk space to accommodate the new size . These considerations help in preventing data loss and ensuring the resizing process does not affect system stability .

Linux package management differs between Debian-based and Red Hat-based distributions mainly in the package manager used: 'apt' for Debian/Ubuntu and 'yum/dnf' for Red Hat/CentOS/Fedora . Both systems offer commands like 'sudo apt update' and 'sudo dnf update' for package updates, but the syntax and package repositories vary . This impacts system administration as it requires admins to be familiar with different command sets and manage updates, installations, and removals according to the distribution-specific package manager, influencing system stability and security .

User management in Linux can be enhanced using commands like 'sudo useradd username' to create users, 'sudo passwd username' to set passwords, and 'sudo userdel username' to delete users efficiently . Proper management ensures system security and optimal resource allocation by preventing unauthorized access and maintaining user-specific settings . Inadequate user management might lead to security breaches, unauthorized data access, and system instability due to resource mismanagement .

Linux commands facilitate network management by enabling configuration and monitoring of network interfaces, testing connectivity, and viewing active connections . Functionalities like 'ping google.com' for connectivity tests, 'ifconfig/ip a' for displaying network interfaces, and 'sudo netstat -tuln' for active network connections significantly enhance network troubleshooting . These capabilities aid in diagnosing network issues, ensuring smooth operations by allowing admins to manage IP addresses and analyze traffic patterns effectively .

Backup and restore are critical processes for data protection and system recovery in Linux environments . Tools like 'tar' and 'rsync' are specifically mentioned, with commands 'sudo tar -czvf backup.tar.gz /path/to/directory' for creating backups and 'sudo rsync -avh /path/to/source/ /path/to/destination/' for efficient copying of data . These processes ensure data integrity and availability, allowing recovery from data loss or corruption and enhancing system resilience .

System monitoring is crucial for maintaining a Linux-based server as it provides insights into real-time process activities, resource usage, and system performance . Specific tools mentioned include 'top' for real-time process monitoring, 'htop' for an interactive process viewer, 'free -h' for memory usage, and 'df -h' for disk space usage . These tools help in identifying bottlenecks and optimizing system performance by tracking resource allocation and process status .

File permissions in Linux define the levels of access that users and groups have on files, crucial for system security and data privacy . Commands like 'sudo chmod 755 filename' change permissions, allowing certain operations for user, group, and others . Altering permissions can enhance security by restricting unauthorized data access or, conversely, expose sensitive information if permissions are too permissive, leading to potential system compromise . Ensuring that permissions follow the principle of least privilege helps mitigate security risks .

Cron jobs in Linux are scheduled tasks that automate repetitive processes, allowing commands or scripts to run at specified times or intervals . They are essential for system automation as they enable regular execution of critical tasks like backups, updates, and log management without manual intervention, enhancing efficiency and reliability . Admins can use 'crontab -l' to view and 'crontab -e' to edit cron jobs, ensuring that required tasks are performed consistently .

You might also like