Skip to content
VLSI Mentor

Linux & Bash · Part I · Module 1 · Linux, the Shell and the Command Line

Your First Session: Where You Are, Who You Are, Which Machine

Three chapters of model-building are enough. This one puts you in a session and establishes the habit that experienced engineers perform without thinking: on any machine you are not certain about, find out where you are, who you are and which machine this is before doing anything that changes something. Three commands answer those questions. The rest of the chapter is about the prompt — the text you will look at more than any other, and the one thing in your session that is configurable text rather than a fixed part of the interface.

Foundation12 min readLinuxBashPart IFundamentalsOrientation

Part I · Module 1 · Chapter 1.4 · Your First Session

1. Three Questions, Asked in Order

You have just connected to a machine. Before running anything that creates, deletes or submits work, three facts are worth knowing, and all three are one command each.

  1. Where am I? Which directory is this session sitting in. Commands that take a filename interpret it relative to this directory, so the answer changes what your next command means.
  2. Who am I? Which user account this session belongs to. Everything you are permitted to read, write and run follows from this.
  3. Which machine is this? Which host you are actually typing into. In an environment with a login server, a dozen compute servers and a laptop, this is not a rhetorical question.

The commands are pwd, whoami and hostname. Each is worth understanding rather than memorising.

2. Where Am I: pwd

Azvya Education Pvt. Ltd.VLSI Mentor
Snippet
pwd
Azvya Education Pvt. Ltd.VLSI Mentor
Representative output
/home/engineer

pwd stands for print working directory. Every process on a Linux system has a working directory — one directory it is currently positioned in — and a shell is a process like any other. pwd reports the shell's.

The output begins with /, which is the top of the single filesystem tree from Chapter 1.1. A path starting at / names exactly one place with no ambiguity, no matter where you happen to be standing. Module 2 covers paths properly, including the shorter, relative kind that depend on where you are.

Why this is the first question and not a formality: a working directory is what gives a short filename its meaning. cat notes.txt means a different file in two different directories, and rm -r build means a different directory. The working directory is the silent first half of most commands you will type.

3. Who Am I: whoami

Azvya Education Pvt. Ltd.VLSI Mentor
Snippet
whoami
Azvya Education Pvt. Ltd.VLSI Mentor
Representative output
engineer

whoami prints the user name this session is acting as. That single word determines:

  • which files you may read, write and execute (Module 5);
  • which directory is your home directory, and therefore where your own files and settings live;
  • what you are allowed to install, start and stop;
  • whose name appears against any job you submit on a shared machine.

It is a short command with a specific purpose: it answers who the system thinks you are, which is not always who you expected. You will meet machines where your login name differs from your usual one, shared accounts set up for a project, and sessions where a previous command changed user without you remembering.

A fuller answer is available when you need it:

Azvya Education Pvt. Ltd.VLSI Mentor
Snippet
id
Azvya Education Pvt. Ltd.VLSI Mentor
Representative output
uid=1001(engineer) gid=1001(engineer) groups=1001(engineer),2000(design),2001(verif)

id reports your numeric user id, your primary group, and every group you belong to. Groups are how shared project directories work — a directory can be readable by a group rather than by one person — and that is Module 5's subject. For now, one observation is enough: the system identifies you by a number, and the name is a convenience on top of it.

4. Which Machine: hostname

Azvya Education Pvt. Ltd.VLSI Mentor
Snippet
hostname
Azvya Education Pvt. Ltd.VLSI Mentor
Representative output
build-server-03

hostname prints the name the machine calls itself. On a single laptop this is unremarkable. In an engineering environment it is one of the most useful commands available, because a typical setup has:

  • a laptop or workstation you sit at;
  • one or more login servers you connect to, intended for editing, browsing and submitting work;
  • many compute servers where the heavy work actually runs.

Those machines look identical through a terminal. The same shell, the same prompt style, often the same home directory mounted from the same file server. The only reliable way to know which one you are on is to ask.

Azvya Education Pvt. Ltd.VLSI Mentor
Snippet
uname -n
Azvya Education Pvt. Ltd.VLSI Mentor
Representative output — same answer, different command
build-server-03

uname -n reports the same name through the command from Chapter 1.1, and is worth knowing because hostname is a separate program that is occasionally absent on minimal systems while uname is almost always present.

5. Reading the Prompt

You will look at the prompt more than at any other text on the machine, so it is worth reading deliberately once.

A widely used default looks like this:

Azvya Education Pvt. Ltd.VLSI Mentor
A common default prompt — yours may differ completely
engineer@build-server-03:~$

Four pieces, left to right:

PieceMeaning
engineerthe user name — the same answer whoami gives
@build-server-03the host name — the same answer hostname gives
:~the working directory, with ~ standing for your home directory
$by convention, "ready for your command" for an ordinary user

So a default prompt of this shape has already answered all three of §1's questions. That is exactly why it was designed that way, and why experienced engineers glance at it constantly.

Two details repay attention.

The ~ is an abbreviation, not a directory name. ~ is how the shell writes "your home directory" so a long path does not fill the line. When you are in a subdirectory, a common prompt shows ~/work/notes while pwd reports /home/engineer/work/notes. Both are correct; one is abbreviated.

$ versus # is a convention. A # traditionally indicates the superuser account, root, which can change anything on the machine. It is a strong hint and widely followed — but it is a configured character, not a security boundary. The real answer to "am I root?" comes from whoami or id.

6. A Complete Orientation, Once Through

Here is the whole routine as one session, which is how it actually looks in practice.

Azvya Education Pvt. Ltd.VLSI Mentor
Representative session — a full orientation
engineer@login-01:~$ hostname
login-01
engineer@login-01:~$ whoami
engineer
engineer@login-01:~$ pwd
/home/engineer
engineer@login-01:~$ ls
projects  scripts  notes.txt
engineer@login-01:~$

Reading that session line by line, in the vocabulary of Chapter 1.3:

  • hostname → login-01. This is a login machine, not a compute machine. Nothing heavy should start here.
  • whoami → engineer. The session is acting as the expected account, so permissions will behave as expected.
  • pwd → /home/engineer. The session is in the home directory, so any short filename in the next command refers to something here.
  • ls with no arguments lists the working directory. Three entries: two directories and a file. ls chose that output; the shell neither produced it nor formatted it.
  • The prompt returns. Each command finished and handed a status back, and the shell printed a new prompt — step 5 of Chapter 1.2's loop, four times.

Four commands, and the session is no longer unfamiliar. That is the whole technique.

7. When the Answers Surprise You

Three realistic surprises, each worth recognising on sight.

pwd reports somewhere you did not expect. Entirely normal: a session can start anywhere, and a setup script run at login may move you. Nothing is wrong. It does mean your next relative filename means something different from what you assumed, which is the actual risk.

whoami reports a name you do not recognise. Likely a shared project account, or an account an administrator created with a different convention. Confirm before writing anything, because files you create will belong to that account.

hostname reports a name that does not match your prompt. Believe hostname. Either the prompt is configured with a fixed string, or you have moved machines inside the session — a nested ssh does not have to change the prompt's appearance. This is a direct consequence of Chapter 1.3: the prompt is text printed by whichever shell is currently reading your line.

8. Check Your Understanding

Question 1. Your prompt shows ~/work and pwd prints /home/engineer/work. Are these inconsistent? Explain what each is showing.

Question 2. A prompt ends in #. Give two reasons that is not sufficient evidence that you are the superuser, and name the command that would settle it.

Question 3. You run ls and see nothing at all, with no error. Using Chapter 1.3's vocabulary, which component produced that silence, and what does it mean?

Question 4. You are about to start a six-hour job. Which of the three orientation questions is the one that prevents the most common mistake, and why?

Question 5. Your prompt reads engineer@login-01 but hostname prints compute-07. Which do you believe, and what are the two most likely explanations?

9. Remember

  • Three questions orient you anywhere: where am I (pwd), who am I (whoami), which machine is this (hostname). Ask them before doing anything that changes something.
  • The working directory is the silent first half of most commands. A short filename means something different in a different directory.
  • Identity decides permission. whoami names the account; id adds the numeric id and group membership, which is how shared project directories work.
  • hostname distinguishes machines that look identical through a terminal — and prevents the classic mistake of running heavy work on a shared login server.
  • A common default prompt already answers all three questions: user, host, directory, and a readiness character.
  • ~ means your home directory. It is the shell's abbreviation, not a directory name.
  • The prompt is configurable text, not a system readout. Trust it as a convenience; ask the system when it matters.

You can now orient yourself and read a prompt. The next chapter takes the command lines themselves apart, so an unfamiliar one becomes something you can decompose rather than something you have to have seen before.

Where this fits

Part of the Linux & Bash curriculum.