Access a shell prompt and issue commands with correct syntax

Understand and Use Essential Tools

πŸ“˜Red Hat Certified System Administrator (RHCSA – EX200)


1. What is a Shell Prompt?

In Linux, the shell is a program that lets you interact with the operating system. Think of it as the interface where you type commands to make the system do tasks like:

  • List files
  • Copy or move files
  • Check system status

The shell prompt is where you type these commands. A typical shell prompt looks like:

[user@hostname ~]$
  • user – the username you are logged in as
  • hostname – the name of the system
  • ~ – your current directory (here it means your home directory)
  • $ – indicates a normal user (if it is #, it means root user)

Important: For RHCSA, you must be comfortable working both as a regular user and as root (administrator) using the shell.


2. Accessing a Shell Prompt

You can access a shell in several ways:

  1. Locally on the system:
    • Login to a Linux system via GUI and open Terminal.
    • The terminal opens a shell session.
  2. Remotely using SSH (Secure Shell):
    • Command to connect from another machine: ssh username@ip_address
    • Example: ssh alice@192.168.1.100
  3. Switching to root (administrative user):
    • Using su (switch user): su - Then enter the root password.
    • Or using sudo (execute commands as root): sudo command Example: sudo yum update

Tip: RHCSA exam often requires running commands with root privileges, so knowing su and sudo is essential.


3. Issuing Commands

3.1 Basic Command Structure

A Linux command typically has this format:

command [options] [arguments]
  • command – the program or utility you want to run (e.g., ls, cat)
  • options – modify the behavior of the command (e.g., -l, -a)
  • arguments – the target of the command (file, directory, user, etc.)

Example:

ls -l /etc
  • ls β†’ list files
  • -l β†’ show detailed info
  • /etc β†’ directory to list

3.2 Commonly Used Commands for the Exam

Here are essential commands you must know:

CommandPurposeExample
pwdPrint current directorypwd β†’ /home/alice
lsList filesls -l /var/log
cdChange directorycd /etc
catView file contentcat /etc/passwd
more / lessView large files page by pageless /var/log/messages
cpCopy filescp file1.txt /tmp/
mvMove or rename filesmv file1.txt file2.txt
rmRemove filesrm file1.txt
mkdirCreate a directorymkdir /tmp/testdir
rmdirRemove empty directoryrmdir /tmp/testdir
touchCreate an empty filetouch /tmp/file1
echoDisplay textecho "Hello"
manShow manual pageman ls
unameShow system infouname -a
whoamiShow current userwhoami

RHCSA Exam Tip: You need to type commands correctly. Even small mistakes in syntax (like missing a space) can cause failure.


3.3 Understanding Options and Arguments

  • Single-dash options (short options): ls -l
  • Double-dash options (long options): ls --human-readable

Remember: Many commands combine multiple options:

ls -la /etc

-l for long listing, -a to show hidden files


3.4 Command Execution Rules

  1. Commands are case-sensitive.
    • ls β‰  LS
  2. Commands must be typed in the correct order: command β†’ options β†’ arguments
  3. Use Tab completion to save time:
    • Start typing a filename or directory and press Tab to auto-complete
  4. Use Up/Down arrows to recall previous commands

4. Viewing Command Output and Errors

  • Normal output β†’ standard output (stdout)
  • Errors β†’ standard error (stderr)

Example:

ls /nonexistent

Output:

ls: cannot access '/nonexistent': No such file or directory
  • Use redirection to handle output: ls -l /etc > filelist.txt # Save output to a file ls /nonexistent 2> error.txt # Save error to a file

5. Using man and --help

  • Every command has a manual: man command
  • Or quick help: command --help

Example:

man cp
cp --help

This will show options and usage for the cp command. RHCSA often tests your ability to explore commands like this.


6. Best Practices for the Exam

  1. Always check your current directory with pwd.
  2. Verify files before removing with ls.
  3. Practice using sudo and root commands.
  4. Learn at least 15–20 essential commands fluently.
  5. Use Tab completion and man pages to avoid mistakes.
  6. Understand the difference between stdout and stderr.

βœ… Summary for the Exam

  • Know how to open a shell (locally and via SSH)
  • Know root vs regular user access (su and sudo)
  • Understand command syntax: command [options] [arguments]
  • Be fluent in basic Linux commands (ls, cd, cp, mv, rm, mkdir, cat, man)
  • Use options and arguments correctly
  • Handle output and errors with redirection
  • Use help (man and --help) to understand commands

This is the foundation for the rest of the RHCSA exam, because all tasks start with accessing the shell and running commands.

Buy Me a Coffee