// Linux Basics

Edit files with nano and vi

How to edit a configuration file and escape the editor alive.

On a console-only computer you need a text editor. nano is friendly; vi is almost universal.

Nano basics

nano ~/darkpc-notes.txt

Type normally. Shortcuts on the bottom row show ^ for Ctrl. Use Ctrl+O to save, Enter to confirm, and Ctrl+X to exit. If nano isn't installed, use an available editor such as vi.

Vi basics

vi ~/darkpc-notes.txt

Vi has modes. Press i to enter insert mode and type. Press Esc to go back to command mode.

Keys (after Esc) Action
:w Enter Save
:q Enter Quit
:wq Enter Save and quit
:q! Enter Quit without saving
/word Enter Find text

Before changing config

cp ~/.bashrc ~/.bashrc.backup

For system files, use a suitable administrator account and take a copy first. On Slackware the root login is commonly reached with su -; never edit system files as root without understanding the change.