1. Understand and Use Essential Tools
πRed Hat Certified System Administrator (RHCSA β EX200)
In the RHCSA exam, you will often need to create, view, and modify text files on a Linux system. Text files are everywhere in Linux: configuration files, scripts, logs, and notes. Knowing how to manage them efficiently is essential.
1. Understanding Text Files in Linux
- A text file is a file that contains readable characters (letters, numbers, symbols) instead of binary data.
- Examples in IT environments:
/etc/passwdβ stores user accounts./etc/fstabβ stores filesystem mount information.- Log files in
/var/log/β stores system logs. - Script files in
/usr/local/binβ custom automation scripts.
Key point: Most configuration and script files in Linux are plain text files.
2. Creating Text Files
There are multiple ways to create text files in Linux:
2.1 Using touch
- Command:
touch filename.txt
- What it does: Creates an empty text file or updates the timestamp if it already exists.
- Example (IT environment):
touch /home/admin/new_config.txt
This creates an empty file where you can later add configuration data.
2.2 Using echo
- Command:
echo "Some content" > filename.txt
>will overwrite the file.- Example:
echo "PermitRootLogin no" > /etc/ssh/sshd_config
>>will append to the file instead of overwriting:
echo "AllowUsers admin" >> /etc/ssh/sshd_config
2.3 Using cat
- Command:
cat > filename.txt
- After running, you can type the content directly. Press
CTRL+Dto save and exit. - Example:
cat > /tmp/server_list.txt
server1.example.com
server2.example.com
2.4 Using text editors
- In Linux, you often need to edit configuration files, so text editors are important.
Common editors in RHCSA:
| Editor | How to open | Key Features |
|---|---|---|
vi / vim | vi filename | Powerful, default on most Linux systems. |
nano | nano filename | Easy for beginners, shows on-screen shortcuts. |
gedit | gedit filename | GUI editor (if using desktop Linux). |
3. Editing Text Files
3.1 Using vi or vim
vi is commonly tested in RHCSA because it is available on all Linux systems.
Basic steps in vi:
- Open a file:
vi /etc/hosts
- Switch to insert mode to type:
- Press
iβ you can now type/edit text.
- Exit insert mode:
- Press
ESC.
- Save changes and exit:
:wβ write/save.:qβ quit.:wqorZZβ save and quit together.:q!β quit without saving.
Example: Adding a new server IP in
/etc/hosts:
192.168.1.50 webserver.example.com
3.2 Using nano
- Command:
nano /etc/hostname
- After opening:
- Type your text.
- Save:
CTRL+Oβ press Enter. - Exit:
CTRL+X.
nanois easier for beginners thanvi.
4. Viewing Text Files
Sometimes you just need to check file content:
| Command | Description |
|---|---|
cat filename | Show entire content |
less filename | Scroll up/down through content |
more filename | Similar to less but less advanced |
head filename | Show first 10 lines by default |
tail filename | Show last 10 lines (useful for logs) |
tail -f filename | Continuously monitor logs (real-time updates) |
Example: Monitoring
/var/log/messagesfor new log entries:
tail -f /var/log/messages
5. Practical IT Scenarios
- Editing a config file:
vi /etc/ssh/sshd_config
Disable root login:
PermitRootLogin no
- Creating a script:
nano /usr/local/bin/backup.sh
Add:
#!/bin/bash
tar -czf /backup/home_backup.tgz /home
Save and exit β make it executable:
chmod +x /usr/local/bin/backup.sh
- Checking log files:
tail -f /var/log/secure
Helps monitor authentication attempts in real-time.
6. Key Exam Tips
- Know at least
vicommands β itβs mandatory for RHCSA. - Practice creating files with
touch,echo, andcat. - Be comfortable viewing and appending text using
>>. - Know how to check file content using
cat,less,head,tail. - Always check permissions if editing system files:
ls -l /etc/hosts
sudo vi /etc/hosts
7. Summary Table
| Task | Command/Method | Notes |
|---|---|---|
| Create empty file | touch file.txt | Fast, simple |
| Create file with content | echo "text" > file.txt | Overwrites existing |
| Append text | echo "text" >> file.txt | Adds to end |
| Create/edit interactively | cat > file.txt | Type content manually |
Edit with vi | vi file.txt | Default editor, powerful |
Edit with nano | nano file.txt | Beginner-friendly |
| View file | cat file.txt | Shows all content |
| View large file | less file.txt | Scrollable view |
| Monitor logs | tail -f file.log | Real-time monitoring |
β
Conclusion:
In the RHCSA exam, you must be able to create, edit, view, and append text files efficiently, mostly using vi, nano, or basic shell commands. These skills are tested not just for text files, but because most Linux administration tasks (configuring services, creating scripts, monitoring logs) depend on them.
