Photo by Christina @ wocintechchat.com on Unsplash

Have you ever wondered what your computer is doing underneath the surface? Beyond our browsers, chatbots and fancy UIs, our machines are quietly doing a ton of work to support our digital needs.

Today, we’ll investigate our operating system and find out what is going on with its software, hardware and network connections. First, let’s dig into the commands that will help us gather information about the server!

## Essential System Commands

Without further ado, here are some commands that you can use to extract system information from the server. (Note: some of these commands can only be executed as root. So make sure you have your privileges configured correctly and Sudo when needed!)

### Operating system information

First, the basics. Let’s say you want to find out the version of the kernel that you are using. You can use the uname command for this.

uname -v

uname -r


The first command prints out the version, and the second just the release number. You can also check the Linux distribution version with these commands:

lsb_release -a
hostnamectl


## Hardware information

lshw stands for “List Hardware”. It is a command-line utility that allows users to gather hardware information of the machine. The command generates detailed reports about various hardware components such as the memory capabilities, CPU stats, cache configuration, and so on.

### Disk drive information

For example, to check for disk size and information about storage controllers on the system, you can use:

lshw -c disk


And to find information about the partitions and controllers of disks, you can use this command. This will give you a more detailed view of the memory system.

lshw -c volume


Alternatively, you can use fdisk to achieve the same results. This command will list the partition tables of a hard disk.

fdisk -l


### Mount points

To find out information about mounted file systems, you can use these commands:

lsblk

df -h


The lsblk command lists the block devices of the system, and df reports the filesystem’s disk space usage. Read the man page for each command to learn more!

### Memory information

You can use this command to find information about the memory hardware:

lshw -c memory


And the free command to display the amount of free and used memory in the system.

free -h


### Processor information

Lastly, the lscpu command can be used to find information about the CPU of the machine:

lscpu


This will display full details about the processor of the system, including the CPU’s vendor, version and capabilities.

The lshw command can also be used:

lshw -c cpu


#### Process information

What if you wanted to find out more about specific system processes? For example, how do you find the PID of a process? Its current state? And its memory and processing power usage?

You can use the top command or the htop command to find the current processes on the system. You can also use the pgrep command to search for specific processes using their name. (The command will return the PIDs of all the matching processes. You can use the -l option to display the names of the matching processes as well.)

top

htop

pgrep -l "launch"


top and htop also display detailed process information. Alternatively, after you find out the PID of your target process, you can use the ps <PID> command to get more details.

ps 100


## Network information

To figure out the networking details of the server, you can use these few commands.

ifconfig is a useful command for acquiring networking information of the system. If run without arguments, it will display the status of the currently active network interfaces.

ifconfig -a


The above command shows the local IP address of the machine. Alternatively, you can use the ip command for this. For example, the command below also shows the local IP address:

ip addr


The route command displays the IP routing table. You can also use ip for the same results.

route

ip route


netstat prints the current network connections, routing tables, interface statistics, and more.

netstat


Lastly, the ss command is used to dump socket statistics. It shows similar information as netstat, but can display more TCP and state information than other tools.

ss


## Conclusion

Linux systems are full of built-in utilities that will help you discover more information about the machine. And remember, you can always check the man page of each of these commands to find more ways to use them.

If you are a system admin, a hacker, a programmer, or a student, take some time and dig into your operating system! You never know what interesting things you’ll learn. Have fun!