Skip to main content
In this lesson we focus on one of the most important skills for a Red Hat Certified System Administrator (RHCSA): editing text files. Almost everything in Linux is managed through text configuration files — services, networking, users, security policies, and system behavior are all controlled by editable files. If you can’t confidently edit text files from a terminal, you can’t confidently administer a RHEL system.
A dark-themed diagram shows the Linux Tux penguin linked by an arrow to a document/edit icon. To the right is a vertical list of items: Services, Networking, Users, Security Policies, and System Behavior.
This lesson starts with Vim basics: understanding Vim modes, entering insert mode, saving changes, and exiting properly. Next we cover safe editing practices for system configuration files. Finally, practice exercises help you build confidence — the only way to become proficient with Vim is to use it often. By the end of this lesson you’ll be able to open, edit, and safely save configuration files on a live RHEL system.

Why Vim?

Vim is the editor you’ll most frequently encounter on RHEL servers because it works reliably in any terminal session (no GUI required). Think of Vim like driving a manual car: the concept is different at first, but once you understand the modes (the “gears”), you gain precise, fast control.
The image shows the Vim logo on the left with a pencil and arrow pointing to the Red Hat Enterprise hat logo and text on the right. It suggests using Vim to edit or configure something on Red Hat Enterprise.

Vim Modes (the core concept)

Vim works by switching between modes. Knowing which mode you are in is essential before you press keys.
A dark-themed infographic titled "Vim Modes" showing four labeled cards for different modes: Command Line (":"), Insert ("i"), Visual ("v"), and Visual Block ("CTRL+V").
At any time press Esc to return to normal mode. Once you understand these modes, Vim becomes fast and predictable for system administration tasks.
Tip: Press Esc to make sure you’re in normal mode before issuing commands like :wq, dd, or search commands.

Essential Normal-Mode Commands

Normal mode is where you control and manipulate the file — navigation, search, delete, copy/paste, and file operations happen here. Notes:
  • Use ZZ (capital Z twice) in normal mode as a shortcut for save-and-exit.
  • To view line numbers while editing: enter :set number in normal mode.
  • For syntax highlighting: enter :syntax on (if supported).

Safe Editing of Configuration Files

Editing system configuration files requires care. Follow these recommended practices to avoid service disruption.
Warning: Never edit critical system files without a backup. A syntax error in a config file can prevent services from starting. Use sudoedit or make a copy before editing, and test changes in a staging environment when possible.
Practical tips:
  • If you can’t save a file because of permissions, either use sudoedit or save to a temporary path with :w /tmp/yourfile and then move it into place with sudo mv.
  • Prefer sudoedit for safer privilege escalation: it opens the file in your editor but writes as root only after you complete the edit.
  • When editing remote systems, ensure you have an active secondary connection or a recovery method in case SSH config is accidentally broken.

Hands-on Practice Exercises

Try these short exercises on a non-production system to build muscle memory:
  1. Open a file: vim /etc/hosts
  2. Ensure you’re in normal mode (Esc), navigate to a line, press i and add a comment.
  3. Save: :w and then quit: :q (or :wq).
  4. Practice copy/paste: yy on a line, move, then p.
  5. Delete a line with dd, then undo with u.
  6. Use search: /localhost then n to jump through matches.
  7. Create and test a backup workflow: sudo cp /etc/hosts /etc/hosts.bak.

Further Reading and References

Practice regularly. Knowing how to edit and safely manage configuration files is a foundational skill for RHCSA and daily system administration.

Watch Video