How to list all recently logged in users on your Linux system. And other useful Linux tricks.

Posted: January 31, 2015. At: 12:30 AM. This was 3 years ago. Post ID: 8031

The sudo lastb command will list all recently logged in users on your Linux system. This is a useful tool on a server.

[email protected]:~$ sudo lastb
jason    :0           :0               Thu Jan  8 12:41 - 12:41  (00:00)    
jason    :0           :0               Mon Jan  5 11:42 - 11:42  (00:00)    
jason    :0           :0               Mon Jan  5 11:42 - 11:42  (00:00)    
 
btmp begins Mon Jan  5 11:42:03 2015

The lastlog command will list all of the users on your system, and will show the last login time if they have logged in before.

List free space on the / partition. Use the df -Hla / command to show the available space on the partition.

[email protected]:~$ df -Hla /
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb3       235G   76G  160G  33% /

How to list just the space taken up by a directory and it`s contents. Use the du -ackh DIRNAME | tail -n 1 command.

[email protected]:~$ du -ackh Desktop/ | tail -n 1
118M	total

This will show the amount of space that the directory contents take up on the disk.

How to list all installed CPU`s in your Linux machine. Use the lscpu command to list all hardware CPU`s installed in your Linux machine.

[email protected]:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 37
Model name:            Intel(R) Core(TM) i3 CPU         530  @ 2.93GHz
Stepping:              2
CPU MHz:               1197.000
CPU max MHz:           2926.0000
CPU min MHz:           1197.0000
BogoMIPS:              5866.27
Virtualisation:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              4096K
NUMA node0 CPU(s):     0-3

Use printf in bash.

[email protected]:~$ printf '%s %s\n' "Hello" $LOGNAME
Hello jason

How to get the temperature of your hard disk drive with the Linux command line.

The hddtemp command will display the temperature of a hard disk drive as long as it has a supported temperature sensor.

[email protected]:~$ sudo hddtemp /dev/sdb
/dev/sdb: ST3500418AS: 33°C

Also use the sensors command to read the temperatures of your hardware with the Linux command line. This is how to view the temperature of your video card under Linux.

[email protected]:~$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +47.0°C  (high = +89.0°C, crit = +105.0°C)
Core 2:       +45.0°C  (high = +89.0°C, crit = +105.0°C)
 
radeon-pci-0100
Adapter: PCI adapter
temp1:        +35.5°C  (crit = +120.0°C, hyst = +90.0°C)
1 responses to “How to list all recently logged in users on your Linux system. And other useful Linux tricks.

Nice tips, thanks. Note that you don’t have to pipe the output of du to tail just to get the total size. du has proper arguments for this and you can achieve the same using du -csxh /tmp/ 2>/dev/null

Thanks again.

Leave a Reply