Skip to content

Instantly share code, notes, and snippets.

@mehdihasan
Created April 18, 2020 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdihasan/75c3d465ce18d28a9dea31d6a469fc44 to your computer and use it in GitHub Desktop.
Save mehdihasan/75c3d465ce18d28a9dea31d6a469fc44 to your computer and use it in GitHub Desktop.
Basic Linux commands

Displaying Basic System Information on Linux Shell

uname

Output:

Result of uname command

uname -s

Output:

Kernel name displayed with uname command

Get the Linux Kernel Release

$ uname -r

Output:

Get Linux Kernel release information

Get the Linux Kernel Version

uname -v

Output:

Linux Kernel version

Get Network Node Hostname

uname -n

more user-friendly:

uname --nodename

Get system hostname

Both commands will display the same above output. Please note that the hostname and the node name might not be the same for non-Linux systems. Get Machine Hardware Architecture (i386, x86_64, etc.)

uname --m

Output:

Get Linux architecture x86_64

The output x86_64 signifies that I am using a 64-bit architecture. The output i686 means that a user is on a 32-bit system. Get Processor Type

In order to know the type of processor you are using, please use the following command:

$ uname -p

Output:

Get Linux processor type

This output shows that I am using a 64-bit processor. Get Hardware Platform

In order to know the hardware platform you are using, please use the following command:

$ uname -i

Output:

Get hardware platform information

In my case, the output is the same as that of the machine hardware name. Get Operating System information

The following command will let you know the name of the operating system you are using:

$ uname -o

Output:

Linux Operating System information

My Ubuntu machine has displayed the above output for my system. Displaying All Information of Uname Command

The above commands have displayed system information as per the type of switch used. In case, you want to see all the system information at once, use the following command:

$ uname -a

Output:

uname -a result

You can see that the above output shows the complete list of system information for the user. Displaying Detailed Hardware Information

Here we will describe the commands, other than uname, that are used to extract detailed hardware information of your system: Get Hardware Information with lshw

The lshw utility enables you to fetch important hardware information such as memory, CPU, disks, etc. from your system. Please run the following command as a super user in order to view this information:

$ sudo lshw

Output:

Output of lshw command

The above output is a very detailed version of the hardware information of my system. You can also view a summary of hardware information as described in the following section. Short Summary

In order to view the summary of your detailed hardware profile, please use the following command:

$ lshw -short

Output:

Short summary of lshw hardware report

The above output is a column-wise summary of the hardware profile which is more readable. Creating an HTML File

The lshw utility also lets you print your hardware profile to an HTML file as a superuser. Use the following command for this purpose:

$ sudo lshw -html > [filename.html]

Example:

$ sudo lshw -html > hardwareinfo.html

Output:

Hardware report in HTML format

The above HTML file has been created at the /home/user/ folder. Get CPU Information with lscpu

The lscpu utility lists detailed CPU information from the files sysfs and /proc/cpuinfo to your screen. This is how you can use this command:

$ lscpu

Output:

CPU details shown with lscpu

The above output displays CPU architecture, number of CPUs, cores, CPU family model, threads, CPU caches and much more. Get Block Device Information with lsblk

The lsblk utility displays information about all the basic storage devices of your system such as hard drive, its partitions and the flash drives connected to your system.

$ lsblk

You can use the following command to view much more detailed information about all the devices:

$ lsblk -a

Output:

lsblk result Get USB Device Information with lsusb

The lsusb lists information about all the USB controllers and the devices connected to them. Please run the following command:

$ lsusb

You can also use the following command to view much detailed information about each USB device.

$ lsusb -v

Output:

Details about the USB devices

This output displays all the USB controllers and the attached devices. Get Information About Other Devices

You can also view information about the following devices of your system:

PCI devices

Command: $ lspci

SCSI devices

Command: $ lsscsi

SATA devices

Command:

$ hdparm [devicelocation] e.g. $ hdparm /dev/sda2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment