Skip to content

Beginner · Linux and the shell · topic 3 of 57 · 30 min

Shell basics and getting help

Explanation

The shell is the program that reads what you type and runs it; on RHEL it is bash. A command line has a command, options (starting with - or --) and arguments. When you forget something, man, --help and man -k answer you without the internet.

What is the shell?

A terminal is the window where you type. The shell is the program inside it that reads your line, works out what you mean and runs it. RHEL uses bash (the Bourne Again SHell) by default. The prompt tells you who and where you are:

output
[asha@web01 ~]$     <- user asha, host web01, in the home directory (~), $ = normal user
[root@web01 log]#    <- user root, in a directory named log, # = root (admin)
A # at the end of the prompt means you are root. Be extra careful there.

The shape of a command

Most commands follow one pattern: command, then options, then arguments. An option changes how the command behaves. Short options are one dash and one letter (-l), and you can combine them (-la). Long options use two dashes and a word (--all). An argument is what the command works on, usually a file or directory.

bash
$ ls -l --human-readable /var/log/messages
-rw-------. 1 root root 1.2M Oct 19 10:15 /var/log/messages
ls is the command, -l and --human-readable are options, /var/log/messages is the argument.

Keys that save hours

  • Tab: completes command and file names. Press it twice to see all choices. It also stops typing mistakes.
  • Up arrow: brings back earlier commands. history lists them; !42 runs number 42 again.
  • Ctrl+R: search back through your history. Type part of an old command.
  • Ctrl+C: stop the running command. Ctrl+L or clear: clean the screen.
  • Ctrl+A / Ctrl+E: jump to the start / end of the line.

Getting help without Google

In an exam like RHCSA, and on many secure company servers, you have no internet. The help is already on the machine.

bash
$ ls --help | head -3
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

$ man ls          # full manual page; q quits, /word searches, n = next match
$ man 5 passwd    # section 5: the FORMAT of the /etc/passwd file
$ man -k partition
fdisk (8)            - manipulate disk partition table
parted (8)           - a partition manipulation program
...
--help gives a short summary. man gives the full manual. man -k searches the short descriptions of all pages.

Man pages are grouped in numbered sections. The ones you need most: 1 = user commands, 5 = file formats, 8 = admin commands. passwd(1) is the command; passwd(5) explains the file. If man -k finds nothing, the search index may be old; root can rebuild it with mandb.

Many packages also install examples and notes in /usr/share/doc. When you forget the exact syntax of a config file, look there and at the EXAMPLES part near the end of the man page.

Who am I, where am I?

bash
$ whoami
asha
$ id
uid=1000(asha) gid=1000(asha) groups=1000(asha),10(wheel)
$ hostname
web01.example.com
$ date
Mon Oct 19 10:20:31 IST 2026

Common mistakes

  • Forgetting the space: ls-l is not ls -l. The shell looks for a command named "ls-l".
  • Wrong case: LS and ls are different. Linux is case-sensitive everywhere.
  • Pasting commands from a website without reading them, especially ones with sudo or rm. Read every line first.
  • Working as root all day. Use a normal user and sudo only when needed.
Tip: Get used to man pages now. In the RHCSA exam, being able to find a forgotten option in man is often the difference between pass and fail.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Shell basics and getting help · 1/7

Terminal → shell (bash) → kernel

The shell reads what you type and runs it. On RHEL the shell is bash.

Prefer a video by a teacher? Find free videos on “bash shell basics man pages help linux beginners” on YouTube ↗

In real life: No internet in the data centre

An admin at a Mumbai stock-broking firm works on servers in a locked network with no internet, for security. He has to set a password expiry but does not remember the chage options. He runs man chage, types /expire to search, and finds -E in a few seconds. No phone, no browser needed.

bash
$ chage --help | grep -i expire
  -E, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -M, --maxdays MAX_DAYS        set maximum number of days before password change to MAX_DAYS

Practice (0/3 done)

Task 1 · Question

In "ls -l /etc", what is -l?

Task 2 · Question

You want to read about the FORMAT of the /etc/shadow file, not a command. Which is best?

Task 3 · Practice

Without using the internet, find: (a) the option of ls that sorts by file size, (b) a command that can create a new user, (c) which section of the manual covers admin commands.

Quick quiz

Question 1

1.What does a # at the end of the prompt usually mean?

Question 2

2.Which key completes a file name you have started typing?

Question 3

3.What does man -k firewall do?

Question 4

4.What is wrong with typing "ls-la"?

Question 5

5.Which shows a list of earlier commands?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

What does a # at the end of the prompt usually mean?

Answer: You are logged in as root

# marks the root user; $ marks a normal user.

Which key completes a file name you have started typing?

Answer: Tab

Tab completes names; twice shows all matches.

What does man -k firewall do?

Answer: Searches man page descriptions for "firewall"

man -k (same as apropos) searches the short descriptions of all man pages.

What is wrong with typing "ls-la"?

Answer: There must be a space between the command and its options

Without the space the shell looks for a command literally named ls-la.

Which shows a list of earlier commands?

Answer: history

history lists commands you ran; !N runs number N again.

Why write rm "$file" instead of rm $file?Related

Answer: A file name with spaces stays one argument

Unquoted variables are split on spaces.

From Bash scripts: variables, quoting, arguments and exit codes

Which command shows a module's options and examples without internet?Related

Answer: ansible-doc MODULE

ansible-doc.

From Ad-hoc commands and ansible-doc

Which command keeps showing new lines of a log file as they are written?Related

Answer: tail -f app.log

tail -f follows the file and prints new lines as they arrive.

From The Linux filesystem and everyday commands

Which output format should a shell script usually read?Related

Answer: json or text

Tables are formatted for people. JSON or text output is stable and easy for scripts to parse.

From The command line on all three clouds

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. 3 more topics in “Linux and the shell” before its exam: Working with files: ls, cp, mv, rm, links and find, Reading text: grep, less, pipes and redirection, Editing files with vim.
  2. Module 1 exam: Linux and the shell · 13 questions · 20 min, without help. 6 topics of this module still to finish first.
  3. Then the next module, Permissions, users and sudo. 57 topics left in the course before the final exam.

← Previous: The filesystem hierarchy and paths