This chapter defines the core tools and concepts needed to begin interacting with the Linux operating system using the command line.
1. Terminal vs. Shell
It is important to distinguish between the two primary interfaces you use:
- Terminal (or Terminal Emulator): The graphical application (like Gnome Terminal, iTerm, or PuTTY) that provides a window for input and output. It is the visual interface.
- Shell: The actual program running inside the Terminal that interprets your commands and interacts with the operating system kernel. Bash (Bourne Again SHell) is the most common shell in modern Linux distributions.
2. The Structure of a Command
A Linux command typically follows a consistent structure:
$$command \space [options] \space [arguments]$$
- Command: The program name you want to execute (e.g.,
ls,cd,mkdir). - Options (or Flags): Used to modify the behavior of the command. They usually start with a hyphen (
-) for short options or two hyphens (--) for long options. - Arguments: The data the command operates on (e.g., file names, directory paths).
Example Command Structure:
To list all files (-a) in long format (-l) in the /home directory (/home):
ls -l -a /home
3. Absolute vs. Relative Paths
When referencing files or directories, you must specify their location using a path.
Absolute Path
An absolute path starts from the root directory (/) and specifies the full location regardless of your current position.
- Starts with:
/ - Example:
/home/user/documents/file.txt
Relative Path
A relative path specifies a location relative to your current working directory.
- Starts with: A directory name,
.(current directory), or..(parent directory).
| Symbol | Meaning | Example Path |
. | The current directory. | ./images/logo.png |
.. | The parent directory (one level up). | ../backups/old.zip |
~ | The current user’s Home Directory. | ~/Desktop/notes.txt |
4. Getting Help
The man (manual) command is the primary way to get detailed documentation on almost any command.
Execution
To view the manual page for the ls command:
man ls
Tip: Press
qto exit the manual page viewer.
