9  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

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

9.1.2 Display free, used, swap memory in the system

free
               total        used        free      shared  buff/cache   available
Mem:        16367520     1600380    12379704       50856     2770308    14767140
Swap:        3145724           0     3145724

9.1.3 Display file system disk space usage

df
Filesystem      1K-blocks     Used Available Use% Mounted on
/dev/root       151263856 62900308  88347164  42% /
tmpfs             8183760       84   8183676   1% /dev/shm
tmpfs             3273504     1024   3272480   1% /run
tmpfs                5120        0      5120   0% /run/lock
efivarfs           131072       32    131036   1% /sys/firmware/efi/efivars
/dev/nvme0n1p16    901520    86444    751948  11% /boot
/dev/nvme0n1p15    106832     6250    100582   6% /boot/efi
tmpfs             1636752       12   1636740   1% /run/user/1001

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

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

9.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()

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

Worked solutions in solutions/sysinfo.md (attempt first).