whoami, hostname, uname, ps & df
Know your system
Lesson 17 of 20 · 9 min · Module 5: Permissions and the system
Before you change a server, confirm where you are and how it is doing. A few short commands answer the basic questions.
Start this lesson →Free. No installation: you write and run the code in your browser, and it is checked automatically.
By the end, you’ll be able to…
- Confirm user and machine
- Inspect processes and disk space
- Read environment variables
The idea
whoami shows your user, hostname the computer’s name, and uname -a the system and kernel. ps aux lists running programs. df -h shows free disk space in readable units. echo $HOME prints an environment variable.
whoami
hostname
uname -a
df -h
01Confirm before you act
On a real job you may have several terminal windows connected to different servers. whoami and hostname take a second and prevent running a command on the wrong machine.
02Read the disk report
df -h lists each filesystem with its size, used and available space, and Use%. Above about 90 percent, programs may start failing to write files.
df -hFilesystem Size Used Avail Use% Mounted on
/dev/sda1 40G 36G 4.0G 91% /03Variables carry settings
$HOME, $USER, and $PATH are environment variables. echo $PATH shows where the shell looks for commands. env lists all of them.
Your turn
df -h into disk.txt in your home folder.What the checks look for
- Shows the user learner
- Shows the host name codetemper
- Saves the df -h report to disk.txt
Take this with you
A quick look at user, host, disk, and processes is the first step of any server check.
Go a little further
Run ps aux and find the processes for the web server nginx and the database postgres.