Leaving presentation mode.

Access the Command Line

Dennis Kibbe

Mesa Community College

Keyboard Shortcuts

This slide presentation was created by B6Plus. The audio accompanying this presentation is AI-generated.

Module Outline

Learning Objectives

After completing the work in this module you will be able to:

Access the Command Line

Introduction

relationship of the shell to the Linux kernel

Let's start by breaking down what happens when you interact with the Linux command line. This diagram illustrates the layered architecture of a Linux system.

At the center, we have the kernel— this is the core of the operating system. It manages your computer's hardware resources, such as memory, CPU time, and devices. You don’t interact with the kernel directly as a user, but it handles everything behind the scenes to make sure the system runs smoothly.

Surrounding the kernel is the shell, such as the Bash shell. The shell is your interface to the kernel. When you type a command, the shell interprets it and passes it to the kernel to execute. Think of the shell as your personal translator between human-readable commands and the lower-level instructions understood by the kernel.

Finally, we have the utilities— these are the commands and programs you use to get things done. For example, ls lists files, cp copies files, and top monitors system performance. These utilities run in user space and rely on the shell to invoke system services provided by the kernel.

So, when you type a command, it flows from the utility, through the shell, and down to the kernel, which does the actual work. Then the result flows back up to you, often in the form of text output on your screen.

This layered approach gives Linux its flexibility and power. As you learn more commands and scripting, you'll see how these layers interact in more depth.

The GNOME Terminal Program

Now that we’ve seen how the shell fits into the Linux system, let’s take a look at how we actually interact with it on a desktop environment—using the GNOME Terminal.

GNOME Terminal is a terminal emulator—a graphical application that gives us access to the shell, typically the Bash shell, from our desktop.

When you open GNOME Terminal, you’ll see a blinking cursor next to a line of text. This is the shell prompt. It’s where you type commands.

Let’s break down a typical Bash prompt you might see:

megan@localhost:~$

This prompt is Bash’s way of saying, “I’m ready for your next command.”

As we move forward, we’ll practice entering basic commands like ls, pwd, and cd—right at this prompt. Each one will give us a different kind of response from the system.

The GNOME Terminal Menu

Let’s now look at how we can customize the GNOME Terminal to make it easier to read and more comfortable to use.

First, open the GNOME Terminal. At the top of the terminal window, locate the menu. Depending on your desktop environment, you may see a three-line menu icon (☰) in the top-right corner or you may need to right-click inside the terminal window.

From the menu, choose Preferences. This opens the terminal settings.

Inside Preferences, you’ll see a list of profiles on the left. Click on the one labeled Unnamed or whatever profile is active.

To Adjust the Font Size:

To Change the Theme (Dark or Light):

Changing these settings does not affect how the shell works—it simply makes the environment more comfortable for you as a user.

Once you're done, just close the Preferences tab. Your new settings are saved automatically.

Log in Using the Text Console

Red Hat Enterprise Linux 9.1 Beta (plow)
Kernel 5.14.0-70.13.1.el9_0.x86_64 on an x86_64

Activate the web console with: systemctl enable --now cockpit

utility login: megan
Password:
        

Here we see a classic text-based login prompt, which you’ll encounter when logging into a Linux system without a graphical interface—like on a server or a virtual console.

The system begins by asking for a username. You type your username and press Enter.

Next, it asks for your password. This is where many new users get confused: when you type your password, you won’t see anything on the screen—not even asterisks.

This behavior is normal and intentional. It's a security feature to prevent anyone nearby from guessing your password length or characters just by watching your screen.

Even though you don’t see anything, your keystrokes are being registered. Just type your password carefully and press Enter.

If the username and password are correct, the system will log you in and present a shell prompt, usually something like this:

[megan@localhost ~]$

If you make a mistake, the system will tell you that authentication failed, and you’ll be asked to try again.

Log in Using Secure Shell

[student@workstation ~]$ ssh student@servera
Warning: Permanently added 'servera' (ED25519) to know hosts.
Activate web console with: systemctl enable --now cockpit.socket

Register system with Red Hat Insights: insights-client --register
View all your systems at https://red.ht/insights-dashboard
[student@servera ~]$
        

This slide shows what it looks like when you log into a remote Linux system using SSH, which stands for Secure Shell.

In this course, you will use SSH to connect to two remote lab systemsservera and serverb. These systems are set up for hands-on exercises, and most of your lab work will be done on them.

The typical SSH command looks like this:

ssh megan@servera

After you run this command, you’ll be prompted for your password. Just like with a local login, no characters will appear as you type the password. This is normal—it’s a security feature.

Once authenticated, you’ll be logged into the remote system and presented with a Bash shell prompt—ready to enter commands and start your lab work.

You will use this same SSH method to connect to both servera and serverb, depending on the instructions for each lab.

Please get comfortable with this process early on—it’s an essential skill for working with remote Linux systems in the real world."

Log Out Using Secure Shell

[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$
        

To log out of a remote system when using Secure Shell, simply type exit or press Ctrl+D in the GNOME Terminal. This closes the SSH session and returns you to your local machine's command prompt. Always remember to log out properly to help maintain system security and free up resources on the remote host.

The Lab Environment

The Lab Environment lets you open a console for servera or serverb to log in without using a network connection. Think of the console as a backdoor to fix network connection issues. When you have completed a lab and submitted the screenshot it is a best practice to delete the current Lab Environment. Be sure to watch the video on the Lab Environment page.

Graded Quiz

Access the Command Line

Complete this graded quiz in Canvas.

Access the Command Line with the Desktop

Most of the time in this course you will access a remote host using a terminal program on the GNOME Desktop.

GNOME Desktop Terminal Program

If you don't see the terminal icon at the bottom of the screen click the Activities button at the left end of the taskbar and type terminal then press Enter to start the terminal application.

Logout and Reboot the System

Let's take a moment to review how to properly log out of your user session or reboot the system when you're finished working in the GNOME desktop environment. These are essential actions to understand, whether you're on a lab machine, a personal system, or a shared workstation.

Accessing the System Menu

Logging Out

Rebooting (Restarting) the System

Guided Exercise

Access the Command Line with the Desktop

Lab Notes

Step 2.2: In the Terminal window that opens, type passwd at the shell prompt. Change the student password from student to 55TurnK3y. Unlike a graphical interface typing a password at a terminal does not display any characters.

In this exercise, you log in through the graphical display manager as a regular user to become familiar with the GNOME Standard desktop environment. Be sure to check the assignment in Canvas for any lab notes before starting the assignment.

Execute Commands with the Bourne Again SHell

The Bash or Bourne Again Shell is based on the shell created by Stephen R. Bourne and is the default command interpreter used by most Linux distributions.

Basic Command Syntax

The Linux command line—also called the terminal or shell—is a powerful tool for interacting with your system. Understanding its basic syntax will help you use Linux more effectively and efficiently.

What is a Command?

A command is a text-based instruction you type into the shell to tell the computer what to do. Commands are executed by the Bash shell in most Linux systems.

Basic Structure of a Command

command [options] [arguments]
      

Examples

ls -l /home/student

cp file1.txt file2.txt

Tips for Beginners

Why This Matters

The command line gives you more control, faster access, and greater flexibility than the graphical interface. Many system administration tasks in Linux are only available through the command line.

In upcoming slides, we will explore commonly used commands. For now, remember this structure:

command → options → arguments

Modifying a Command with an Option

Options for commands start with a single dash and must be separated from the command by a space. Here the -a option lists all the files in student's home directory including hidden files and directories which start with a period.

Adding an Argument to a Command

Adding a directory name as an argument to the ls command lists files in the hidden .ssh directory. The -l option lists the files in a long format which includes additional information such as permissions, ownership, file size, and modification or creation date.

Understand Tab Completion

This slide demonstrates how tab completion works in the Bash shell to speed up navigation and reduce typing errors.

The student begins by typing:

cd D

Then they press the Tab key. Nothing happens since multiple directory names begin with 'D'—namely Desktop/, Documents/, and Downloads/— pressing the Tab key a second time Bash displays the possible completions.

Next, the student types:

cd Do

and presses Tab again nothing happens. Pressing the Tab key a second time now narrows the options down to just Documents/ and Downloads/.

Finally, they type:

cd Doc

and press Tab key once and the shell completes the command since there is only one possible completion. Of course, in every day use you only need to type as many characters as are unique to the selection you want.

This shows how tab completion helps users:

Tab completion works not only with directories, but also with commands, filenames, and script names. It's an essential skill for working efficiently at the command line.

A Long Command on Multiple Lines

Command as shown in lab instructions

$ ln /home/student/files/target.file \
/home/student/links/file.hardlink
      

Enter command on one line without the backslash

$ ln ~/files/target.file ~/links/file.hardlink
      

Some lab instructions include the \ (backslash) character at the end of a line. This indicates that the command continues on the next line. While you can type the backslash and then press Enter I suggest replacing the backslash with a space and continue typing the remainder of the command on the same line. Note that commands you type are in a bold typeface in the instructions.

The tilde (~) is a Linux "shortcut" to denote a user's home directory. Thus tilde slash (~/) is the beginning of a path to a file or directory below the user's home directory. -TWiki. I use it here for the same reason the textbook uses the backslash to prevent the clong command from running off the edge of the slide.

Display the Command History

The history command displays a list of commands you’ve previously typed in the terminal. This is part of the Bash shell’s command history feature, which helps you recall, review, and reuse past commands without retyping them. It is helpful for correcting mistakes, re-running complex commands, and documenting your work.

Basic Usage

Type history and press Enter. You'll see a numbered list of recent commands, typically up to the last 500 or 1,000.

Example Output

101  ls -l /home/student
102  cd /var/log
103  cat syslog
      

Each command is assigned a history number, which you can use to re-execute it.

Recalling Commands

Searching History

Practical Tips

Security Reminder

Be careful with commands that include passwords or sensitive data—they are saved in ~/.bash_history by default.

You can clear your session’s history with:

history -c

The history command is more than a log—it’s a tool for productivity, accuracy, and troubleshooting. Encourage students to use it often to reinforce what they've learned.

Edit the command Line

Graded Quiz

Execute Commands with the Bash Shell

The Bash shell keeps a list of the commands you run. You can re-run any command in the list by typing an exclamation point which is called a bang in UNIX speak followed by the number of the command. For example, to run the ls Desktop command again type an exclamation point followed by 4.

Correct Errors Entering Commands

The shell can be unforgiving and you will make mistakes. Recognizing errors and knowing how to deal with common errors will accelerate your mastery of the Bash shell.

Spaces in File Names

[student@servera ~]$ touch Module 1 Outline
[student@servera ~]$ ls Module 1 Outline
1        Module   Outline
      

When working on the command line spaces in file names can present problems. In this example touch Module 1 Outline creates not one file but three files.

Replace Spaces in File Names

[student@servera ~]$ touch Module-1-Outline
[student@servera ~]$ ls Module-1-Outline
Module-1-Outline
      

Replace spaces with a dash or underscore or use Camel Case. If you need to deal with an existing file name which contains spaces surround the file name with quotes. See this article for help.

No Such File or Directory

Terminal window showing an error message for a missing file.

This error message means exactly what it says. The ls command could not list the file you asked for.

Troubleshoot "No Such File or Directory"

Terminal window showing command errors and folder listings.

When you get this error check the prompt to see if you are in the directory where the file was created, then run the ls command to see if the file was misspelled or is capitalized differently. You can often avoid this error by using Tab Completion wherever possible to automatically complete file names.

Incomplete Commands

If the command you typed is missing a required option or argument the shell will return a short help message or, sometimes, the complete manual page for the command. In this example the mkdir command requires a directory name as an argument.

Unfinished Commands

The Bash shell knows that this command is not finished and opens a subshell so you can complete the command by adding the missing close quote.

Troubleshoot Unfinished Commands

In this example, typng the missing trailing quote and then pressing Enter finishes the command so the shell can run it.

Unresponsive Commands

Some commands will simply hang if not entered correctly. Here the cat command was entered without the required file name and blocks any further access to the command prompt. Hint: Use the more or less commands to avoid this issue.

Troubleshoot Unresponsive Commands

Press Ctrl plus c to interrupt the command and return the shell prompt.

Complete this graded quiz in Canvas.

Module Summary

Access the Command Line

  1. The Bash shell is the standard command interpreter on most Linux systems.
  2. Many commands have a --help option.
  3. Using the GNOME Desktop you can have multiple Workspaces to organize tasks.
  4. The Activities button shows an overview of open windows and applications.
  5. The file command is used to identify a file's type.
  6. The head and tail commands display the first 10 lines or the last 10 lines of a file.
  7. Tab completion automatically completes commands, options, and file or directory names.
  8. To conserve system resources most Linux servers only have a text interface.
  9. A backslash \ (backslash) at the end of a line means that the command continues on the next line.

Resources

Graded Lab

Access the Command Line

Lab Notes

Be sure to run lab grade cli-review and grab a screenshot of the output before running lab finish cli-review.

Thanks for Watching

Thanks for watching. This is the end of the presentation.

Created on 17 February 2025 by Dennis Kibbe. Last modified on 9 June 2025 09:21:00 by DNK.