Study guide

3.3 Create and Edit Text Files

Red Hat Certified System Administrator RHCSA

Track your progress as you read

Finished sections get a check mark.

1 Introduction & Exam Overview

1.1 Current Exam Facts 1.2 Lab Setup & Performance-Based Study Strategy

2 Essential Tools: Shell, Redirection & Text Analysis

2.1 Shell Prompt and Command Syntax 2.2 Input-Output Redirection and Pipes 2.3 grep and Regular Expressions for Text Analysis

3 Essential Tools: Remote Access, Users & Text Editing

3.1 Access Remote Systems Using SSH 3.2 Log In and Switch Users in Multiuser Targets 3.3 Create and Edit Text Files

4 Essential Tools: Files, Links & Archives

4.1 Create, Delete, Copy, and Move Files and Directories 4.2 Hard and Soft Links 4.3 Archive and Compress with tar, gzip, and bzip2

5 Essential Tools: Permissions & System Documentation

5.1 List, Set, and Change Standard ugo/rwx Permissions 5.2 System Documentation: man, info, and /usr/share/doc

6 Manage Software: RPM and Flatpak

6.1 Configure Access to RPM Repositories 6.2 Install and Remove RPM Software Packages 6.3 Configure Access to Flatpak Repositories 6.4 Install and Remove Flatpak Software Packages

7 Create Simple Shell Scripts

7.1 Conditional Execution: if, test, and [] 7.2 Looping Constructs for Files and Input 7.3 Process Script Inputs ($1, $2, and Beyond) 7.4 Process Shell Command Output in Scripts

8 Operate Running Systems: Boot and Recovery

8.1 Boot, Reboot, and Shut Down a System Normally 8.2 Boot Systems into Different Targets Manually 8.3 Interrupt the Boot Process to Gain Access

9 Operate Running Systems: Processes and Tuning

9.1 Identify and Kill CPU/Memory Intensive Processes 9.2 Adjust Process Scheduling 9.3 Manage Tuning Profiles

10 Operate Running Systems: Logs, Services & File Transfer

10.1 Locate and Interpret System Log Files and Journals 10.2 Preserve System Journals 10.3 Start, Stop, and Check Status of Network Services 10.4 Securely Transfer Files Between Systems

11 Configure Local Storage: Partitions and LVM

11.1 List, Create, and Delete Partitions on GPT Disks 11.2 Create and Remove Physical Volumes 11.3 Assign Physical Volumes to Volume Groups 11.4 Create and Delete Logical Volumes

12 Configure Local Storage: Mounting and Expansion

12.1 Mount File Systems at Boot by UUID or Label 12.2 Add Partitions, Logical Volumes, and Swap Non-Destructively

13 Create and Configure File Systems: Local FS and Permissions

13.1 Create, Mount, and Use VFAT, ext4, and XFS File Systems 13.2 Extend Existing Logical Volumes 13.3 Diagnose and Correct File Permission Problems

14 Create and Configure File Systems: NFS and autofs

14.1 Mount and Unmount Network File Systems Using NFS 14.2 Configure autofs

15 Deploy and Maintain: Scheduling, Services & Targets

15.1 Schedule Tasks with at, cron, and systemd Timers 15.2 Start, Stop, and Enable Services at Boot 15.3 Configure Systems to Boot into a Specific Target

16 Deploy and Maintain: Time, Software Updates & Bootloader

16.1 Configure Time Service Clients 16.2 Install and Update Software from CDN, Remote Repos, and Local Files 16.3 Modify the System Bootloader

17 Manage Basic Networking

17.1 Configure IPv4 and IPv6 Addresses 17.2 Configure Hostname Resolution 17.3 Configure Network Services to Start Automatically at Boot 17.4 Restrict Network Access Using firewalld and firewall-cmd

18 Manage Users and Groups

18.1 Create, Delete, and Modify Local User Accounts 18.2 Change Passwords and Adjust Password Aging 18.3 Create, Delete, and Modify Local Groups and Memberships 18.4 Configure Privileged Access

19 Manage Security: Firewall, umask & SSH Keys

19.1 Configure Firewall Settings with firewall-cmd and firewalld 19.2 Manage Default File Permissions 19.3 Configure Key-Based Authentication for SSH

20 Manage Security: SELinux Modes and Contexts

20.1 Set Enforcing and Permissive Modes for SELinux 20.2 List and Identify SELinux File and Process Contexts 20.3 Restore Default File Contexts

21 Manage Security: SELinux Ports and Booleans

21.1 Manage SELinux Port Labels 21.2 Use Boolean Settings to Modify SELinux Settings

3.3 Create and Edit Text Files

Key Takeaways Explain This Topic AI

RHCSA configuration work is mostly text files: create them with redirection or editors, and ensure paths and ownership match the task so settings persist across reboot.

vim is the classic exam editor: i/a for insert, Esc then :wq to save and quit, :q! to abandon, /pattern to search; know enough to edit under pressure without a GUI.

nano is a simpler alternative when available; on-screen shortcuts (Write Out, Exit) speed small edits if you prefer them.

tilde (~) expands to the current user's home—/home/user for ordinary accounts and /root for root—so always verify whoami and $HOME before writing "into home".

Creating a file is not enough for services: edit the correct persistent path under /etc (or unit drop-ins), then enable/restart the service so the change is active after reboot.

Last updated: August 2026

Almost every RHCSA objective eventually reduces to creating or editing a text file in the right place with the right content, then making related services or permissions correct so the result survives reboot . Shells, package tools, and systemd matter—but if you cannot reliably open, change, save, and verify a file under time pressure, later topics become unnecessarily hard.

  • Creating Files Without an Interactive Editor
  • You do not always need vim . Quick creation methods: touch /tmp/notes.txt # empty file (or update timestamps)
  • echo 'servera' > /tmp/hostname-hint.txt
  • echo 'line two' >> /tmp/hostname-hint.txt # append
  • cat > /tmp/motd-snippet.txt << 'EOF'

Welcome to the lab system.

EOF

Redirection review (ties to essential shell skills):

  • Operator Effect
  • > Write stdout; truncate existing file
  • >> Append stdout
  • 2> Redirect stderr
  • &> or >file 2>&1 Combined streams (style may vary; know the idea)

Danger: > on an existing config file wipes it. For live /etc files, prefer an editor with an explicit save, or write to a temp file and mv into place after review.

  • Create directories first when needed: mkdir -p ~/lab/configs
  • printf 'PermitRootLogin no\n' > ~/lab/configs/sshd-snippet.conf
  • Choosing an Editor on the Exam

RHEL provides multiple editors. For EX200, fluency in one reliable terminal editor is enough; many candidates standardize on vim (or vi ) because it is always expected on minimal systems. nano is friendlier if installed and allowed in your lab image—confirm with command -v nano .

You are not graded on editor fandom. You are graded on the resulting file content and system behavior .

vim Essentials for RHCSA

vim (and vi ) is modal.

Modes you must know

  • Mode How you get there What you do
  • Normal (command) Default on open; Esc from insert Navigate, delete, yank, type : commands
  • Insert i (before cursor), a (after), o (new line below) Type text
  • Command-line : from normal mode :w , :q , :wq , :q! , searches
  • Survival cheatsheet vim /etc/hosts
  • i insert text
  • Esc back to normal mode
  • :w write (save)
  • :q quit
  • :wq or ZZ save and quit
  • :q! quit discarding changes
  • dd delete current line (normal mode)
  • x delete character under cursor
  • /ssh search forward for ssh
  • n next search match
  • u undo

Open at a line if you know it: vim +42 /etc/ssh/sshd_config .

If you accidentally enter a mode you do not understand, press Esc until you are calm, then :q! to abandon or :wq to save intentionally. Panic-quit without saving can lose work; panic-save of a half-edited sshd_config can lock you out—use sshd -t after SSH edits when that file is in play.

  • Minimal visual workflow
  • vim file
  • Move with arrows or h j k l
  • i → type → Esc
  • :wq
  • cat -n file or grep to verify

That five-step loop is enough for most exam edits.

  • nano Essentials
  • If nano is available: nano /etc/hosts

Shortcuts are shown at the bottom ( ^ means Ctrl):

  • Ctrl+O — write out (save); confirm filename
  • Ctrl+X — exit (prompts if unsaved)
  • Ctrl+W — search
  • Ctrl+K / Ctrl+U — cut / paste line-oriented workflow

nano stays in a single modeless-style editing experience, which some candidates prefer under stress. Either editor is fine; pick one and practice until saving is automatic.

Paths, Tilde, and Root’s Home

Shell expansion of ~ depends on the current user :

  • Identity ~ expands to Example personal SSH dir
  • student /home/student /home/student/.ssh
  • root /root /root/.ssh

Mistakes that cost time:

  • Creating authorized_keys under /home/root (wrong; does not exist by default)
  • Editing ~/my.conf as root thinking it is the same file student created earlier
  • Using relative paths after cd somewhere unexpected
  • Always: whoami
  • echo $HOME
  • pwd
  • realpath ./file # when available, resolve absolute path

System configuration almost always lives under /etc , unit files under /etc/systemd/system , and application data in documented paths—not in a random home directory—unless the task explicitly says otherwise.

Editing for Persistence After Reboot

Creating a file in /tmp is often non-persistent across reboot (tmpfs or cleanup policies). Exam tasks that must remain after reboot usually require files in durable locations:

  • Goal Typical durable location
  • Service / daemon options /etc/... or drop-in under /etc/systemd/system/name.service.d/
  • User shell customization ~/.bashrc , ~/.bash_profile (per user)
  • Scheduled jobs /etc/cron.* or user crontab (later objectives)
  • Network and SSH server policy /etc/ssh/sshd_config , /etc/ssh/sshd_config.d/*.conf

Workflow for a persistent service-related edit:

  • Edit the correct file with vim/nano
  • Validate syntax if a tool exists ( sshd -t , nginx -t , systemd-analyze verify , etc.)
  • systemctl enable and/or restart / reload as required
  • Confirm with systemctl status and a functional test
  • Mentally (or literally) ensure a reboot would still load that unit and file

The file content alone does not start a service; enabled units + correct on-disk config produce post-reboot behavior.

Permissions and Safety While Editing

Ordinary users cannot write most of /etc ; use root ( su - or sudo) when required.

Avoid leaving world-writable config files.

For critical files, copy a backup first: cp -a /etc/ssh/sshd_config /root/sshd_config.bak

Use visudo for sudoers (special validation)—do not casually vim /etc/sudoers without the wrapper when policy tools exist.

  • View files safely: less /var/log/messages
  • cat -A file # show tabs/line endings when debugging weird parse errors
  • grep -n Pattern file
  • Practical Exam Patterns
  • Pattern A — Create a required file with exact content cat > /etc/issue.d/lab.issue << 'EOF'

Authorized use only.

  • EOF
  • Pattern B — Change one directive in a large config vim /etc/ssh/sshd_config
  • # set or adjust a directive, Esc, :wq
  • sudo sshd -t && sudo systemctl reload sshd
  • Pattern C — Drop-in override instead of editing vendor file

Many modern RHEL configs support .d directories. Prefer a small drop-in when the task allows clarity and safer upgrades—still a text file you create and edit.

  • Common Pitfalls
  • Saving the file under the wrong path or wrong user’s home
  • Forgetting to leave insert mode before :wq (vim beeps or inserts punctuation into the file)
  • Using > and truncating a working configuration
  • Editing only a runtime copy or tmp location that disappears after reboot
  • Not verifying with cat / grep after the editor exits

Build muscle memory: open → edit → save → verify → enable/restart if needed. That loop is the daily language of RHCSA administration and the foundation for storage, networking, security, and software objectives that all depend on correct on-disk text.