top ad article

Linux is without doubt the most powerful and widely used operating system in the server and Desktop space. Whether you’re a true Linux beginner or an advanced user navigating recent changes, there are common Linux commands helpful in querying information about the system. In our guides to follow we’ll cover how to master basic operations of Linux and tackling more advanced system administration tasks.

Let’s now look at the most basic Linux commands you’ll often use to check your system information.

1. Checking system date

To show the current date and time you’ll run:

$ date
Sat 30 Jan 2021 08:57:04 AM EAT

On a systemd Linux system you can also use timedatectl command:

$ timedatectl
               Local time: Sat 2021-01-30 08:57:44 EAT
           Universal time: Sat 2021-01-30 05:57:44 UTC
                 RTC time: Sat 2021-01-30 05:57:45
                Time zone: Africa/Nairobi (EAT, +0300)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no

2. Show System uptime

To show current system uptime use the command:

$ uptime
 08:58:33 up 11 min,  1 user,  load average: 0.00, 0.00, 0.00

More Pretty format:

$ uptime -p
up 11 minutes

To show currently logged in users and their active & idle times use:

$ w
 08:59:50 up 11 min,  1 user,  load average: 0.00, 0.00, 0.00
USER     TTY      FROM             [email protected]   IDLE   JCPU   PCPU WHAT
root     pts/0    41.80.97.239     08:56    3.00s  0.07s  0.00s w

The top command will also show system uptime.

$ top

3. Show Calendar

To show the month’s calendar, run:

$ cal
    January 2021
Su Mo Tu We Th Fr Sa
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

Pass the first three characters or whole month to see calendar for specific month.

$ cal -m Feb
   February 2021
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28

$ cal -m Dec
   December 2021
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

To show calendar for a whole year pass -y option:

$ cal -y 2021
$ cal -y 2022

4. Show who you’re logged in as

To see who you are logged in as to the system use the command:

$ whoami
root

5. Show Linux Kernel information

Print all kernel information:

$ uname -a
Linux debian10 4.19.0-10-cloud-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux

Only print the kernel name:

$ uname -s
Linux

Only print the kernel release:

$ uname -r
4.19.0-10-cloud-amd64

To print the machine hardware name use:

$ uname -m
x86_64

Print the operating system:

$ uname -o
GNU/Linux

6. Get CPU info

To get CPU details

$ cat /proc/cpuinfo

It has quite amount of information that can be filtered further to get particular detail.

Print CPU Cores and thread count:

$ cat /proc/cpuinfo | grep -c processor
1

$ cat /proc/cpuinfo | grep 'cpu cores'
cpu cores	: 1

Or with lscpu command:

$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
Address sizes:       40 bits physical, 48 bits virtual
CPU(s):              1
On-line CPU(s) list: 0
Thread(s) per core:  1
Core(s) per socket:  1
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               63
Model name:          Intel(R) Xeon(R) CPU E5-2650L v3 @ 1.80GHz
Stepping:            2
CPU MHz:             1797.917
...

You can also use nproc command:

$ nproc --all
1
$ echo "Threads/core: $(nproc --all)"
Threads/core: 1

Using dmidecode to get CPU information.

$ sudo dmidecode -t 4
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.4 present.

Handle 0x0401, DMI type 4, 32 bytes
Processor Information
	Socket Designation: CPU 1
	Type: Central Processor
	Family: Other
	Manufacturer: Bochs
	ID: F2 06 03 00 FF FB 8B 0F
	Version: Not Specified
	Voltage: Unknown
	External Clock: Unknown
	Max Speed: 2000 MHz
	Current Speed: 2000 MHz
	Status: Populated, Enabled
	Upgrade: Other
	L1 Cache Handle: Not Provided
	L2 Cache Handle: Not Provided
	L3 Cache Handle: Not Provided

7. Show disk & directory usage

Determine block devices:

$ lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    254:0    0   25G  0 disk
├─vda1 254:1    0   25G  0 part /
└─vda2 254:2    0    2M  0 part
vdb    254:16   0  466K  1 disk

Check partition disk usage:

$ df -hT /
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/vda1      ext4   25G  972M   23G   5% /

Get size of a directory:

$ du -sh /tmp/
32K	/tmp/

8. Get Memory information

Get full memory information:

$ cat /proc/meminfo

Human readable format of used and free memory:

$ free -h
              total        used        free      shared  buff/cache   available
Mem:          989Mi        41Mi       855Mi       2.0Mi        93Mi       830Mi
Swap:            0B          0B          0B

9. Show installed OS info

Cat /etc/os-release file contents.

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

10. Show all system mount points and options

To show all system mount points and mount options used run:

$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=498264k,nr_inodes=124566,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=101368k,mode=755)
/dev/vda1 on / type ext4 (rw,relatime,errors=remount-ro)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup2 on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime,nsdelegate)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
bpf on /sys/fs/bpf type bpf (rw,nosuid,nodev,noexec,relatime,mode=700)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,pagesize=2M)
mqueue on /dev/mqueue type mqueue (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=41,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=9166)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=101364k,mode=700)

Stay connected for more informative and educative general Linux administrative guides.

In the meantime check out other Linux articles available in our website.

Previous articleInstall Java / OpenJDK on MX Linux 19
Next articleTop Must Know Linux Keyboard Shortcuts

LEAVE A REPLY

Please enter your comment!
Please enter your name here