See and change file contents from the terminal — print and page through files, peek at the start or end of big logs, edit comfortably in nano, and survive your first encounter with vim.
cat dumps an entire file to the screen — fine for short files, overwhelming for long ones. For anything big, less opens a scrollable view: arrow keys or PageUp/PageDown to move, /word to search, and q to quit. less never loads the whole file at once, so it opens huge files instantly.
Dump a whole (short) file to the screen
cat /etc/hostnameOpen a long file in a scrollable pager (q to quit, / to search)
less /etc/serviceshead shows the first lines of a file and tail shows the last — far better than cat for large logs, where the newest entries are at the bottom. The real power move is tail -f ("follow"): it stays open and prints new lines as they are written, so you can watch a log live while something runs. Press Ctrl+C to stop following.
First 10 lines (add -n 20 for a different count)
head /var/log/syslogLast 10 lines — usually the most recent log entries
tail /var/log/syslogFollow a log live: new lines appear as they're written (Ctrl+C to stop)
tail -f /var/log/syslognano is the beginner-friendly editor — it shows its shortcuts along the bottom of the screen the whole time. The ^ means the Ctrl key, so ^O is Ctrl+O to save ("write out") and ^X is Ctrl+X to quit. That is genuinely all you need to edit config files and scripts confidently.
Open (or create) a file for editing
nano notes.txtInside nano: Ctrl+O then Enter = save Ctrl+X = quit Ctrl+W = search Ctrl+K / Ctrl+U = cut / paste a line
vim is everywhere — it is the editor that opens by default on most servers — so you need to escape it even if you prefer nano. The one thing to understand: vim starts in "normal" mode where keys are commands, not text. Press i to start typing ("insert" mode), press Esc to go back, then type a colon command to save and quit. Memorize :wq and you will never be trapped again.
Open a file in vim
vim notes.txtThe survival kit: i = start typing (insert mode) Esc = stop typing (back to normal mode) :w then Enter = save :q then Enter = quit :wq then Enter = save and quit :q! then Enter = quit WITHOUT saving (escape hatch)