Read a sample: 1. Your Terminal Practice Environment
A terminal can look unforgiving when you are new to Linux. It presents a prompt, waits for you to type, and often answers in a few terse lines—or with no visible message at all. The good news is that you do not need to understand the whole operating system before you begin. You need a place to practice, an ordinary user account, and a few habits that make your actions deliberate.
In this chapter, you will prepare that workspace and learn how to check a command before using it. The examples are intentionally modest: you will identify your current user and location, create a practice directory, and read help. These foundations will make the process-management exercises later in the book easier to follow and safer to repeat.
You can work through this book on a Linux computer, in a Linux virtual machine, or in a compatible Linux environment provided through another operating system. A virtual machine is a useful choice if you want a separate practice system: it runs Linux as a guest operating system on your existing computer. If you are using a shared computer or a remote server, make sure you have permission to practice there and follow the administrator’s rules.
A desktop installation usually provides a terminal application through its application menu. Open it, and you should see a window containing text and a prompt. On a server, you may reach a text-based login or connect through a remote terminal session instead. The appearance can vary considerably, but the basic interaction is the same: the shell displays a prompt, you enter a command, and the shell attempts to run it.
For the exercises, use an ordinary user account rather than logging in as the administrator account, traditionally named root. An ordinary account can inspect and manage many of its own activities while being restricted from changing protected parts of the system. Those restrictions are helpful guardrails, not an obstacle to learning.
You may encounter instructions elsewhere that begin with sudo. That command requests elevated privileges when the system is configured to allow them. You do not need it for the practice in this chapter. Later, if a command reports a permission problem, do not automatically add sudo and try again. First ask what the command is intended to do, which resource it targets, and whether you have authorization to act on it.
The terminal is the window or connection through which you type. The shell is the program that reads your commands and starts other programs. Many Linux systems use Bash for interactive work, although other shells are available.
A prompt might look something like this:
text
morgan@practice:~$
In this example, morgan is the user name, practice is the computer name, and ~ represents the user’s home directory. The dollar sign commonly marks a prompt for an ordinary user. The exact text, colors, and symbols are configurable, so your prompt may look different.
You may also see a prompt ending in #, which commonly indicates a root shell. Prompt symbols are not a reliable identity check on their own, however; they can be customized. To check the account associated with your current session, enter:
bash
whoami
Press Enter after the command. On the example system, the result might be:
text
morgan
Throughout this book, command examples show what you should type, without a leading prompt. Output appears separately when it is useful. Do not type the example user name or computer name unless an exercise specifically asks you to; your system will have its own values.
If whoami reports root, switch to an ordinary account before continuing. In a managed environment, ask the administrator how to obtain an appropriate practice account. If you deliberately opened an elevated shell, leave it according to your system’s instructions and verify your identity again in the ordinary shell.
The shell is ready for another command when its prompt returns. Some commands finish almost immediately. Others keep running or wait for input. Later chapters explore how to recognize and control those situations; for now, allow each command to finish before entering the next one.
A shell has a current working directory: the location it uses as the starting point for many file operations. Display yours with:
bash
pwd
The name stands for “print working directory.” You might see:
text
/home/morgan
Your result will probably contain a different user name or a different path. A path beginning with / describes a location from the root of the filesystem. The filesystem root, written as /, is a location; it is not the same thing as the root user account.
Now list the names in your current directory:
bash
ls
You might see familiar directories, such as Documents or Downloads, or you might see no output. An empty display does not necessarily mean something went wrong: it can simply mean there are no visible entries to list.
Commands and names in Linux are generally case-sensitive. Type pwd, not PWD, and pay attention to capitalization in directory names. Spaces also matter because the shell uses them to separate parts of a command. If you receive an error, compare what you typed with the example before assuming the system is broken.
To return to your home directory at any time, use:
bash
cd
The cd command changes the shell’s working directory. On success it normally prints nothing. Run pwd again to see where you are. That small…