Posted: . At: 12:30 AM. This was 9 years ago. Post ID: 8031
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


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


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

jason@eyjafjallajkull:~$ 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.

jason@eyjafjallajkull:~$ 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.

jason@eyjafjallajkull:~$ 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.

jason@eyjafjallajkull:~$ 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.

jason@eyjafjallajkull:~$ 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.

jason@eyjafjallajkull:~$ 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.

jason@eyjafjallajkull:~$ 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 thought on “How to list all recently logged in users on your Linux system. And other useful Linux tricks.”

  1. 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.

    Reply

Leave a Reply to RoseHosting Admin Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.