Beginner · Linux and the shell · topic 3 of 57 · 30 min
Shell basics and getting help
Explanation
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:
[asha@web01 ~]$ <- user asha, host web01, in the home directory (~), $ = normal user
[root@web01 log]# <- user root, in a directory named log, # = root (admin)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.
$ ls -l --human-readable /var/log/messages
-rw-------. 1 root root 1.2M Oct 19 10:15 /var/log/messagesKeys 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.
$ 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
...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?
$ 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 2026Common 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.
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
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.
$ 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_DAYSPractice (0/3 done)
In "ls -l /etc", what is -l?
You want to read about the FORMAT of the /etc/shadow file, not a command. Which is best?
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Working with files: ls, cp, mv, rm, links and findLinux and the shell · same module
- Bash scripts: variables, quoting, arguments and exit codesAutomation basics: scheduling, archives and shell scripts
- Ad-hoc commands and ansible-docAnsible fundamentals
- The Linux filesystem and everyday commandsDevOps: Git, Docker, Kubernetes and CI/CD · Linux for DevOps
- The command line on all three cloudsCloud Computing (AWS, Azure, Google Cloud) · Google Cloud and comparing the clouds
- Linux basics for backend developersBackend Development · Deployment and scaling
Questions people ask about this
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
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.
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.
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
- 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.
- Module 1 exam: Linux and the shell · 13 questions · 20 min, without help. 6 topics of this module still to finish first.
- Then the next module, Permissions, users and sudo. 57 topics left in the course before the final exam.