Linux CLI Essentials for Debian Users – Part 3: System Information
Uncover Linux System Insights: Master System Information Commands in Part 3 of Our Comprehensive Guide.
Introduction:
Welcome to the third installment of our comprehensive guide, “Linux CLI Essentials for Debian Users.” In this section, we continue our journey through the intricacies of the Command Line Interface (CLI).
Before we dive into the world of gathering vital system insights and performance metrics, let’s take a moment to revisit what we’ve covered thus far. In the previous section, you acquired essential skills for manipulating file contents and performing efficient file and directory searches.
Now, in Part 3, we shift our focus to system information. As a user, having a clear understanding of your system’s status, resources, and processes is invaluable. In this section, we will explore commands such as uname
, top
, free
, ps
, jobs
, lspci
, df
, du
, and man
. These commands empower you to monitor system performance, check available resources, analyze running processes, and access comprehensive manual pages, all from the command line.
Understanding your system’s vital statistics is fundamental to efficient system administration and troubleshooting. Whether you’re a seasoned Linux user or just beginning your CLI journey, this section will equip you with the knowledge and tools needed to become a proficient system information explorer.
System Information:
19. uname - display system information:
The uname
command is used to display information about the system. It can display information about the operating system, hardware platform, and other system details.
- Command Name:
uname
- This is the command, used to display system information.
Syntax:
```shelluname [options]
**Examples:**
1. **Display all available system information:**
```shell uname -a ```
This command displays all available system information, including the operating system, machine hardware name, hostname, kernel release, kernel name, and kernel version.
2. **Display the machine hardware name:**
```shell uname -m ```
This command displays the machine hardware name, which represents the hardware platform of the system.
3. **Display the hostname of the system:**
```shell uname -n ```
This command displays the hostname of the system, which is the name that identifies the system on a network.
4. **Display the operating system name:**
```shell uname -o ```
This command displays the name of the operating system, such as "GNU/Linux" or "Linux."
5. **Display the current kernel release:**
```shell uname -r ```
This command displays the version of the currently running kernel.
6. **Display the name of the current kernel:**
```shell uname -s ```
This command displays the name of the currently running kernel, often "Linux."
7. **Display the current kernel version:**
```shell uname -v ```
This command displays the version number of the currently running kernel.
**Options and Modifiers:**
The `uname` command has several options to specify which system information to display. Here are the commonly used options:
1. **`-a` (or `--all`)**: Display all available system information.
- Example:
```shell uname -a
This command displays all system information.
-m
(or--machine
): Display the machine hardware name.- Example:
shell uname -m
This command displays the machine hardware name.
-n
(or--nodename
): Display the hostname of the system.- Example:
shell uname -n
This command displays the hostname.
-o
(or--operating-system
): Display the operating system name.- Example:
shell uname -o
This command displays the operating system name.
-r
(or--kernel-release
): Display the current kernel release.- Example:
shell uname -r
This command displays the kernel release version.
-s
(or--kernel-name
): Display the name of the current kernel.
- Example:
shell uname -s
This command displays the kernel name.
-v
(or--kernel-version
): Display the current kernel version.- Example:
shell uname -v
This command displays the kernel version.
These options allow you to customize the information displayed by the uname
command to obtain specific details about your system.
20. top - display system resources and processes:
The top
command is used to display information about the system performance. It can display information about the system load, CPU usage, memory usage, and running processes.
- Command Name:
top
- This is the command, used to display real-time information about system resources and processes.
Syntax:
```shelltop [options]
**Examples:**
1. **Display real-time system performance:**
```shell
top
This command runs top
in interactive mode, continuously updating and displaying information about system resources and processes.
Options and Modifiers:
The top
command has several options and modifiers that allow you to control its behaviour and customize the displayed information. Here are some commonly used options:
-b
(or--batch
): Runtop
in batch mode.
- Example:
top -b
This command runs top
in batch mode, which is useful for scripting and non-interactive use.
-n
(or--number
): Specify the number of iterations to be performed when running in batch mode.- Example:
top -b -n 5
This command runs
top
in batch mode for 5 iterations and then exits.-c
(or--command
): Show the full command line used to start each process.- Example:
top -c
This command displays the full command lines of processes, which can be helpful for identifying specific programs.
-d
(or--delay
): Specify the update interval when running in interactive mode.- Example:
top -d 5
This command runs
top
in interactive mode with a 5-second update interval.-h
(or--help
): Display help information for thetop
command.- Example:
top -h
This command displays the help message for
top
and its available options.-p
(or--pid
): Monitor only a specific process ID.- Example:
top -p 1234
This command monitors the process with the ID 1234.
-u
(or--user
): Monitor processes for a specific user.- Example:
top -u username
This command displays processes associated with the specified user.
These options and modifiers provide flexibility in how you use the top
command to monitor and analyze system resource usage and processes.
21. free - Displays the system memory usage:
The free
command in Linux is used to display information about the system’s memory usage, including both physical RAM and swap space. It provides details about the total available memory, used memory, free memory, and memory used for various purposes such as buffers and cache.
- Command Name:
free
- This is the command, used to retrieve and display memory usage information.
Syntax:
The free
command does not require any options, modifiers, or arguments. You can simply run it as follows:
free
Example:
Running free
without any options will display memory usage information in the default format.
$ free
total used free shared buff/cache available
Mem: 2048336 522812 1138708 105188 387816 1319416
Swap: 1048572 11240 1037332
Options and Modifiers:
The free
command typically does not require options, as it provides memory usage information by default. However, you can use options to customize the output or display the information in a different format. Here are some common options:
-b
(or--bytes
): Display memory usage in bytes.- Example:
free -b
This command displays memory usage in bytes instead of the default kilobytes.
- Example:
-k
(or--kilo
): Display memory usage in kilobytes (default).- Example:
free -k
This is the default behaviour of the
free
command and displays memory usage in kilobytes.-m
(or--mega
): Display memory usage in megabytes.- Example:
free -m
This command displays memory usage in megabytes.
-g
(or--giga
): Display memory usage in gigabytes.
- Example:
free -g
This command displays memory usage in gigabytes.
-t
(or--total
): Display a total line that shows the sum of memory and swap.- Example:
free -t
This command includes a total line in the output.
These options allow you to specify the units in which you want to display memory usage or add additional summary information to the output.
22. ps - display information about current processes:
The ps
command in Linux is used to display information about currently running processes. It provides details about the processes running on the system, including their process IDs (PIDs), parent process IDs (PPIDs), CPU usage, memory usage, and more.
- Command Name:
ps
- This is the command, used to retrieve and display information about running processes.
Syntax:
The ps
command does not require any options or arguments by default. You can run it as follows to display information about processes associated with your current terminal session:
ps
Examples:
- Display basic information about processes associated with the current terminal session:
$ ps
PID TTY TIME CMD
12345 pts/0 00:00:01 shell
23456 pts/0 00:00:00 ps
This command displays a list of processes running in the current terminal session, including their PIDs, TTY (terminal), execution time, and command (CMD).
- Display detailed information about all processes on the system:
$ ps aux
This command displays detailed information about all running processes on the system, including user, CPU usage, memory usage, and more.
Options and Modifiers:
The ps
command supports various options and modifiers that allow you to customize its output and filter processes. Here are some common options:
-a
(or--all
): Display information for all processes, not just the processes associated with the current terminal session.
ps -a
-e
(or--everyone
): Alias for-a
. It shows information for all processes.
ps -e
-f
(or--full
): Display full information for each process, including additional details like UID, PPID, C, STIME, TTY, and TIME.
ps -f
-u
(or--user
): Display information for processes of a specific user. Replace<username>
with the actual username.
ps -u <username>
-x
(or--no-headers
): Show information for processes not attached to a terminal. This option is useful for viewing all processes.
ps -x
-A
(or--forest
): Show the process hierarchy as a tree-like structure.
ps -A
-C
(or--deselect
): Show only the command name (process name), not the entire command line.
ps -C
-j
(or--jobs
): Show information in a job control format, which includes process group IDs (PGID) and session IDs (SID).
ps -j
These options allow you to customize the output of the ps
command based on your specific requirements and filter processes by various criteria.
23. jobs - Display information about current jobs:
The jobs
command in Linux is used to manage and display information about jobs running in the background within a terminal session. Jobs are processes that are started in the background, allowing you to continue working within the terminal while they execute. The jobs
command provides a way to list and control these background jobs.
- Command Name:
jobs
- This is the command, used to list and manage background jobs within a terminal session.
Syntax:
The jobs
command does not require any options or arguments. You can simply run it within an active terminal session:
jobs
Examples:
- Display a list of background jobs in the current terminal session:
$ jobs
[1] + Running command1 &
[2] - Stopped command2
[3] + Running command3 &
This output provides information about each background job, including its status, job number, and command.
- Bring a background job to the foreground:
$ fg %1
This command brings the job with job number 1 (in this case, command1
) to the foreground, allowing you to interact with it directly.
- Stop a background job:
$ kill %2
This command stops the job with job number 2 (in this case, command2
).
Options and Modifiers:
The jobs
command does not have many options or modifiers. It primarily displays information about background jobs. However, the interaction with jobs (e.g., bringing them to the foreground or stopping them) is typically done using the fg
and kill
commands along with the job number or job name.
While jobs
itself doesn’t have many options, it is used in conjunction with other commands like fg
and kill
to manage background jobs effectively.
fg
: Brings a background job to the foreground. Usefg %<job_number>
to specify the job number.kill
: Terminates a job. Usekill %<job_number>
to specify the job number.
These commands allow you to interact with and manage background jobs within the terminal session.
24. lspci – list all the PCI (Peripheral Component Interconnect) devices
The lspci
command is a Linux command used to list all the PCI (Peripheral Component Interconnect) devices connected to your computer. PCI devices include hardware components like graphics cards, network adapters, sound cards, USB controllers, and more. This command provides information about these devices, such as their names, vendors, device IDs, and more.
Here is the breakdown of the command:
-
Command:
lspci
-
Options:
-
-v
or--verbose
: This option provides more detailed information about the PCI devices, including driver details and IRQ (Interrupt Request) assignments. -
-nn
: This option displays device and vendor IDs in numeric form, which can be useful for identifying devices accurately.
-
-
Example Usage:
-
Basic Usage:
lspci
This command will list all PCI devices without additional details.
-
Verbose Output:
lspci -v
This command will provide a more detailed list of PCI devices, including driver information.
-
Numeric IDs:
lspci -nn
This command will display device and vendor IDs in numeric form.
-
The output of the lspci
command will look something like this:
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
Each line represents a PCI device and provides information about its type, vendor, and more. The format typically includes:
- PCI Address: This includes the bus, device, and function numbers (e.g.,
00:02.0
). - Device Type: This describes the type of the PCI device (e.g., “VGA compatible controller,” “Audio device”).
- Vendor: The manufacturer or vendor of the device (e.g., “Intel Corporation”).
- Device: The specific name or model of the device (e.g., “Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller”).
- Revision: The revision or version of the device (e.g., “rev 06”).
The lspci
command is valuable for identifying the hardware components present in your computer, especially when you need to install or update drivers or troubleshoot hardware issues.
25. df - display disk usage:
The df
command in Linux is used to display information about disk space usage on mounted file systems. It provides details about the total disk space, used space, available space, and the percentage of space used on each file system.
Here’s the breakdown of the df
command:
- Command Name:
df
- This is the command, used to display disk space usage information.
Syntax:
The basic syntax of the df
command is as follows:
df [options] [file_system]
[options]
: These are optional flags that you can use to customize the output.[file_system]
: This is an optional argument that allows you to specify a particular file system to display information about. If not provided,df
will display information for all mounted file systems.
Examples:
- Display disk space usage for all mounted file systems:
df
This command will display information about all mounted file systems, including their total size, used space, available space, and mount points.
- Display disk space usage in human-readable format:
df -h
Adding the -h
option makes the output human-readable, showing sizes in gigabytes, megabytes, or kilobytes as appropriate.
- Display disk space usage for a specific file system:
df /dev/sda1
This command displays disk space information specifically for the file system mounted at /dev/sda1
.
- Display disk space usage in a specific block size:
df -B 1M
This command displays sizes in megabytes (1M), which is useful when you want to control the display format of the sizes.
Options and Modifiers:
The df
command has several options that allow you to customize its output:
-a
or--all
: Include file systems that have a type of “dummy.”-B
or--block-size
: Specify the block size for displaying sizes (e.g.,1K
,1M
,1G
).-h
or--human-readable
: Display sizes in human-readable format.-i
or--inodes
: Display information about inodes (file and directory entries) instead of disk space.-k
or--kilobytes
: Display sizes in kilobytes.-l
or--local
: Show only information about local file systems.-T
or--print-type
: Display the type of the file system.-x
or--exclude-type
: Exclude file systems of the specified type.
These options can be used in various combinations to customize the df
output according to your preferences and requirements.
26. du - display disk usage of files and directories:
The du
command in Linux is used to display disk space usage information for directories. It calculates and shows the disk space used by each specified directory and its subdirectories. It’s a useful tool for checking which directories or files are consuming the most disk space.
- Command Name:
du
- This is the command, used to display disk space usage information.
Syntax:
The basic syntax of the du
command is as follows:
du [options] [directory]
[options]
: These are optional flags that you can use to customize the output.[directory]
: This is an optional argument that allows you to specify the directory for which you want to display disk space usage. If not provided,du
will start from the current directory.
Examples:
- Display disk space usage for a specific directory:
du /home/user
This command will display the space used by the /home/user
directory and all its subdirectories.
- Display disk space usage in human-readable format:
du -h /path/to/directory
Adding the -h
option makes the output human-readable, showing sizes in gigabytes, megabytes, or kilobytes as appropriate.
- Display a summary of total space used:
du -sh /path/to/directory
The -s
option summarizes the total space used, and the -h
option makes it human-readable.
- Display disk space usage for the current directory:
du
When no directory is specified, du
starts from the current directory.
Options and Modifiers:
The du
command has several options and modifiers that allow you to customize its output:
-a
or--all
: Display information for all files and directories, not just directories.-B
or--block-size
: Specify the block size for displaying sizes (e.g.,1K
,1M
,1G
).-c
or--total
: Display a grand total at the end of the output.-d
or--max-depth
: Display information only for files and directories up to a specified depth.-h
or--human-readable
: Display sizes in human-readable format.-k
or--kilobytes
: Display sizes in kilobytes.-L
or--dereference
: Follow symbolic links.-s
or--summarize
: Display only a summary of the total size.
These options can be used in various combinations to customize the du
output according to your preferences and requirements. For example, you can display human-readable sizes, include all files (not just directories), and show a grand total at the end of the output using options like du -ach
.
27. man - display manual pages:
The man
command in Linux is a powerful tool for accessing and reading manual pages (documentation) for various commands, utilities, and system calls. Let’s break down its components, syntax, options, and provide examples:
- Command Name:
man
- This is the primary command used to display manual pages.
Syntax:
The man
command has a simple syntax:
man [options] [command]
options
: Optional. These are various options that can modify the behaviour of theman
command.command
: Required. This is the name of the command or topic for which you want to view the manual page.
Examples:
- Viewing the Manual Page for a Command:
To view the manual page for a specific command, simply use the man
command followed by the command’s name. For example, to view the manual page for the ls
command:
man ls
This command will display the manual page for ls
, which contains detailed information about how to use the ls
command, its options, and examples of usage.
- Navigating Through the Manual Page:
Once you’re in the manual page viewer, you can navigate through it using the following keys:
Space
: Scroll forward by one screen.Enter
: Scroll forward by one line.B
: Scroll backward by one screen.Y
: Scroll backward by one line.Q
: Quit and exit the manual page viewer.
Options and Modifiers:
The man
command provides several options and modifiers to customize your interaction with manual pages:
-
-k
or--apropos
: Search for a keyword or topic across all manual pages and display a list of relevant manual pages. Example:man -k search_term
-
-f
or--whatis
: Display a brief description of a command without showing the full manual page. Example:man -f ls
-
-l
or--local-file
: View the manual page for a specific file. Example:man -l /path/to/some_file
-
-S
or--sections
: Specify the section(s) of the manual page to search. Manual pages are divided into sections, and this option allows you to choose which section to read. Example:man 3 printf
This command will display the
printf
manual page from section 3, which typically covers C library functions.
Manual Page Sections:
The manual pages are organized into sections, each covering a specific category of documentation. The most common sections are:
NAME
: A brief description of the command and what it does.SYNOPSIS
: A summary of how to use the command, including options and arguments.DESCRIPTION
: A detailed explanation of what the command does and how to use it.OPTIONS
: A list of options that can be used with the command.EXAMPLES
: Examples of how to use the command in real-life scenarios.SEE ALSO
: References to related commands or topics.
By specifying the section number, you can access the relevant documentation. For example, man 2 open
will display information about the open
system call, typically found in section 2 of the manual pages.
The man
command is an indispensable tool for accessing detailed information about Linux commands and system functions, making it easier to use and understand the various features and capabilities of the Linux operating system.
Conclusion:
In this section, you’ve ventured into the realm of system information, uncovering a treasure trove of commands that provide insights into your system. From the fundamental uname
command that displays system information to top
, which offers a comprehensive view of system resources and processes, you’ve gained essential skills for monitoring and managing your Debian environment.
With commands like free
, ps
, jobs
, lspci
, df
, du
, and man
, you’ve broadened your CLI toolkit, enabling you to delve deeper into system memory usage, process management, hardware information, and manual page access.
As you continue your journey through this comprehensive guide, you’ll find yourself well-prepared for the next section, “System Administration.” Here, you will explore advanced commands and techniques for configuring, securing, and maintaining your system.
By mastering these Linux CLI essentials, you’re not only becoming a proficient user but also gaining valuable skills that can empower you in various IT roles and endeavours. Stay engaged, keep exploring, and embrace the power of the CLI as you advance to the next section of this guide.
Leave a comment