Lesson 4.2: Terminal Applications
Beyond basic commands, Linux offers powerful terminal applications that can handle text editing, file management, system monitoring, and more. These tools often outperform their graphical counterparts in speed and efficiency.
Text Editors
Text editors are the most common terminal applications. Ubuntu comes with several options:
nano - Beginner-Friendly Editor
nano is the easiest terminal text editor for beginners:
nano shows keyboard shortcuts at the bottom of the screen:
- Ctrl + O: Save file (Write Out)
- Ctrl + X: Exit nano
- Ctrl + W: Search text
- Ctrl + K: Cut line
- Ctrl + U: Paste line
- Ctrl + G: Get help
Creating a file with nano
vim - Powerful Editor
vim (Vi IMproved) is a powerful modal editor with a steep learning curve:
vim has two main modes:
- Normal mode: For navigation and commands (press Esc)
- Insert mode: For typing text (press i)
Basic vim workflow
emacs - Extensible Editor
emacs is another powerful editor known for its extensibility:
Basic emacs shortcuts:
- Ctrl + X, Ctrl + S: Save file
- Ctrl + X, Ctrl + C: Exit emacs
- Ctrl + G: Cancel current command
File Management Tools
mc - Midnight Commander
Midnight Commander is a visual file manager that runs in the terminal:
mc features:
- Dual-panel interface (like Norton Commander)
- Keyboard shortcuts for common operations
- Built-in text editor and viewer
- FTP/SFTP support
tree - Directory Tree View
tree shows directory structure in a tree format:
ncdu - Disk Usage Analyzer
ncdu (NCurses Disk Usage) helps find what's using disk space:
System Monitoring Tools
htop - Interactive Process Viewer
htop is an improved version of the traditional top command:
htop features:
- Color-coded process display
- Interactive sorting and filtering
- Tree view of processes
- Kill processes with F9
- Scrollable process list
iotop - I/O Monitoring
iotop shows which processes are using disk I/O:
nethogs - Network Monitoring
nethogs shows network usage by process:
Network Tools
ping - Network Connectivity
ping tests network connectivity to a host:
curl - Web Content Retrieval
curl transfers data from URLs:
Example Domain
This domain is for use in illustrative examples in documents.
wget - File Downloading
wget downloads files from the web:
Text Processing Tools
less - File Viewer
less is a powerful file viewer with search capabilities:
less navigation:
- ↑/↓: Scroll up/down
- Page Up/Down: Scroll by page
- /text: Search for text
- n: Next search result
- q: Quit
grep - Text Search
grep searches for patterns in files:
sed - Stream Editor
sed performs text transformations:
awk - Text Processing
awk processes text files column by column:
Archive and Compression Tools
tar - Archive Files
tar creates and extracts archive files:
tar options:
- -c: Create archive
- -x: Extract archive
- -t: List contents
- -z: Compress with gzip
- -f: Specify filename
zip/unzip - ZIP Files
Development Tools
git - Version Control
git is essential for managing code:
make - Build Automation
make automates compilation and build processes:
Terminal Multiplexers
tmux - Terminal Multiplexer
tmux allows multiple terminal sessions in one window:
tmux basics:
- Ctrl + B, c: Create new window
- Ctrl + B, n: Next window
- Ctrl + B, p: Previous window
- Ctrl + B, d: Detach session
- tmux attach: Reattach session
screen - Terminal Multiplexer
screen is another terminal multiplexer:
Practice Exercises
Exercise 1: Text Editor Practice
- Use nano to create a file called "notes.txt"
- Add 3 lines of text about what you've learned
- Save and exit nano
- Use cat to verify the file contents
Click for solution
Exercise 2: File Processing
- Create a file with multiple lines of text
- Use grep to find lines containing a specific word
- Use sed to replace a word in the file
- Use awk to extract a specific column
Click for solution
Exercise 3: System Monitoring
- Install and run htop to see running processes
- Use ping to test connectivity to a website
- Use curl to retrieve a web page
- Use wget to download a small file
Click for solution
Choosing the Right Tool
With so many terminal applications, here's when to use each:
For Text Editing:
- nano: Quick edits, beginners
- vim: Power editing, programming
- emacs: Extensible, complex projects
For File Management:
- mc: Visual file management
- tree: Directory overview
- ncdu: Disk usage analysis
For System Monitoring:
- htop: Process monitoring
- iotop: I/O monitoring
- nethogs: Network monitoring
What's Next?
You now have a solid foundation in terminal applications! These tools will be invaluable as we move on to desktop environments and package management.
Key Takeaways
- nano is the easiest terminal editor for beginners
- vim offers powerful editing once you learn its modes
- htop provides better process monitoring than top
- grep, sed, and awk are essential for text processing
- tmux and screen enable persistent terminal sessions
- Terminal apps work over SSH and use fewer resources
Linux 101