Command | Description | Use Cases |
---|---|---|
uname | Displays system information (OS, kernel, architecture). | Check OS details before installing software on cloud servers. |
uptime | Shows system uptime and load averages. | Monitor server health and performance in cloud environments. |
date | Displays or sets the system date and time. | Timestamp logs, automate cron jobs, and synchronize cloud instances. |
who | Lists currently logged-in users. | Monitor active users on production servers for security. |
whoami | Shows the current logged-in user. | Verify user privileges before executing critical commands. |
id | Displays user ID (UID) and group ID (GID). | Check user permissions in DevOps environments. |
sudo | Executes commands as a superuser. | Perform administrative tasks like installing software. |
shutdown | Shuts down the system. | Schedule controlled server shutdowns in cloud environments. |
reboot | Reboots the system. | Restart cloud instances after updates or maintenance. |
apt | Package manager for Debian-based systems. | Install and update software in Ubuntu, Debian cloud instances. |
yum | Package manager for RHEL-based systems. | Manage packages in RHEL, CentOS cloud servers. |
dnf | Modern package manager for RHEL/Fedora. | Install software on Fedora-based cloud environments. |
pacman | Package manager for Arch Linux. | Deploy lightweight servers using Arch Linux in cloud setups. |
portage | Source-based package management in Gentoo. | Optimize and compile software in Gentoo-based cloud deployments. |
1. uname
– Get System Information
Usage: Displays system information (OS, kernel version, architecture).
How It Works:
- Retrieves system details from
/proc/sys/kernel
anduname
system call.
Examples:
uname # Display OS name
uname -r # Show kernel version
uname -a # Show all system information
Output:
Linux ip-172-31-24-100 5.11.0-41-generic #45-Ubuntu SMP Thu Jan 6 17:35:33 UTC 2023 x86_64 GNU/Linux
📌 Case Study: A DevOps engineer checks the OS and kernel version before updating a cloud server.
2. uptime
– Show System Uptime
Usage: Displays system uptime and load averages.
How It Works:
- Retrieves uptime and load information from
/proc/uptime
and/proc/loadavg
.
Example:
uptime
Output:
12:05:30 up 10 days, 3:42, 2 users, load average: 0.12, 0.14, 0.09
📌 Case Study: A cloud engineer checks uptime before scheduling maintenance on an AWS EC2 instance.
3. date
– Display or Set System Date and Time
Usage: Shows or sets the system date and time.
How It Works:
- Reads and modifies
/etc/localtime
and system clock.
Examples:
date # Show current date and time
date +%Y-%m-%d # Display only date in YYYY-MM-DD format
date -s "2025-01-18 12:00:00" # Set system date/time (requires sudo)
📌 Case Study: A DevOps engineer schedules automated backups and uses date
to timestamp log files.
4. who
– Show Logged-in Users
Usage: Displays currently logged-in users.
How It Works:
- Fetches user login data from
/var/run/utmp
.
Example:
who
Output:
devops pts/0 2025-01-18 10:05 (192.168.1.100)
📌 Case Study: A system admin monitors remote users accessing a production server.
5. whoami
– Display Current User
Usage: Prints the currently logged-in username.
How It Works:
- Reads the user ID from the environment.
Example:
whoami
Output:
devops
📌 Case Study: A developer checks their user privileges before executing a command.
6. id
– Display User ID (UID) and Group ID (GID)
Usage: Shows the user ID, group ID, and group memberships.
How It Works:
- Retrieves user and group info from
/etc/passwd
and/etc/group
.
Example:
id devops
Output:
uid=1001(devops) gid=1001(devops) groups=1001(devops),27(sudo)
📌 Case Study: A DevOps engineer checks if a user has sudo
privileges.
7. sudo
– Execute Commands as Superuser
Usage: Runs commands as a superuser or another user.
How It Works:
- Reads
/etc/sudoers
to check user permissions.
Examples:
sudo apt update # Run package update as root
sudo -u devops ls # Execute command as another user
📌 Case Study: A system admin uses sudo
to update cloud instances securely.
8. shutdown
– Power Off or Restart System
Usage: Shuts down or reboots the system.
How It Works:
- Sends SIGTERM to all processes and powers off the system.
Examples:
sudo shutdown -h now # Shutdown immediately
sudo shutdown -r +5 # Reboot in 5 minutes
📌 Case Study: A cloud admin schedules a safe shutdown of EC2 instances during maintenance.
9. reboot
– Restart System
Usage: Reboots the system immediately.
How It Works:
- Executes a system call to reboot.
Example:
sudo reboot
📌 Case Study: A DevOps engineer restarts a Kubernetes node after applying updates.
10. apt
– Package Manager for Debian-based Systems
Usage: Manages software packages in Ubuntu/Debian.
How It Works:
- Uses
/etc/apt/sources.list
to fetch package data.
Examples:
sudo apt update # Update package lists
sudo apt install nginx # Install Nginx
sudo apt remove apache2 # Remove Apache
📌 Case Study: A DevOps engineer installs monitoring tools on AWS Ubuntu instances.
11. yum
– Package Manager for RHEL/CentOS
Usage: Manages software packages in RHEL/CentOS.
How It Works:
- Uses
/etc/yum.repos.d/
for repositories.
Examples:
sudo yum update # Update system packages
sudo yum install httpd # Install Apache
sudo yum remove nginx # Remove Nginx
📌 Case Study: A cloud engineer sets up web servers using yum
in AWS RHEL-based AMIs.