Home › Linux command line: first steps › Step 2

Lesson 2: Essential Linux commands every admin needs

Step 2 of 5 in Linux command line: first steps · video 8:34

Can't see the video? Watch it on YouTube.

What you will learn

About this lesson

A tour of the small commands an administrator types every day on Red Hat Enterprise Linux. It revisits navigation with pwd and the forms of cd: an absolute path such as /usr/bin, cd or cd ~ for home, cd / for the root, cd .. for the parent and cd - to jump back to the previous directory. It then turns to sessions and identity: tty prints the terminal name, who reads /var/run/utmp to list logged-in users, w adds idle time and current activity, and uptime shows how long the system has run and the load averages over 1, 5 and 15 minutes. whoami prints the effective user, while logname still gives the original login name after su or sudo. id shows UID, GID, groups and the SELinux context, and groups lists primary and supplementary groups. The lesson closes with login history from last, lastb (failed attempts, root only) and lastlog, and system details from uname and its options.

Check yourself

Answer in your head first, then open each question to see the answer.

1. You moved from /etc/sysconfig to /var/log and need to go straight back. Which command does it?

cd -. The dash tells cd to return to the previous working directory, and running it again swaps back, so it toggles between the two locations.

2. You log in as alice and switch to root with sudo -i. What do whoami and logname print now?

whoami prints root, because it reports the effective user running the command. logname still prints alice, because it reports the user who originally logged in to the session.

3. uptime ends with three numbers such as 0.15, 0.30, 0.25. What do they mean?

They are the load averages: the average number of processes running or waiting to run over the last 1, 5 and 15 minutes. Comparing them shows whether load is rising or falling.

4. A colleague cannot write to a shared folder and you want to see their numeric UID and every group they belong to in one command. What do you run?

id username (or plain id for yourself). It prints the UID, the primary GID and all supplementary groups, which is what file permissions are checked against; groups username gives just the group names.

Go deeper

This lesson comes from the course below - with the full set of lessons, demonstrations and practice.

Administration of Red Hat Enterprise Linux

4.5★ · 10,209 students on Udemy

See the course on Udemy
← Lesson 1: ls, cd and mkdirNext: Lesson 3: Linux time - RTC versus the system clock →

Video lesson by Vitalii Shumylo. The summary and the questions on this page were written from the lesson with AI help and checked against its transcript.