CIS126RH | RHEL System Administration 1
Mesa Community College
Access systems via console, graphical, and remote methods
What the shell is, how it interprets commands, and bash basics
Understand username, hostname, directory, and privilege indicators
Execute commands with options and arguments
The shell is a command-line interpreter that provides a user interface to the Linux operating system. It reads your commands, interprets them, and asks the kernel to execute them.
Text-based · Powerful and flexible
Scriptable · Works over remote connections
Low resource usage
Visual interface · Easier for beginners
Limited automation · Requires graphics
Higher resource usage
Bash (Bourne Again SHell) is the default shell in RHEL. It is an enhanced version of the original Unix Bourne shell, combining features from C shell, Korn shell, and others.
# Check your current shell
[user@host ~]$ echo $SHELL
/bin/bash
# See available shells on the system
[user@host ~]$ cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
# Check bash version
[user@host ~]$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
$SHELL variable shows your default login shell. /etc/shells lists every shell available on the system.
| Method | Description | When to Use |
|---|---|---|
| Console | Physical terminal or virtual console (Ctrl+Alt+F1–F6) | Direct hardware access, troubleshooting |
| Graphical | Desktop environment (GNOME) login screen | Workstations, desktop use |
| SSH | Secure Shell remote connection | Remote server administration |
| Terminal Emulator | GUI application providing shell access | Shell access within graphical session |
# SSH login to remote system
[user@local ~]$ ssh user@server.example.com
user@server.example.com's password:
Last login: Mon Jan 15 10:30:00 2024 from 192.168.1.100
[user@server ~]$
# After successful login:
# - Shell environment is initialized
# - You are placed in your home directory
# - Shell prompt appears, ready for commands
# Log out when done
[student@server ~]$ exit
# Or press Ctrl+D (sends end-of-file signal)
# Switch between virtual consoles
# Ctrl+Alt+F2 through F6 — different consoles
# Ctrl+Alt+F1 (or F2) — return to graphical desktop
The shell prompt tells you important information: who you are, what system you are on, where you are, and what privileges you have.
[student@server ~]$
│ │ │ │
│ │ │ └── $ = regular user (# = root)
│ │ └──── ~ = home directory (/home/student)
│ └────────── server = hostname
└────────────────── student = username
# Regular user prompt
[student@server ~]$
# Root user prompt (note # instead of $)
[root@server ~]#
# In a different directory
[student@server Documents]$
# Full path might show instead of ~
[student@server /var/log]$
# prompt means you have root (administrator) privileges. Be extra careful — root can do anything, including accidentally destroying the system.
Linux commands follow a consistent structure: the command name, followed by options that modify behavior, followed by arguments that specify what to act on.
$ command [-options] [arguments]
│ │ │
│ │ └── What to act on (files, directories, etc.)
│ └────────────── How to do it (modify behavior)
└───────────────────────── What to do (the program to run)
# Command only
[user@host ~]$ date
Mon Jan 15 10:30:00 EST 2024
# Command with option
[user@host ~]$ date -u
Mon Jan 15 15:30:00 UTC 2024
# Command with argument
[user@host ~]$ echo Hello
Hello
# Command with option and argument
[user@host ~]$ ls -l /home
drwx------. 3 student student 4096 Jan 15 10:00 student
# Multiple options combined
[user@host ~]$ ls -la /home
total 12
drwxr-xr-x. 3 root root 24 Jan 15 09:00 .
dr-xr-xr-x. 18 root root 4096 Jan 15 09:00 ..
drwx------. 15 student student 4096 Jan 15 10:00 student
date works alone. Some commands require arguments — cp needs source and destination.
# Short options: single dash, single letter
[user@host ~]$ ls -l
[user@host ~]$ ls -a
[user@host ~]$ ls -la # Combined short options
[user@host ~]$ ls -l -a # Same as above
# Long options: double dash, full word
[user@host ~]$ ls --all
[user@host ~]$ ls --human-readable
[user@host ~]$ ls -l --all # Mix short and long
# Options with values
[user@host ~]$ head -n 5 file.txt # Short: space or no space
[user@host ~]$ head --lines=5 file.txt # Long: use = sign
| Short | Long | Description |
|---|---|---|
| -a | --all | Show all (including hidden files) |
| -l | (none) | Long listing format |
| -h | --human-readable | Human-readable sizes (KB, MB) |
| -r | --reverse | Reverse sort order |
--human-readable is clearer than -h. In daily use, short options are faster to type. Check man COMMAND for all available options.
# Display current date and time
[user@host ~]$ date
Mon Jan 15 10:30:00 EST 2024
# Show who you are logged in as
[user@host ~]$ whoami
student
# Display system hostname
[user@host ~]$ hostname
server.example.com
# Print working directory (where you are)
[user@host ~]$ pwd
/home/student
# Display text
[user@host ~]$ echo "Hello, World!"
Hello, World!
# Clear the terminal screen
[user@host ~]$ clear
# Or use Ctrl+L — same effect, faster
# Display a file's contents
[user@host ~]$ cat /etc/hostname
server.example.com
# Who is logged into the system
[user@host ~]$ who
student tty1 2024-01-15 09:00
root pts/0 2024-01-15 09:30 (192.168.1.100)
# Detailed user and group IDs
[user@host ~]$ id
uid=1000(student) gid=1000(student) groups=1000(student),10(wheel)
# System information
[user@host ~]$ uname -a
Linux server 5.14.0-362.el9.x86_64 #1 SMP x86_64 GNU/Linux
wheel group in id output is significant — membership grants sudo privileges in RHEL.
# How long the system has been running
[user@host ~]$ uptime
10:30:00 up 5 days, 3:15, 2 users, load average: 0.15, 0.10, 0.08
# Current calendar
[user@host ~]$ cal
January 2024
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
...
# Specific month and year
[user@host ~]$ cal 12 2024
# Basic listing
[user@host ~]$ ls
Desktop Documents Downloads Music Pictures Videos
# Long format with details
[user@host ~]$ ls -l
drwxr-xr-x. 2 student student 4096 Jan 15 09:00 Desktop
drwxr-xr-x. 2 student student 4096 Jan 15 09:00 Documents
-rw-r--r--. 1 student student 123 Jan 15 10:00 notes.txt
# List a specific directory
[user@host ~]$ ls -l /var/log
# Show hidden files (start with .)
[user@host ~]$ ls -a
. .. .bash_history .bashrc Desktop Documents ...
# Human-readable sizes
[user@host ~]$ ls -lh
-rw-r--r--. 1 student student 4.5K Jan 15 10:00 file.txt
-rw-r--r--. 1 student student 2.1M Jan 15 10:00 image.jpg
# Combine all three
[user@host ~]$ ls -lah
.) are hidden by default. Use -a to see them. These are typically configuration files like .bashrc.
# Display entire file
[user@host ~]$ cat /etc/hostname
server.example.com
# Display multiple files in sequence
[user@host ~]$ cat file1.txt file2.txt
# Show line numbers
[user@host ~]$ cat -n /etc/passwd
1 root:x:0:0:root:/root:/bin/bash
2 bin:x:1:1:bin:/bin:/sbin/nologin
...
cat on a large file floods your terminal. Use head, tail, or less for large files.
# Show first 10 lines (default)
[user@host ~]$ head /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
...
# Show first 5 lines
[user@host ~]$ head -n 5 /etc/passwd
# Show last 10 lines
[user@host ~]$ tail /var/log/messages
# Follow file in real-time (great for logs)
[user@host ~]$ tail -f /var/log/messages
# Press Ctrl+C to stop following
tail -f is essential for watching log files in real time — you see new lines appear as events happen.
Bash remembers commands you have typed. Use history to recall and reuse previous commands — a huge time saver.
# Use Up/Down arrows to scroll through history
# Press Up arrow repeatedly to go back through commands
# View command history
[user@host ~]$ history
1 date
2 whoami
3 ls -la
4 cat /etc/hostname
5 history
# Run command by number
[user@host ~]$ !3
ls -la
# Run last command again
[user@host ~]$ !!
# Run most recent command starting with cat
[user@host ~]$ !cat
# Reverse search: Ctrl+R, then type
(reverse-i-search)`cat': cat /etc/hostname
# Press Ctrl+R again to find older matches
# Press Enter to run, or arrow keys to edit first
Ctrl+R and start typing any part of a past command. Bash searches your entire history backward for matching commands instantly.
Tab completion is your best friend. Press Tab to automatically complete commands, file names, and paths. It saves typing and prevents typos.
# Type partial command, press Tab
[user@host ~]$ hostTab
hostname
# Type partial filename, press Tab
[user@host ~]$ cat /etc/hostTab
cat /etc/hostname
# Multiple matches: Tab Tab shows options
[user@host ~]$ cat /etc/passTabTab
passwd passwd-
# Complete directory paths
[user@host ~]$ ls /var/loTab
ls /var/log/
# Works for commands, files, directories, and more
[user@host ~]$ ls /var/log/messTab
ls /var/log/messages
| Shortcut | Action |
|---|---|
| Ctrl+C | Cancel current command / interrupt running process |
| Ctrl+D | Log out (send EOF — end of file) |
| Ctrl+L | Clear screen (same as clear command) |
| Ctrl+A | Move cursor to beginning of line |
| Ctrl+E | Move cursor to end of line |
| Shortcut | Action |
|---|---|
| Ctrl+U | Delete from cursor to beginning of line |
| Ctrl+K | Delete from cursor to end of line |
| Ctrl+W | Delete word before cursor |
| Ctrl+R | Search command history (reverse search) |
| Ctrl+Z | Suspend current process (send to background) |
# Ctrl+C example: stop a running command
[user@host ~]$ tail -f /var/log/messages
(log output streaming...)
^C
[user@host ~]$
# Run commands sequentially with semicolon
[user@host ~]$ date; whoami; pwd
Mon Jan 15 10:30:00 EST 2024
student
/home/student
# Run second command only if first succeeds (&&)
[user@host ~]$ cd /tmp && ls
(lists /tmp contents)
# Run second command only if first fails (||)
[user@host ~]$ cd /nonexistent || echo "Directory not found"
bash: cd: /nonexistent: No such file or directory
Directory not found
# Continue command on next line with backslash
[user@host ~]$ echo "This is a very long command that \
> continues on the next line"
This is a very long command that continues on the next line
; — runs both commands regardless of success&& — runs second only if first succeeds|| — runs second only if first fails
man (manual) pages are the built-in documentation for Linux commands. Every command should have a man page explaining its usage, options, and examples.
# Read the manual for a command
[user@host ~]$ man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory
by default).
...
# Navigation in man pages (uses the less pager):
# Space or Page Down — next page
# b or Page Up — previous page
# /pattern — search for pattern
# n — next search result
# q — quit
# Man pages are in sections; specify section when needed
[user@host ~]$ man ls # Section 1: user commands
[user@host ~]$ man 5 passwd # Section 5: file formats
[user@host ~]$ man 8 useradd # Section 8: admin commands
/ to search within the page.
# Quick help — most commands support --help
[user@host ~]$ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs...
-a, --all do not ignore entries starting with .
-l use a long listing format
...
# Whatis — one-line description
[user@host ~]$ whatis ls
ls (1) - list directory contents
--help is shorter than a man page — good for a quick reminder of options. Some commands use -h instead.
# Apropos — search for commands by keyword
[user@host ~]$ apropos directory
cd (1) - change working directory
ls (1) - list directory contents
mkdir (1) - make directories
pwd (1) - print name of current working directory
rmdir (1) - remove empty directories
...
# Info pages (more detailed than man for some commands)
[user@host ~]$ info ls
apropos KEYWORD. It searches all man page descriptions for that keyword.
Logging In: Access via console, graphical, SSH, or terminal emulator. Password never displays. Use exit or Ctrl+D to log out.
The Shell: Bash is the command interpreter. It reads commands, executes them, and displays results.
The Prompt: [user@host dir]$ shows username, hostname, directory. $ = user, # = root.
Commands: Structure is command [-options] [arguments]. Use Tab completion, history, and man pages.
date, whoami, hostname, pwd, idls with various options: -l, -a, -la, -lh/etc directorydate, ls, and cat