In cloud infrastructure and DevOps, configuration files (YAML, JSON, INI, Nginx configs) and server logs are plain text. Being able to edit files directly inside a remote shell and parse gigabytes of log output with grep, find, sed, and awk is a required engineering skill.
1. Terminal Text Editors: nano vs. vim
When you SSH into a remote Linux server or enter a container, there is no VS Code GUI. You must use a terminal-based editor:
nano — The Beginner-Friendly Editor
nano is intuitive and displays keyboard shortcuts at the bottom of the screen (^ represents the Ctrl key):
- Ctrl + O — WriteOut (Save) changes. Press Enter to confirm filename.
- Ctrl + W — Where Is (Search) for text.
- Ctrl + K — Cut line.
- Ctrl + U — Paste (Uncut) line.
- Ctrl + X — Exit nano (prompts to save if modified).
vim — The Ubiquitous Powerhouse
vim (Vi IMproved) is pre-installed on virtually every Linux distribution and container base image. It is a modal editor:
Essential vim Cheat Sheet:
- Open a file:
vim app.config(starts in Normal Mode). - Start typing: Press i to switch to Insert Mode.
- Stop typing / return to command mode: Press Esc.
- Save and Exit:
:w— Save (Write).:q— Quit.:wqorZZ— Save and Quit.:q!— Force Quit (Discard all unsaved changes).
- Navigation & Editing in Normal Mode:
dd— Delete (cut) current line.yy— Copy (yank) current line.p— Paste below cursor.u— Undo last change.Ctrl + r— Redo undone change./keyword— Search forkeywordforward (pressnfor next match).:%s/old/new/g— Find and replace all occurrences across entire file.:set number— Display line numbers.
2. Searching File Contents with grep
grep (Global Regular Expression Print) scans files or standard input for text patterns:
3. Locating Files with find
While grep searches inside files, find searches the filesystem for files by attributes:
4. Stream Editing with sed
sed (Stream Editor) modifies text streams on the fly without opening an editor:
5. Column Extraction & Analysis with awk
awk is a complete pattern-scanning and text-processing language designed for structured column data (like CSVs, access logs, or command output):
6. Text Manipulation Toolkit: wc, sort, uniq, cut, tr
Summary
- Use
nanofor quick simple edits; mastervim(ito insert, Esc +:wqto save,:q!to abort). - Use
grep -rnEfor fast recursive keyword and regex searching across codebases. - Use
findto locate files by name, size, type, or age, and execute batch operations with-exec. - Use
sed -ifor automated in-place configuration replacements in CI/CD scripts. - Chain
awk,sort, anduniq -cinto high-speed log-analysis pipelines.
In the next lesson, you will master Linux permissions, ownership, octal modes (chmod 755/600), and superuser delegation with sudo!