Lesson  in  Linux for SRE / DevOps - Beginner Level

The Terminal Is the Only GUI You Get

on Linux
Shell basics, running commands, reading a command's own usage output, and why the terminal is the entire interface on a real server.

There is no desktop here. No file manager, no settings menu, nothing to click with a mouse. Almost every real Linux server you will ever be given access to looks exactly like this: a black screen and a blinking cursor, waiting for you to type. This first lesson is about getting comfortable with that.

pwd: where am I

The very first thing to check on any new session is where the shell dropped you:

pwd
/home/laborant

pwd stands for "print working directory" - it prints the one folder you're currently "inside," out of the entire filesystem. Every relative path you type from here is measured from this location, which is why it's worth checking first, before it matters.

Finding your way around with no map

Three things will help you on any unfamiliar computer, for the rest of your career:

  • Tab - start typing a command or path and press Tab. The shell finishes it for you, or - if there's more than one match - shows you every option so you can keep typing to narrow it down. Try typing ls /ho and pressing Tab: it completes to ls /home/.
  • The up arrow - cycles backward through your command history, most recent first. Press it repeatedly to step further back. You almost never have to retype a long command you ran a minute ago.
  • man <command> - opens the manual page for that command. man ls explains every flag ls accepts, one at a time, with examples. Press q to leave it and return to your prompt.

A command you don't recognize will often tell you how to use it if you just run it plainly, with no arguments. Someone on your team left a tool on this box. Find out what it does:

oncall-tool
Usage: oncall-tool --ack    (acknowledge the on-call handoff)

That's the entire skill in one line: an unfamiliar command told you exactly what flag it wants, you just had to run it and read the output. Now use it the way it just told you to:

oncall-tool --ack
Acknowledged. On-call handoff logged.
I ran it and nothing happened

Running oncall-tool with no arguments prints a usage line - it doesn't acknowledge anything by itself. Read that line carefully - it names the exact flag to pass.

Environment variables, briefly

Your shell keeps a set of named values, called environment variables - $PATH is the most important one. It's the list of folders the shell searches through, in order, when you type a command name, looking for a matching program to run - oncall-tool only worked above because whoever set up this box put it in one of those folders. See the current list with:

echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Each folder is separated by a :. When you type a bare command name like ls, the shell checks /usr/local/sbin first, then /usr/local/bin, and so on down the list, stopping at the first match. That's also exactly why "command not found" happens: the program exists somewhere on disk, but not in any folder $PATH lists.

You can set your own variables with export NAME=value. Once you export a variable, every command you run afterward, in that same session, can see it - try export GREETING=hi then echo $GREETING in the same terminal. To make a variable available every time you log in, add an export line to the file ~/.bashrc - that file automatically runs at the start of every new interactive shell session, so anything you export there becomes permanent for that user.