Introduction
I’m continuing my 30-day Linux challenge as part of my preparation for the RHCSA exam and today’s article covers something I’ve come to appreciate more with every passing day that is the vi editor.
At first, it can feel unfamiliar (even frustrating) but once you understand how it works, vi becomes one of the most powerful tools in your Linux toolkit. It is available on every system, lightning fast and surprisingly efficient especially when working on servers with no graphical interface.
In this article, I’ve broken it down step by step from how to open a file, switch between modes, save your changes and navigate like a pro. Whether you’re just starting out or need a quick refresher, this guide is for you. Let’s make vi simple, useful and maybe even fun.
Index
- What is vi
- How to Open a File in vi
- Modes in vi
- Common vi Commands
- Real World Scenarios
- Pro Tips for Beginners
- Industry Insight
- Quick Summary
🧠 What is vi?
vi
is a text editor built into nearly every Unix-like system. It allows you to:
- Edit configuration files
- Write shell scripts
- View and tweak log files
- Manage content right from the terminal, no GUI needed
Once you get comfortable with it, you’ll save time, improve efficiency, and never feel lost when you're dropped into a Linux server.
⚙️ How to Open a File in vi
vi filename.txt
- If the file exists, it opens.
- If it doesn’t,
vi
creates a new file with that name.
🧭 Modes in vi
Understanding the modes is key.
Mode | What It Does |
---|---|
Normal Mode | Default mode. You can navigate, delete, copy, etc. |
Insert Mode | You can type/edit text. (Enter with i ) |
Command Mode | For saving, quitting, searching. (Start with : ) |
✍️ Common vi Commands
Action | Command |
---|---|
Enter insert mode | i |
Exit insert mode | Esc |
Save file | :w |
Quit vi
|
:q |
Save and quit |
:wq or ZZ
|
Quit without saving | :q! |
Delete line | dd |
Copy line | yy |
Paste line | p |
Move cursor | Arrow keys or h , j , k , l
|
💻 Real World Scenarios
🔧 Editing a config file
sudo vi /etc/ssh/sshd_config
Make changes, then :wq
to save and exit.
📦 Quick script edit
vi backup.sh
Add/modify commands without needing an external editor.
📝 On-the-fly file creation during SSH session
vi /tmp/note.txt
Useful for jotting down temporary notes or logs.
💡 Pro Tips for Beginners
- Don’t panic! Press
Esc
if you feel stuck. - Use
:set number
to show line numbers. - Use
/search_term
to find text in the file. - Practice with sample files before jumping into system configs.
🏢 Industry Insight
Why does vi
matter in real-world environments?
- It is lightweight and runs on every Linux server even minimal installs.
- In production systems, there is no GUI
vi
is your main tool. - Many automated tools use
vi
-style keybindings (like Git, Crontab).
Mastering vi
is like learning how to drive stick shift, you may not use it every day but when you need it, you're glad you know it.
✅ Quick Summary
Today’s takeaway? Don’t fear vi
. Get comfortable with it and you will unlock a whole new level of control in Linux. It is not just a text editor, it is a superpower.
I'd love to hear your thoughts, insights or experiences with Linux. Feel free to share and join the conversation [Connect with me on LinkedIn www.linkedin.com/in/techwithsana ]💜
#30dayslinuxchallenge #redhat #networking #cloudcomputing #cloudenginner #cloudarchitect #cloud #RHCSA #RHCE #RHEL #WomeninTech #Technology
Top comments (0)