Module 11 · Editors & Environment
Every Windows user hits the same two walls on Linux: "I can't edit this file" and "this terminal feels weird." This module sorts both. You'll learn to edit files without flinching, get out of vim without panic, and set up your terminal so it actually feels like yours.
By the end of this module, you will:
- Edit configuration files using nano without assistance
- Exit vim without panicking using the survival sequence (Esc :q!)
- Customise the terminal environment by editing ~/.bashrc
- Create command aliases that reduce repetitive typing
- Read, set, and export environment variables (PATH, EDITOR, LANG)
- Use tmux to keep terminals running across SSH disconnects and split your screen
Why text editors matter more than you'd think
On Windows you double-click a file and a window opens. On Linux — especially on a server, where there's no desktop to click on — you have to use a text editor inside the terminal. Every settings file in /etc, every script you write, every scheduled job: all of it goes through a text editor. You really do have to know at least one.
The three editors you'll bump into
nano — the friendly one. It shows you all its buttons at the bottom of the screen. Start with this one. vim — the powerful one. It's everywhere, but it's tricky if you don't know it. You only need enough to not get stuck inside it. VS Code — yes, the same one you use on Windows. Use it for everyday editing whenever you've got a real desktop.
Your setup: .bashrc and shortcuts
Windows hides its settings inside the Registry and the Environment Variables window. Linux just uses plain text files. The main one is ~/.bashrc — it runs by itself every time you open a terminal. (The cousin file, ~/.bash_profile, runs when you log in.) Editing ~/.bashrc is how you make the terminal feel like yours: pick your prompt's colours, set shortcuts, change defaults.
nano — start with this one
nano puts all its shortcuts right at the bottom of the screen, so you can always see what does what. The little ^ symbol means Ctrl. So ^X just means "press Ctrl and X together". There's nothing to memorise past the handful of basics below.
vim — the five commands that get you out alive
Why vim catches people out
vim has two modes — two completely different states it can be in. When you first open vim, you're in Normal mode, which is for moving around and giving commands. To actually type letters into the file, you have to switch to Insert mode first. If you don't know that, you open vim, start typing, and the screen does weird stuff because vim is reading each letter as a command. Every beginner gets caught by this. The fix: press i first, then type normally.
The vim escape rule
If you ever get lost in vim and don't know what's going on: press Esc (that always puts you back into Normal mode), then type :q! and press Enter. You're out. Nothing is saved, nothing is broken — you can just start again. Memorise that one sequence and vim can never trap you.
Making the terminal yours — .bashrc
Every single time you open a terminal, Linux quietly runs a file called ~/.bashrc first. It's a list of commands that set up your terminal — your prompt colours, your shortcuts, your defaults. Think of it as a personal settings file just for the terminal. Open it with nano ~/.bashrc, make your changes, save, then type source ~/.bashrc to load them right away (no need to close and reopen the terminal).
| On Windows | On Linux | What's different |
|---|---|---|
| Notepad | nano | Friendly — the shortcuts are right there at the bottom |
| Notepad++ (for power users) | vim or gedit | vim in the terminal, gedit if you've got a desktop |
| VS Code on Windows | VS Code on Linux | Exactly the same app. Install with Snap or a .deb file. |
| Environment Variables (in System Properties) | ~/.bashrc or /etc/environment | Add a line like export KEY=value |
| Adding to your PATH | export PATH="$HOME/bin:$PATH" in .bashrc | Adds your folder to the front of the existing list |
| Doskey macros (those one-line shortcuts) | alias | e.g. alias ll='ls -la' in .bashrc |
| Windows Terminal profiles | ~/.bashrc or ~/.zshrc | Where you set everything about your shell |
| Programs that run at login (Task Scheduler) | ~/.bash_profile or a systemd user unit | .bash_profile runs once when you sign in |
Handy extras to drop into .bashrc
One line that stops vim ambushing you
Add this single line to the bottom of your ~/.bashrc: export EDITOR=nano. From then on, every Linux tool that needs you to "open the editor" — git when you write a commit message, crontab -e, visudo and a few others — will open nano instead of vim. Once you're comfortable with vim later, swap the line. For now, this is what keeps you out of trouble.
Installing VS Code on Ubuntu
If you already use VS Code on Windows, you'll be happy: it's exactly the same app on Linux. All your extensions, all your keyboard shortcuts, all your habits — they all just work. Install it once and use it for almost everything; keep nano for quick edits in the terminal.
Environment variables — the terminal's labelled drawers
An environment variable is just a labelled value the terminal can read. Think of them as drawers with names on them — EDITOR, PATH, LANG — and inside each drawer is the answer to one question. They decide where the terminal looks for programs, which editor opens for git commit, which language Linux talks to you in. The three you'll change again and again are PATH, EDITOR and LANG.
| Name | What it controls | Check it / set it |
|---|---|---|
PATH | The list of folders the terminal searches when you type a command. ls works because /bin is on the list. | See it: echo $PATH. Add a folder: export PATH="$HOME/bin:$PATH" |
EDITOR | Which editor opens when a tool needs you to type something (git, crontab, visudo). | See it: echo $EDITOR. Set it: put export EDITOR=nano in ~/.bashrc |
LANG | Linux's language. Changes the language of messages, the date format, even how things sort. | See it: echo $LANG. Examples: en_GB.UTF-8, fr_FR.UTF-8 |
HOME | The path to your home folder. When you type cd by itself, this is where you go. | See it: echo $HOME. (Don't change it — Linux sets it for you.) |
PS1 | What your prompt looks like (the "user@host:~$" bit before you type). Change it to whatever you like. | export PS1='\u@\h \w $ ' |
The classic "I just installed it but it says command not found" usually means the program is sitting in a folder like ~/.local/bin/foo, but that folder isn't on your PATH list — so the terminal doesn't know to look there. Fix: add export PATH="$HOME/.local/bin:$PATH" to ~/.bashrc, run source ~/.bashrc, and the command starts working. Saves a lot of head-scratching.
tmux — terminal sessions that don't die when you disconnect
tmux is a tool that does two clever things. First, it splits one terminal window into several panes so you can watch a few things at once. Second — and this is the magical bit — it keeps your terminal sessions running even after you close the window or get disconnected. Start a job over SSH, lose your Wi-Fi, log back in later, ask tmux to bring the session back, and the job is still chugging along right where you left it.
Install it with sudo apt install tmux. The way tmux works is: you press Ctrl+b first (called the "prefix"), let go, then press the next key. So Ctrl+b then d means: hold Ctrl+b, release, then tap d.
| What you want to do | How to do it |
|---|---|
| Start a new session called "work" | tmux new -s work |
| Step out of the session (it keeps running) | Ctrl+b then d |
| See which sessions you have | tmux ls |
| Come back to a session | tmux attach -t work |
| Split the current pane top-and-bottom | Ctrl+b then " |
| Split the current pane side-by-side | Ctrl+b then % |
| Jump between panes | Ctrl+b then an arrow key |
| Close the current pane | Type exit (or press Ctrl+d) |
| Open a new tab inside the session | Ctrl+b then c — switch tabs with Ctrl+b then a number |
The classic moment tmux saves you: you SSH into a server somewhere, run tmux new -s build, start a long backup or build, press Ctrl+b then d to step out, and log off for the night. Tomorrow you SSH back in, type tmux attach -t build, and there it is — the job's finished, the output is still on screen, and nothing was lost when your Wi-Fi dropped.