Access the Command Line

Dennis Kibbe

Mesa Community College

Module Outline

  • Access the Command Line
  • Graded Quiz
  • Access the Command Line with the Desktop
  • Guided Exercise
  • Execute Commands with the Bash Shell
  • Graded Quiz
  • Correct Errors Entering Commands
  • Module Summary
  • Resources
  • Graded Lab

Learning Objectives

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

  1. Log into the GNOME Desktop and run commands in a Bash shell.
  2. Log into a text-based host and enter commands.
  3. Use Bash shell features to save time entering commands.
  4. Correct common mistakes when entering commands.

Access the Command Line

Introduction

3D illustration showing layered shapes labeled as Shell, Kernel, and Utilities.

The GNOME Terminal Program

A computer terminal with a user prompt on a dark desktop environment.

The GNOME Terminal Menu

A Linux terminal window showing a menu and command prompt.

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:
        

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 ~]$
        

Log Out Using Secure Shell


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

The Lab Environment

List of active server instances with action buttons and auto options.

Graded Quiz

Access the Command Line

Access the Command Line with the Desktop

A dark-themed computer desktop with a menu bar, search bar, empty window, and application dock.

Logout and Reboot the System

Desktop interface with top menu and bottom taskbar showing various icons.

Guided Exercise

Access the Command Line with the Desktop

Execute Commands with the Bourne Again SHell

Basic Command Syntax


[student@workstation ~]$ ls -l .ssh
total 20
-rw------- 1 student student 726 Sep 21  authorized_keys
-rw------- 1 student student 173 Mar 27  config
-rw------- 1 student student 846 Jul  6  known_hosts
-rw------- 1 student student 464 Jan  3  lab_rsa
-rw------- 1 student student 97  Jan  3  lab_rsa.pub
[student@workstation ~]$
      

Understand Tab Completion


[student@workstation ~]$ cd D
Desktop/ Documents/ Downloads/
[student@workstation ~]$ cd Do
Documents/ Downloads/
[student@workstation ~]$ cd Documents/
[student@Documents ~]$
      

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
      

Display the Command History


[student@workstation ~]$ history
    1 ls -l .ssh
    2 ls -a
    3 cd Documents/
    4 echo "Hello World"
    5 cd ~/
[student@workstation ~]$
      

Graded Quiz

Execute Commands with the Bash Shell

Correct Errors Entering Commands

Spaces in File Names


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

No Such File or Directory


[student@workstation ~]$ ls file.txt
ls: cannot access 'file.txt': No such file or directory
[student@workstation ~]$
       

Incomplete Commands


[student@workstation ~]$ mkdir
mkdir: missing operand
Try 'mkdir --help' for more information.
[student@workstation ~]$
       

Unfinished Commands


[student@workstation ~]$ echo "Hello World
> "
Hello World
      

Unresponsive Commands


[student@workstation ~]$ echo "Hello World" > hello.txt
[student@workstation ~]$ cat
^C
[student@workstation ~]$
      

🛠️ Module Summary

Access the Command Line

  • The Bash shell is the standard command interpreter on most Linux systems.
  • Many commands have a --help option.
  • Using the GNOME Desktop you can have multiple Workspaces to organize tasks.
  • The Activities button shows an overview of open windows and applications.
  • The file command is used to identify a file's type.
  • The head and tail commands display the first 10 lines or the last 10 lines of a file.
  • Tab completion automatically completes commands, options, and file or directory names.
  • To conserve system resources most Linux servers only have a text interface.
  • 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

Mesa Community College logo