Day 3: System Registration, RHEL Lightspeed, Essential File Commands, and the Filesystem Hierarchy¶
Course: RHCSA Section: Core Command-Line Skills Topic: Registering RHEL with Red Hat, using the command-line assistant, managing files and directories, and understanding the Linux directory tree Audience: Linux beginners through RHCSA exam candidates
1. Topic Introduction¶
This section combines two foundations of everyday administration.
First, a RHEL system must be registered with Red Hat before it can install or update software from Red Hat repositories. Without registration, package installation fails, so registering is usually the first task on a new RHEL system.
Second, almost every administration task involves creating, reading, copying, moving, and deleting files and directories, and knowing where things live in the Linux filesystem hierarchy. These skills appear in every later topic.
The section also introduces RHEL Lightspeed command-line assistance, an AI-based helper available from the terminal on supported RHEL releases.
Where this is used in practice
- Registering a newly built server so it can receive updates and security patches.
- Creating directory structures for applications and projects.
- Inspecting log and configuration files.
- Safely copying, renaming, and removing files without damaging the system.
- Knowing which directory holds configuration, logs, temporary data, or user files.
2. Learning Objectives¶
After completing this section, you will be able to:
- Explain why a RHEL system must be registered and what registration provides.
- Register a system with
rhc connectand withsubscription-manager register, and verify the result. - Disconnect or unregister a system.
- Install and use the command-line assistant, and describe its limits and privacy considerations.
- Create files and directories with
touch,echo,cat,mkdir, andmkdir -p. - Explain the difference between
>and>>. - Read files with
cat,tac,more,less,head, andtail. - List directories with
lsand its common options, and navigate withcdandpwd. - Copy, move, rename, and remove files and directories safely.
- Describe the purpose of the major top-level directories in the Filesystem Hierarchy Standard.
3. Core Concepts¶
3.1 System registration¶
Definition: Registration connects a RHEL system to Red Hat's subscription service so Red Hat can verify that the system is entitled to receive Red Hat content.
Red Hat Subscription Management (RHSM) is the service that verifies entitlements, meaning the licenses and subscriptions associated with your account.
What registration provides
| Benefit | Explanation |
|---|---|
| Official software updates | Packages and errata from Red Hat |
| Repository access | The ability to install and update packages with dnf |
| Certified content | Red Hat-certified software and content |
| Security fixes | Security patches and bug fixes |
| Support | Technical support under your subscription terms |
Why it matters: On a system that has never been registered, dnf cannot reach Red Hat's repositories, so installing and updating Red Hat packages fails.
Common misunderstanding: Registration is not the same as installation. A RHEL system installs and boots without being registered, but it cannot obtain Red Hat packages until it is.
3.2 Two ways to register¶
| Method | Command | Notes |
|---|---|---|
Red Hat connector (rhc) |
rhc connect |
Recommended on newer releases. Available on RHEL 8.8 and later, including RHEL 9 and 10 |
| Subscription Manager | subscription-manager register |
The traditional method, available on all supported releases |
Prerequisites for rhc connect
- RHEL 8.8 or later.
- A valid Red Hat account with a usable subscription.
- Root privileges (log in as
rootor usesudo). - Internet access.
What rhc connect can enable in one step
| Feature | Purpose |
|---|---|
| Content | Access to Red Hat repositories for installs and updates |
| Analytics | Connects the system to Red Hat Insights for monitoring and proactive analysis |
| Remote management | Allows management from the Red Hat Hybrid Cloud Console |
3.3 RHEL Lightspeed command-line assistance¶
Definition: A command-line assistant that answers questions written in plain English and responds with Linux commands and explanations.
How it works: You ask a question in the terminal. The question is sent to a Red Hat service over the internet, and the answer is displayed in the terminal. Because it relies on that service, it requires internet access and a registered system.
Why it matters: It can speed up learning and reduce context switching, especially for beginners.
Important limits
- It is available only on supported RHEL releases. It is not available on other distributions such as Ubuntu.
- AI answers can be wrong or incomplete. Check commands against
manpages before running them, especially commands that change or delete data. - Do not include passwords, keys, personal data, or other secrets in a question.
Verify: The availability of the assistant, its package name, and the exact command may differ by RHEL release. Reports describe the underlying model as being from IBM's Granite family. Confirm details in Red Hat's current documentation. Whether you may use it during an exam depends on the exam rules, so do not depend on it. Rely on commands and manual pages you know.
3.4 Files, directories, and paths¶
- A file stores data.
- A directory holds files and other directories.
- A path describes a location. An absolute path starts with
/. A relative path starts from your current directory. - The special names
.(the current directory) and..(the parent directory) are used in relative paths.
3.5 Redirection and append¶
| Operator | Name | Behavior |
|---|---|---|
> |
Redirect | Sends output to a file and overwrites any existing content |
>> |
Append | Sends output to a file and adds it to the end, keeping the existing content |
Common misunderstanding: > silently replaces a file's content. There is no confirmation and no undo, so use >> when you want to add a line.
You can write to files, not to directories. A directory cannot be "edited" like a file. You change a directory by creating, removing, renaming, or moving the items inside it.
3.6 Reading files: choosing the right tool¶
| Command | Best used for |
|---|---|
cat |
Short files, or sending a whole file to another command |
tac |
Reading a file in reverse order, last line first |
more |
Basic paging forward |
less |
Paging with scrolling both ways and searching |
head |
Viewing the beginning of a file |
tail |
Viewing the end of a file, such as the newest log entries |
3.7 The Filesystem Hierarchy Standard (FHS)¶
The filesystem is a single tree that starts at /, the root directory. Everything is placed in a subdirectory beneath it. The Filesystem Hierarchy Standard describes what each major directory is for.
Do not confuse the root directory
/with therootuser's home directory/root.
4. Commands and Syntax¶
Command: rhc¶
Purpose: Connect a system to Red Hat services (content, analytics, and remote management).
Privileges: root or sudo.
Syntax:
sudo rhc connect
sudo rhc status
sudo rhc disconnect
Example:
sudo rhc connect
Explanation: rhc connect prompts for your Red Hat credentials (or uses an activation key if you supply one) and then registers the system and enables the default features. rhc status reports the connection state. rhc disconnect removes the connection.
Important points
- Individual features can be turned off at connection time with options such as
--disable-feature. Option names can vary by version, so checkrhc connect --helpon your system. - After
rhc disconnect, new package downloads from Red Hat repositories no longer work. Packages already installed remain installed. - Avoid typing your password on the command line, because it can be stored in your shell history. Let the command prompt for it.
Common errors
| Problem | Likely cause | Resolution |
|---|---|---|
| Connection or network error | No internet access, DNS problem | Test connectivity; check the VM's network |
| Authentication failure | Wrong username or password | Re-enter credentials; confirm they work on the Red Hat website |
| System already registered | A previous registration exists | Check the state with rhc status; disconnect or unregister before registering again |
| No subscription available | Account lacks an entitlement | Check your subscription in the Red Hat Customer Portal |
Command: subscription-manager¶
Purpose: Register a system, check subscription state, and unregister.
Privileges: root or sudo.
Syntax:
sudo subscription-manager register
sudo subscription-manager status
sudo subscription-manager identity
sudo subscription-manager unregister
Example:
sudo subscription-manager register
Explanation: The command prompts for the username and password. status shows the overall subscription status. identity shows the system's registration identity. unregister removes the registration.
Important points
- Use the Tab key to complete command names and options. Tab completion depends on the
bash-completionpackage being installed. Verify it works on your system. - Unregister practice VMs when you finish with them so old test systems do not clutter your Red Hat account.
Command: dnf repolist (verification)¶
Purpose: Confirm that repositories are available.
sudo dnf repolist
Explanation: A registered system lists the Red Hat repositories it can use. An unregistered system typically shows none, or shows an error about the system not being registered.
Note: The repository names you see depend on your release and subscription.
Command: command-line-assistant (RHEL Lightspeed)¶
Purpose: Install and use the command-line assistant.
Privileges: Installation requires root or sudo.
Syntax:
sudo dnf install command-line-assistant -y
c "your question in plain English"
Example:
c "how do I install the httpd package?"
Explanation: The question goes in quotes. The assistant typically responds with commands and short explanations, such as installing a package with dnf, enabling and starting a service with systemctl, and opening a firewall service. Read the answer and verify the commands before running them.
Verify: The package name and the command name
ccan vary by release. Confirm them in Red Hat's documentation for your version.
Command: touch¶
Purpose: Create an empty file, or update a file's modification time.
Syntax:
touch [options] file...
Example:
touch notes.txt report.txt
Explanation: Creates two empty files. If a file already exists, touch updates its timestamp and does not change its content.
Command: echo¶
Purpose: Print text. Combined with redirection, it creates or modifies files.
Syntax:
echo "text"
echo "text" > file
echo "text" >> file
Example:
echo "first line" > log.txt
echo "second line" >> log.txt
cat log.txt
Explanation: The first command creates log.txt (or replaces its content). The second adds a line. cat shows the file, which now has two lines.
Important points: A single > overwrites. Use >> to keep existing content.
Command: cat¶
Purpose: Display file content, or create a short file from keyboard input.
Syntax:
cat file
cat > file # type the content, then press Ctrl+D to finish
cat >> file # append typed content, then Ctrl+D
Explanation: Ctrl+D signals the end of input, which saves the file. Be careful with cat > file on an existing file, because it overwrites it.
Command: tac¶
Purpose: Print a file in reverse order, from the last line to the first.
tac file
Commands: more and less¶
Purpose: View a file one screen at a time.
Syntax:
more file
less file
Explanation: more pages forward and shows a percentage. less allows scrolling both ways and searching with /word. Press q to quit less (and also more).
Commands: head and tail¶
Purpose: Show the first or last lines of a file. The default is 10 lines.
Syntax:
head [-n N] file
tail [-n N] file
Example:
head -n 15 /etc/services
tail -n 5 /etc/passwd
Explanation: The first shows the first 15 lines, and the second shows the last 5 lines.
Note: The files named here exist on typical RHEL systems, but confirm they exist on yours before relying on them.
Command: ls¶
Purpose: List directory contents.
Syntax:
ls [options] [path]
Important options:
| Option | Meaning |
|---|---|
-l |
Long listing (permissions, owner, size, date) |
-a |
Include hidden files (names starting with .) |
-la |
Long listing including hidden files |
-h |
With -l, show sizes in readable units |
-R |
List subdirectories recursively |
Commands: pwd and cd¶
Purpose: Show your location and change directory.
Syntax:
pwd
cd [path]
Common forms:
| Command | Result |
|---|---|
cd /path |
Go to an absolute path |
cd .. |
Up one level |
cd ../.. |
Up two levels |
cd ../../.. |
Up three levels |
cd or cd ~ |
Go to your home directory |
cd - |
Return to the previous directory |
Common error: "No such file or directory" means the path is wrong or does not exist. Check with ls and pwd.
Command: mkdir¶
Purpose: Create directories.
Syntax:
mkdir [options] directory...
Important options:
| Option | Meaning |
|---|---|
-p |
Create parent directories as needed. No error if the directory already exists |
Example:
mkdir projects
mkdir -p earth/asia/india
Explanation: The second command creates earth, then asia inside it, then india inside that, in a single step. Without -p, mkdir earth/asia/india fails if earth and asia do not already exist.
Command: cp¶
Purpose: Copy files and directories.
Syntax:
cp [options] source destination
Important options:
| Option | Meaning |
|---|---|
-r |
Copy directories recursively (required for directories) |
-i |
Ask before overwriting |
Example:
cp notes.txt notes.bak
cp -r projects projects-backup
Explanation: The first copies a file. The second copies a directory and everything inside it.
Command: mv¶
Purpose: Move or rename files and directories.
Syntax:
mv [options] source destination
Example:
mv notes.txt notes-old.txt # rename
mv notes-old.txt projects/ # move into a directory
Explanation: Renaming is moving to a new name. Moving to an existing directory places the item inside it. -i asks before overwriting.
Commands: rm and rmdir¶
Purpose: Remove files and directories.
Warning: Removed files do not go to a recycle bin. Deletion is not reversible from the shell. Double-check paths before pressing Enter.
Syntax:
rm [options] file...
rmdir directory...
Important options:
| Command | Effect |
|---|---|
rm file |
Remove a file |
rm -i file |
Ask for confirmation |
rm -f file |
Force: no prompt, ignore missing files |
rm -r directory |
Remove a directory and its contents |
rm -rf directory |
Remove a directory and contents without prompting |
rmdir directory |
Remove an empty directory only |
Explanation: rmdir fails on a non-empty directory, which makes it a safe choice. rm -rf removes everything without asking.
Important points
- On RHEL, the
rootuser's shell typically defines aliases that add-itorm,cp, andmv, which is why they may prompt. Check withalias. - Never run
rm -rfon a path you have not verified, and never on/or on paths that contain variables you have not checked.
5. Configuration Files and System Paths¶
Filesystem Hierarchy¶
| Directory | Purpose |
|---|---|
/ |
Root of the whole tree |
/bin |
Essential user commands |
/sbin |
System administration commands |
/boot |
Files needed to boot, such as the kernel and bootloader files |
/dev |
Device files that represent hardware such as disks |
/etc |
System-wide configuration files |
/home |
Home directories of regular users (/home/username) |
/root |
Home directory of the root user |
/run |
Runtime data for running processes, cleared at reboot |
/tmp |
Temporary files, cleaned automatically after a period |
/var/tmp |
Temporary files that are kept longer than in /tmp |
/usr |
Installed software, libraries, and shared data |
/var |
Variable data such as logs, spool files, and caches |
Notes
- On modern RHEL,
/binand/sbinare symbolic links to/usr/binand/usr/sbin. You can confirm this withls -ld /bin /sbin. Both paths work. - Files in
/tmpand/var/tmpare removed by a systemd cleanup mechanism after an age limit. The defaults are commonly about 10 days for/tmpand 30 days for/var/tmp. These values are configurable, so check your system (see below). /runis held in memory and is empty after a reboot./devis relevant later when you work with disks, partitions, and LVM.
Inspecting cleanup settings
cat /usr/lib/tmpfiles.d/tmp.conf
Verify: The file path and values can differ between releases. If the path does not exist, search the tmpfiles configuration with
systemd-tmpfiles --cat-config | grep -i tmp.
Do not modify system directories such as /usr, /boot, or /etc casually. Make a backup copy before editing any configuration file.
6. Step-by-Step Administration Procedures¶
Procedure 1: Register a system with rhc¶
Goal: Connect a RHEL system to Red Hat so it can use Red Hat repositories.
Prerequisites: A RHEL 8.8 or later system, a Red Hat account with a valid subscription, root or sudo access, and internet access.
Steps
- Confirm connectivity (for example, that the system can resolve and reach external addresses).
- Run:
bash sudo rhc connect - Enter your Red Hat username and password when prompted.
- Check the result:
bash sudo rhc status - Verify repository access:
bash sudo dnf repolist
Verification: rhc status reports that the system is connected, and dnf repolist lists repositories.
Rollback:
sudo rhc disconnect
Procedure 2: Register with Subscription Manager¶
Goal: Register using the traditional tool.
Prerequisites: The system is not currently registered (or you have disconnected it first).
Steps
- Run:
bash sudo subscription-manager register - Enter the username and password.
- Verify:
bash sudo subscription-manager status sudo subscription-manager identity sudo dnf repolist
Rollback:
sudo subscription-manager unregister
Note: On some accounts, you may also need to attach a subscription or enable repositories. If
dnf repolistshows no repositories after registering, check the subscription and repository settings in your account and withsubscription-manager.
Procedure 3: Use the command-line assistant¶
Goal: Install the assistant and ask a question safely.
Prerequisites: A registered system with internet access, on a release that provides the package.
Steps
- Install:
bash sudo dnf install command-line-assistant -y - Ask a question in quotes:
bash c "how do I create a user and set the password?" - Read the answer and compare it with the
manpages (man useradd,man passwd) before running anything.
Verification: The assistant returns an answer. If the command is not found, confirm the package installed with rpm -q command-line-assistant.
Cleanup: None required.
Procedure 4: Build a directory tree and navigate it¶
Goal: Create earth/asia/india with one command and move around it.
Steps
- Create the tree:
bash mkdir -p earth/asia/india - Check it:
bash ls -R earth - Enter it with a relative path and confirm your location:
bash cd earth/asia/india pwd - Go up three levels:
bash cd ../../.. pwd
Verification: pwd shows the directory where you started.
Cleanup:
rm -r earth
(Remove only the practice directory you created.)
Procedure 5: Create, extend, and read a file¶
Goal: Practice redirection and append without losing data.
Steps
- Create the file with the first line:
bash echo "first line" > log.txt - Append a second line:
bash echo "second line" >> log.txt - Read it:
bash cat log.txt tac log.txt head -n 1 log.txt tail -n 1 log.txt
Verification: cat shows two lines in order, tac shows them reversed, head -n 1 shows the first, and tail -n 1 shows the last.
Cleanup: rm log.txt
Procedure 6: Copy, rename, and delete¶
Goal: Manage files without data loss.
Steps
- Create a source file and a directory:
bash echo "data" > a.txt mkdir backup - Copy the file and a directory:
bash cp a.txt backup/ cp -r backup backup2 - Rename a file:
bash mv a.txt b.txt - Remove items:
bash rm b.txt rm -r backup backup2
Verification: After each step, run ls -R to confirm the result.
Cleanup: All practice items are removed in step 4.
7. Practical Examples¶
Example 1: Preparing a new server for package installs¶
A new RHEL VM cannot install httpd. The likely cause is that it is not registered.
sudo dnf repolist
sudo rhc connect
sudo rhc status
sudo dnf repolist
Why: The first repolist shows the problem. Registering fixes it, and the final repolist proves the fix.
Example 2: Safely backing up a configuration file before editing¶
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
ls -l /etc/ssh/sshd_config*
Why: A copy lets you restore the original if the edit causes a problem. ls -l confirms the backup exists.
Example 3: Reading the end of a log¶
sudo tail -n 20 /var/log/messages
Why: The newest entries are at the end of a log. tail shows them without loading the whole file.
Note: On some systems the file may not exist or may require different tools such as
journalctl. Check what your system provides.
Example 4: Creating an application directory layout¶
mkdir -p ~/app/{config,logs,data}
ls -R ~/app
Why: mkdir -p with brace expansion creates several sibling directories in one command. (Brace expansion is covered with path expansion in a later section.)
8. Verification and Troubleshooting¶
| Symptom | Likely cause | Diagnostic | Resolution |
|---|---|---|---|
dnf cannot install or update |
System not registered | sudo subscription-manager status, sudo dnf repolist |
Register the system |
| Registration fails with network error | No connectivity or DNS | Test network access | Fix networking, then retry |
| Authentication failure at registration | Wrong credentials | Log in to the Red Hat site to confirm | Re-enter credentials |
| "Already registered" message | A registration exists | sudo rhc status, sudo subscription-manager identity |
Disconnect or unregister, then register again |
| Registered, but no repositories | No usable subscription attached or repositories disabled | sudo subscription-manager status |
Check the subscription in your account |
c command not found |
Package not installed or different release | rpm -q command-line-assistant |
Install it, or check the documentation |
mkdir: cannot create directory |
Parent missing or no permission | ls, pwd |
Use -p or choose a writable location |
rmdir fails with "Directory not empty" |
The directory has contents | ls -A dir |
Remove contents, or use rm -r if intended |
cp complains about a directory |
-r missing |
n/a | Use cp -r |
| File content disappeared | Used > instead of >> |
n/a | Restore from backup; use >> next time |
Permission denied |
Insufficient privileges | whoami, ls -l |
Use sudo only where needed |
No such file or directory |
Wrong path | pwd, ls |
Correct the path |
Persistent versus temporary: Registration persists across reboots until you disconnect or unregister. File and directory changes persist, except for /run (cleared at boot) and the automatic cleanup in /tmp and /var/tmp.
9. Best Practices and Important Notes¶
- Register new systems early, and unregister disposable test systems when finished.
- Do not type passwords on the command line. Let the tools prompt you.
- Never send secrets to the command-line assistant, and verify its answers in the manual pages.
- Use
mkdir -pto create nested directories in one command. - Use
>>unless you intend to overwrite. - Use
cp -rfor directories, and keep a backup before editing important files. - Prefer
rmdirorrm -iwhile learning. Userm -rfonly on paths you have verified. - Do not store important data in
/tmp, because it is cleaned automatically. - Do not use
rm -rfon system directories.
Common mistakes
- Typing
>when>>was needed. - Forgetting
-rwhen copying directories. - Mixing up
/and/root. - Expecting
/tmpcontents to survive indefinitely.
10. RHCSA Exam Preparation¶
Practical skills practiced in this section
- Creating, copying, moving, and removing files and directories.
- Redirection and append.
- Reading files with several tools.
- Registering a system and confirming repository access.
- Knowing where configuration (
/etc), logs (/var/log), temporary files, and home directories live. - Verifying every change with a command such as
ls,cat, ordnf repolist.
Good exam habits
- After every task, run a command that proves the result.
- Use the manual pages (
man) when you are unsure of an option. - Double-check paths before deleting or overwriting anything.
- Practice until common commands are automatic.
Verify: Some study material describes the exam's structure (for example, how many systems or questions it has) and specific recovery tasks. These details were not verified here. Check the current EX200 objectives and exam rules on Red Hat's official website. Whether the command-line assistant is permitted during the exam is not verified either.
11. Section Summary¶
- Registration connects a RHEL system to Red Hat's subscription service and is required for installing and updating Red Hat packages.
- Register with
rhc connect(newer systems) orsubscription-manager register(traditional). Verify withrhc status,subscription-manager status, anddnf repolist. - The command-line assistant answers plain-English questions, but it needs internet access and registration, and its answers must be verified.
- Create files with
touch,echo, andcat, and directories withmkdir(-pfor nested paths). >overwrites and>>appends.- Read files with
cat,tac,more,less,head, andtail. - Copy with
cp(-rfor directories), move and rename withmv, and remove withrm,rm -r, andrmdir. - The filesystem is a single tree starting at
/, with directories such as/etc,/home,/root,/var,/usr,/tmp,/boot,/dev, and/run.
12. Quick Revision¶
| Command | Purpose | Notes |
|---|---|---|
sudo rhc connect |
Register and connect | RHEL 8.8 and later |
sudo rhc status |
Show connection state | |
sudo rhc disconnect |
Remove connection | New downloads stop |
sudo subscription-manager register |
Traditional registration | Prompts for credentials |
sudo subscription-manager status |
Subscription status | |
sudo subscription-manager unregister |
Remove registration | |
sudo dnf repolist |
List repositories | Verification |
c "question" |
Command-line assistant | Verify answers; check release support |
touch f |
Create empty file | Updates timestamp if exists |
echo "x" > f / >> f |
Overwrite / append | > destroys content |
cat > f |
Create from keyboard | End with Ctrl+D |
mkdir -p a/b/c |
Nested directories | No error if they exist |
cat, tac |
Read whole file / reversed | |
more, less |
Page through file | q quits |
head -n N, tail -n N |
First / last lines | Default 10 |
ls -la |
Long list incl. hidden | |
cd .., cd ../.. |
Go up levels | cd alone goes home |
cp -r src dst |
Copy directory | -r required |
mv old new |
Rename or move | |
rm, rm -r, rmdir |
Remove | No recycle bin |
13. Knowledge Check¶
- Why can
dnffail to install packages on a freshly installed, unregistered RHEL system? - Name two benefits of registering a RHEL system.
- Which two commands can register a system, and which is the traditional one?
- How do you verify that a system has repository access after registering?
- What is the difference between
>and>>? - Which command creates
a/b/cin one step even ifaandbdo not exist? - Which option is required to copy a directory with
cp? - What is the difference between
rmdirandrm -r? - Which directory holds system-wide configuration files, and which holds the
rootuser's files? - What is the difference between
/tmpand/var/tmp?
Answer Key¶
- Without registration, the system cannot access Red Hat's repositories, so package installs and updates fail.
- Any two of: official updates, repository access, certified content, security fixes, support.
rhc connectandsubscription-manager register. Subscription Manager is the traditional method.- Run
sudo dnf repolistand confirm that repositories are listed (also checkrhc statusorsubscription-manager status). >overwrites the file's content.>>appends to the end and keeps the existing content.mkdir -p a/b/c.-r(recursive).rmdirremoves only empty directories.rm -rremoves a directory and everything inside it./etcholds configuration files./rootis therootuser's home directory.- Both hold temporary files, but
/var/tmpkeeps them longer (commonly about 30 days versus about 10 days for/tmp; the exact values are configurable).