Lesson 19: Advanced Tools & Power User
Goal: Discover modern CLI tools and advanced techniques that boost your productivity.
Table of Contents
- Command History — history
- Terminal Shortcuts
- tmux — Terminal Multiplexer
- Modern Replacements
- Midnight Commander — mc
- Clipboard — xsel & xclip
- System Monitoring — neofetch & fastfetch
- Terminal Browsers
- Fun Tools
- Power User Tips
- Exercises
Command History — history
View history
# Show all history
history
# Show last 20 commands
history 20
# Search history
history | grep "docker"
Reuse history
# Repeat last command
!!
# Repeat with sudo
sudo !!
# Repeat command #542 from history
!542
# Repeat last command starting with "ssh"
!ssh
# Use last argument of previous command
echo "test" > file.txt
cat !$
# Equivalent to: cat file.txt
Interactive search — Ctrl+R
# Press Ctrl+R, then type part of the command
# Press Ctrl+R again to go to the next match
# Press Enter to execute
# Press Ctrl+G or Esc to cancel
History configuration
# Add to ~/.bashrc
# Large history
HISTSIZE=50000
HISTFILESIZE=100000
# Ignore duplicates and commands starting with space
HISTCONTROL=ignoreboth:erasedups
# Append to history file (don't overwrite)
shopt -s histappend
# Save multi-line commands as one entry
shopt -s cmdhist
# Add timestamps to history
HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
Clear history
# Clear current session history
history -c
# Clear history file
> ~/.bash_history
Terminal Shortcuts
Navigation
| Shortcut | Action |
|---|---|
Ctrl + A |
Move cursor to beginning of line |
Ctrl + E |
Move cursor to end of line |
Ctrl + B |
Move back one character |
Ctrl + F |
Move forward one character |
Alt + B |
Move back one word |
Alt + F |
Move forward one word |
Ctrl + XX |
Toggle between start and current position |
Editing
| Shortcut | Action |
|---|---|
Ctrl + U |
Cut from cursor to beginning of line |
Ctrl + K |
Cut from cursor to end of line |
Ctrl + W |
Cut previous word |
Alt + D |
Cut next word |
Ctrl + Y |
Paste (yank) what was cut |
Ctrl + T |
Swap current and previous character |
Alt + T |
Swap current and previous word |
Alt + U |
Uppercase from cursor to end of word |
Alt + L |
Lowercase from cursor to end of word |
Control
| Shortcut | Action |
|---|---|
Ctrl + C |
Cancel current command |
Ctrl + Z |
Suspend current process |
Ctrl + D |
Exit shell / send EOF |
Ctrl + L |
Clear screen |
Ctrl + S |
Freeze terminal output |
Ctrl + Q |
Resume terminal output |
Ctrl + R |
Reverse search history |
tmux — Terminal Multiplexer
tmux lets you run multiple terminal sessions in one window, and they persist after disconnecting.
Install
sudo apt install tmux
Basic usage
# Start a new session
tmux
# Start a named session
tmux new -s mysession
# Detach from session
# Press: Ctrl+B, then D
# List sessions
tmux ls
# Reattach to a session
tmux attach -t mysession
# Kill a session
tmux kill-session -t mysession
tmux key bindings
All tmux commands start with the prefix key: Ctrl + B
Window management
| Keys | Action |
|---|---|
Ctrl+B c |
Create new window |
Ctrl+B n |
Next window |
Ctrl+B p |
Previous window |
Ctrl+B 0-9 |
Switch to window number |
Ctrl+B , |
Rename window |
Ctrl+B & |
Close window |
Ctrl+B w |
List windows |
Pane management (split screen)
| Keys | Action |
|---|---|
Ctrl+B % |
Split vertically |
Ctrl+B " |
Split horizontally |
Ctrl+B arrows |
Switch between panes |
Ctrl+B x |
Close current pane |
Ctrl+B z |
Toggle pane zoom (fullscreen) |
Ctrl+B Space |
Cycle pane layouts |
Ctrl+B { |
Move pane left |
Ctrl+B } |
Move pane right |
tmux configuration
cat > ~/.tmux.conf << 'EOF'
# Enable mouse support
set -g mouse on
# Start window numbering at 1
set -g base-index 1
# Start pane numbering at 1
setw -g pane-base-index 1
# Increase history limit
set -g history-limit 50000
# Status bar
set -g status-style bg=black,fg=white
set -g status-left '[#S] '
set -g status-right '%H:%M %d-%b-%Y'
EOF
Practical: SSH + tmux workflow
# 1. SSH into server
ssh myserver
# 2. Start a tmux session
tmux new -s deploy
# 3. Run your long-running task
./deploy.sh
# 4. Detach: Ctrl+B, then D
# 5. Disconnect SSH (task keeps running!)
exit
# 6. Later, reconnect and reattach
ssh myserver
tmux attach -t deploy
Modern Replacements
bat — Better cat
sudo apt install bat
# On Ubuntu, the command might be 'batcat'
# Usage
bat script.py # syntax highlighting
bat -n script.py # with line numbers only
bat --diff file.txt # show git changes
lsd — Better ls
# Install via cargo or snap
sudo snap install lsd
lsd # colorful icons
lsd -la # detailed view
lsd --tree # tree view
exa/eza — Better ls (alternative)
sudo apt install eza
eza # basic list
eza -la # detailed with hidden
eza --tree --level=2 # tree view
eza --git # show git status
fd — Better find
sudo apt install fd-find
# Command might be 'fdfind' on Ubuntu
fdfind "*.py" # find Python files
fdfind -t d config # find directories named config
fdfind -e log --size +1m # find .log files > 1 MB
ripgrep (rg) — Better grep
sudo apt install ripgrep
rg "TODO" . # search recursively (auto)
rg -i "error" /var/log/ # case insensitive
rg -t py "import" # search only Python files
rg --hidden "config" # include hidden files
Midnight Commander — mc
A two-panel file manager for the terminal.
sudo apt install mc
mc
Key shortcuts in mc
| Key | Action |
|---|---|
Tab |
Switch panels |
F3 |
View file |
F4 |
Edit file |
F5 |
Copy |
F6 |
Move/rename |
F7 |
Create directory |
F8 |
Delete |
F9 |
Menu |
F10 |
Quit |
Ctrl+O |
Toggle panels (show terminal) |
Clipboard — xsel & xclip
Copy and paste between terminal and GUI clipboard.
# Install
sudo apt install xsel xclip
Usage
# Copy command output to clipboard
echo "Hello" | xclip -selection clipboard
# Paste from clipboard
xclip -selection clipboard -o
# Copy a file's content to clipboard
cat file.txt | xclip -selection clipboard
# Copy your public SSH key
cat ~/.ssh/id_ed25519.pub | xclip -selection clipboard
echo "SSH key copied to clipboard!"
# Shortcut alias (add to .bashrc)
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
System Monitoring — neofetch & fastfetch
fastfetch (modern, fast)
sudo apt install fastfetch
fastfetch
neofetch (classic)
sudo apt install neofetch
neofetch
Both display system info with ASCII art — popular for screenshots and dotfile showcases.
Terminal Browsers
links2
sudo apt install links2
links2 https://example.com
lynx
sudo apt install lynx
lynx https://example.com
Useful for testing websites from servers without a GUI.
Fun Tools
# ASCII art text
sudo apt install figlet
figlet "Hello Linux"
# Colorful system info
sudo apt install lolcat
neofetch | lolcat
# Matrix rain
sudo apt install cmatrix
cmatrix
# Cowsay
sudo apt install cowsay
cowsay "I love Linux"
# Fortune + cowsay combo
sudo apt install fortune-mod
fortune | cowsay
# Train animation
sudo apt install sl
sl
# Internet speed test
sudo apt install speedtest-cli
speedtest-cli
Power User Tips
Brace expansion
# Create multiple files/dirs
mkdir -p project/{src,tests,docs}
touch file{1..5}.txt
echo {A..Z}
echo {01..12}
# Backup with rename
cp config.yaml{,.bak}
# Equivalent to: cp config.yaml config.yaml.bak
Process substitution
# Compare outputs of two commands
diff <(ls dir1/) <(ls dir2/)
# Compare sorted files without temporary files
diff <(sort file1.txt) <(sort file2.txt)
Quick calculations
# bc - calculator
echo "scale=2; 100/3" | bc
# Output: 33.33
# Bash arithmetic
echo $((256 * 1024))
# Python one-liner
python3 -c "print(2**32)"
Quick file server
# Serve current directory on port 8000
python3 -m http.server 8000
# Accessible at http://localhost:8000
Quick JSON formatting
# Pretty-print JSON
curl -s https://api.github.com | python3 -m json.tool
# Or with jq (install: sudo apt install jq)
curl -s https://api.github.com | jq .
Record your terminal session
# Start recording
script session.log
# Do your work...
# Stop recording
exit
# Replay
cat session.log
Exercises
Exercise 1: History mastery
# 1. Show last 10 commands
history 10
# 2. Search for a past command
history | grep "apt"
# 3. Use Ctrl+R to find a command
# Press Ctrl+R, type "ssh", press Enter
# 4. Repeat the last command with sudo
echo "test"
sudo !!
Exercise 2: Try modern tools
# 1. Install and try bat
sudo apt install -y bat
batcat ~/.bashrc # Ubuntu uses 'batcat'
# 2. Install and try ripgrep
sudo apt install -y ripgrep
rg "alias" ~/.bashrc
Exercise 3: tmux basics
# 1. Start a named session
tmux new -s practice
# 2. Split the screen vertically
# Press: Ctrl+B %
# 3. Run 'htop' in one pane, navigate to the other
# Press: Ctrl+B (arrow key)
# 4. Detach
# Press: Ctrl+B d
# 5. Reattach
tmux attach -t practice
# 6. Kill the session
tmux kill-session -t practice
Key Takeaways
history+Ctrl+R— never retype a command- Terminal shortcuts (
Ctrl+A/E/U/K/W) — edit commands blazingly fast tmux— persistent sessions, split panes, essential for remote work- Modern tools:
bat> cat,rg> grep,fd> find,eza> ls mc— visual file manager in the terminalpython3 -m http.server— instant file serverjq— parse JSON on the command line- Fun tools add personality to your terminal setup
Congratulations!
You've completed the Linux Terminal Course! You now have a solid foundation in:
- Navigating the filesystem
- Managing files, directories, and permissions
- Searching and processing text
- Managing packages, processes, and services
- Networking, SSH, and remote file transfer
- Shell customization and advanced tools
Keep practicing, keep experimenting, and keep learning!