Master the Ubuntu terminal by customizing the Nano editor, creating shortcuts (Aliases), and writing your first Bash scripts.
Nano is the most beginner-friendly terminal editor. By creating a .nanorc file, we can add features like mouse support, custom colors, and line numbers.
Open your configuration file:
nano ~/.nanorcCopy and paste the following into the file to enable a modern, powerful editor interface:
# --- General Settings ---
set linenumbers # Show line numbers for easy debugging
set autoindent # Match indentation of previous line
set tabsize 4 # Set tabs to 4 spaces
set tabstospaces # Convert tabs to actual spaces
set minibar # A cleaner look for the bottom bar
set softwrap # Wrap long lines so they stay on screen
set positionlog # Re-open files at the last used cursor position
set mouse # Enable mouse clicking and scrolling
# --- Syntax Highlighting ---
include "/usr/share/nano/*.nanorc"
# --- Interface Colors ---
set titlecolor black,yellow # Top Bar/Minibar (Black text on Yellow)
set statuscolor black,yellow # Status messages/pop-ups
set numbercolor yellow # Side bar line numbers
set keycolor yellow # Shortcut keys (^X, ^O, etc.)
set functioncolor yellow # Descriptions of the shortcutsTip
Understanding Keybindings: In Nano documentation, the ^ symbol stands for the Ctrl key, and M (Meta) stands for the Alt key. For example, M-U means Alt + U.
In Ubuntu, the best practice is to keep your shortcuts in a dedicated file called .bash_aliases.
nano ~/.bash_aliasesCopy and paste these functions to automate your system maintenance:
#!/bin/bash
# This is the update & upgrade shortcut.
update() {
echo "Checking for updates and upgrades..."
sudo apt update && sudo apt upgrade -y
echo "Process completed!"
}
# This is the autoremove shortcut.
cleanup() {
sudo apt autoremove
echo "Autoremove process completed!"
}To make these shortcuts work immediately without restarting your terminal, run:
source ~/.bashrcA script allows you to automate repetitive tasks. One of the coolest things about Nano is that it handles file creation and editing at the same time.
nano myscript.shNote
Did you know? If myscript.sh doesn't exist yet, Nano won't give you an error, It will simply open a blank new file for you. Once you save (Ctrl + O), the file is officially created on your system.
Always start with the "Shebang" (#!) so the system knows to use Bash.
#!/bin/bash
echo "Hello! Today is $(date)"
echo "Your current directory is: $(pwd)"By default, Linux blocks files from "running" for security. Give it permission:
chmod +x myscript.shRun your script using the relative path:
./myscript.shOnce you've customized your terminal, these are the essential commands to keep you moving fast.
| Action | Shortcut |
|---|---|
| Save File | Ctrl + O then Enter |
| Exit Nano | Ctrl + X |
- The "Tab" Key: Never type a full file name! Type the first few letters and hit
Tabto auto-complete it. - Stop a Runaway Script: If a script gets stuck in a loop, press
Ctrl + Cto force-kill the process. - Clear the Screen: Type
clearor pressCtrl + Lto wipe the terminal clutter. - Recall Commands: Use the Up/Down arrow keys to cycle through your previous commands.
Caution
This is provided "as is" without warranty of any kind. I am not responsible for any damage, data loss, or issues caused by the use of this information. Use it at your own risk.