This document provides an overview of informational commands in Linux including how to use commands like whoami, id, uname, df, ps, top, echo, date and man to retrieve system and user information.
This document explores essential Linux informational commands used to retrieve system and user data. It covers commands for finding user details, examining operating system information, monitoring disk usage and running processes, and printing text or variables. The practical applications of each command are demonstrated with examples.
Informational commands in Linux provide essential details about the system and its users. These commands are particularly useful for verifying user identity or determining which user account is running specific processes.
The whoami command displays the current user’s username. It takes no arguments and has no options, making it one of the simplest commands to use.
1$ whoami
2john_doe
The id command returns the user or group ID, which is a numerical identifier assigned to each user or group in the Linux system. It can be used with several options:
id -u: Returns only the numerical user IDid -un: Returns the username corresponding to the numerical user ID1$ id -u
21000
3$ id -un
4john_doe
The uname (Unix name) command provides operating system information, such as the kernel name and version number. This is useful for identifying the type of system or diagnosing system-related issues.
| Option | Description | Example Output |
|---|---|---|
| (no option) | Returns OS name | Linux |
-s | Returns kernel name | Linux |
-r | Returns kernel release | 5.4.0-42-generic |
-v | Returns detailed version information | #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 |
For example, using uname -sr would display both the OS name and its version:
1$ uname -sr
2Linux 5.4.0-42-generic
The df (disk free) command displays the system’s disk usage. It’s particularly useful for monitoring storage space or checking available space on a particular file system.
The most common usage is with the -h option, which makes the output “human-readable” by expressing disk space in units like gigabytes and terabytes instead of bytes:
1$ df -h ~
2Filesystem Size Used Avail Use% Mounted on
3/dev/sda1 100G 30G 70G 30% /home
In this example, df -h ~ displays disk information specific to the home directory (represented by the tilde symbol). The output shows all disks mounted on the home directory, including their size, used space, available space, and usage percentage.
To view disk usage across all filesystems, simply use df -h without specifying a directory.
The ps (process status) command displays currently running processes on the system. This is helpful when monitoring or managing processes.
Common usage includes:
ps: Shows processes associated with the current user and terminalps -e: Lists all processes running on the system, regardless of which user started themThe output includes the process ID, terminal associated with the process, CPU time used, and the command name:
1$ ps -e
2 PID TTY TIME CMD
3 1 ? 00:00:01 systemd
4 2 ? 00:00:00 kthreadd
5 3 ? 00:00:00 rcu_gp
6 ...
The top (table of processes) command functions as a task manager, showing a real-time view of running processes and their resource usage. It’s invaluable for monitoring system performance or identifying resource-heavy processes.
By default, top displays processes sorted by CPU usage. The output includes details such as:
The -n option can limit the display to a specific number of processes:
1$ top -n 3
2Tasks: 3 of 234 total
3%CPU PID USER PR NI VIRT RES SHR S %MEM TIME+ COMMAND
410.2 123 john 20 0 2.0g 400m 20m R 4.9 1:23 chrome
55.0 456 john 20 0 20m 8.0m 4.0m R 0.1 0:05 top
62.5 789 john 20 0 1.5g 300m 30m S 3.7 0:45 spotify
The echo command is a simple yet powerful tool for displaying text or variables in the terminal or in shell scripts.
Basic usage examples:
echo: Returns a newlineecho hello: Prints “hello”echo "Learning Linux is fun!": Prints the quoted stringWhile quotes are not strictly necessary for simple strings, they are best practice for strings with spaces or special characters.
To view the value of a variable, prefix the variable name with a dollar sign:
1$ echo $PATH
2/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
The date command displays the current system date and time:
1$ date
2Wed Jul 2 09:15:30 EDT 2025
The output can be customized using format controls, which are indicated with the % symbol:
| Format Control | Description | Example |
|---|---|---|
| %A | Full weekday name | “Wednesday” |
| %j | Day of year (001-366) | “183” |
| %Y | Year | “2025” |
| %H | Hour (00-23) | “09” |
| %M | Minute (00-59) | “15” |
Custom date formats can be created by combining these controls with text:
1$ date "+Today is %A, day %j of %Y"
2Today is Wednesday, day 183 of 2025
The man (manual) command displays the reference manual for any specified command. This is essential for learning how to use commands and understanding their options.
Usage is straightforward:
1man date
This would display the complete manual page for the date command, including all options, examples, and related information.
Linux informational commands provide valuable insights into user identity, system characteristics, resource usage, and running processes. Mastering these commands is essential for effective system administration and troubleshooting. From simple user identification with whoami to comprehensive process monitoring with top, these tools form the foundation of Linux system management.
(2) The id -u command returns only the numerical user ID assigned to the current user in the system, while id -un returns the username that corresponds to that numerical ID. These options provide different representations of the same user identity.
(3) The top command should be used first as it provides a real-time, dynamic view of system processes sorted by resource usage. It displays information about CPU and memory consumption for all running processes, making it the ideal tool for identifying which processes are consuming excessive memory.
(4) The uname command is only used to display system information and cannot modify any system parameters or settings, regardless of user privileges. It is strictly an informational command used for retrieving details about the operating system.
When using the echo command, quotation marks are always required around strings with spaces to ensure proper output.
False. While it’s considered best practice to use quotation marks around strings with spaces when using the echo command, they are not strictly required. The echo command will still correctly display strings with spaces even without quotation marks, though using quotes is recommended to avoid potential issues with special characters or complex strings.
| Command | Primary Function |
|---|---|
| A. ps | 1. Displays disk usage information |
| B. df | 2. Shows current date and time |
| C. date | 3. Lists running processes |
| D. man | 4. Displays command documentation |
A-3, B-1, C-2, D-4. The ps command lists running processes, df displays disk usage information, date shows the current date and time, and man displays command documentation.
(1) The existence of the -h (human-readable) option for the df command suggests that the default output (in bytes) can be difficult to interpret, especially for large storage values. This option converts the output to more easily understood units like KB, MB, GB, which indicates that command designers recognized the need for more intuitive output formatting.
date "+%j %Y" or date "+Day %j of %Y". This utilizes format controls where %j represents the day of the year (001-366) and %Y represents the four-digit year. The + symbol indicates that what follows is a format string, and quotation marks ensure that the entire format is treated as a single argument.