10  System Info

In this chapter, we will explore commands that will allow us to

Command Description
uname Display important information about the system
free Display free, used, swap memory in the system
df Display file system disk space usage
exit Exit the terminal
sudo Run command as super user
shutdown Shutdown the system

10.1 uname

The uname command is used to view important information about the system. Using additional options, we can

  • print details about operating system
  • hardware & software related information
Command Description
uname Print details about the current machine and the operating system running on it
uname -mp Hardware related information; machine & processor
uname -srv Software related information; operating system, release number and version
uname -n Nodename of the system
uname -a Print all available information system

10.1.2 Display free, used, swap memory in the system

free
               total        used        free      shared  buff/cache   available
Mem:        16373448     1612504    10827812       49996     4337816    14760944
Swap:        3145724           0     3145724

10.1.3 Display file system disk space usage

df
Filesystem     1K-blocks     Used Available Use% Mounted on
/dev/root      151263856 62460532  88786940  42% /
tmpfs            8186724       84   8186640   1% /dev/shm
tmpfs            3274692     1020   3273672   1% /run
tmpfs               5120        0      5120   0% /run/lock
efivarfs          131072       32    131036   1% /sys/firmware/efi/efivars
/dev/sda16        901520    65012    773380   8% /boot
/dev/sda15        106832     6250    100582   6% /boot/efi
tmpfs            1637344       12   1637332   1% /run/user/1001

10.2 Others

In this section, let us look at a few other useful commands that will allow us to

  • see how long a command takes to execute
  • delay activity
  • display and clear command history list
Command Description
time See how long a command takes to execute
sleep Delay activity in seconds
sleep 1m Delay activity in minutes
sleep 1h Delay activity in hours
history Display command history list with line numbers
history -c Clear the command history list

10.3 Funny Commands

Below are a few funny commands for you to try out. Use sudo apt-get install to install fortune and banner before trying them.

Command Description
fortune Poignant, inspirational & silly phrases
yes Output a string repeatedly until killed
banner ASCII banner
rev Reverse each character

10.4 R Functions

In R, we can use Sys.sleep() to delay activity and history() to view command history.

Command R
sleep Sys.sleep()
history history()

10.5 Exercises

  1. Run uname -mp (hardware: machine and processor), uname -srv (software: OS, release, version), and uname -a (all information). State which option you used for each and what you observed.
  2. Run free and df without options. Describe in one sentence each what memory/swap details and disk-space details you observe. (Git Bash users: these commands are unavailable — run them in the Tier 0 Posit Cloud project instead.)
  3. Run time sleep 2 — the timing report should show about 2 seconds. Then run history and find those commands in the list with their line numbers. Do not run history -c for this exercise.