CIS120 Linux Fundamentals by Scott Shaper

Keyboard Tricks

Think of keyboard tricks in Linux like having a super-powered keyboard that can do more than just type letters. Just like how video games have special key combinations for special moves, Linux gives you powerful shortcuts to work faster and smarter. These tricks help you type less and do more!

Quick Reference

Category What It Does Common Use
Cursor Movement Move around in commands Editing commands quickly
Text Editing Modify text in commands Fixing typos, changing words
Cut & Paste Move text around Reusing parts of commands
Completion Auto-complete commands Typing less, working faster
History Reuse past commands Running commands again

When to Use Keyboard Tricks

Cursor Movement

Think of cursor movement commands like having a teleport button for your cursor. Instead of holding down arrow keys, you can jump to exactly where you need to be!

Key What It Does When to Use It
Ctrl-a Go to start of line When you need to add something at the beginning
Ctrl-e Go to end of line When you need to add something at the end
Ctrl-f Move forward one character When you need to move right (same as right arrow)
Ctrl-b Move backward one character When you need to move left (same as left arrow)
Alt-f Move forward one word When you need to jump over a word
Alt-b Move backward one word When you need to jump back a word
Ctrl-l Clear screen When your screen is cluttered

Text Editing

Think of text editing commands like having a magic eraser and pen. You can fix mistakes, change words, and transform text without retyping everything!

Key What It Does When to Use It
Ctrl-d Delete character at cursor When you need to delete one character
Ctrl-t Swap two characters When you type letters in wrong order
Alt-t Swap two words When you type words in wrong order
Alt-l Make word lowercase When you need to fix capitalization
Alt-u Make word uppercase When you need to capitalize a word

Cut and Paste (Kill and Yank)

Think of cut and paste commands like having a clipboard for your terminal. You can save parts of commands and use them later!

Key What It Does When to Use It
Ctrl-k Cut to end of line When you want to save the end of a command
Ctrl-u Cut to start of line When you want to save the beginning of a command
Alt-d Cut to end of word When you want to save the end of a word
Alt-Backspace Cut to start of word When you want to save the beginning of a word
Ctrl-y Paste cut text When you want to use saved text

Command Completion

Think of command completion like having an assistant that finishes your sentences. Just type part of a command and let the computer help you complete it! When you press Tab, the shell tries to complete what you're typing based on what it knows about commands, files, and directories.

How Completion Works

# Basic completion
ls D[TAB] → ls Documents/

# When there are multiple matches, press Tab twice
ls D[TAB][TAB]
Documents/  Downloads/  Desktop/

# When there are many matches (over 100), you'll see:
ls *[TAB]
Display all 150 possibilities? (y or n)

# When there are no matches, you'll hear a beep
ls nonexistent[TAB] → *beep*

Smart Completion Features

Practical Examples

# Type 'ls D' and press Tab
ls Documents/

# Type 'ls D' and press Tab twice to see all D* matches
ls D[TAB][TAB]
Documents/  Downloads/  Desktop/

# Type 'ls *.txt' and press Tab twice to see all .txt files
ls *.txt[TAB][TAB]
file1.txt  file2.txt  file3.txt  ...

# Type 'cd ~/D' and press Tab
cd ~/Downloads/

# When there are many matches, you'll be asked:
ls *[TAB]
Display all 150 possibilities? (y or n)
# Type 'y' to see all matches, 'n' to cancel
Key What It Does When to Use It
Tab Complete command/filename When you know part of a name
Alt-? Show all possibilities When you want to see all options
Alt-* Insert all possibilities When you want to use all matches

Command History

Think of command history like having a time machine for your commands. You can go back and reuse any command you've typed before!

Practical Examples

# Run the last command again
!!

# Run command number 88
!88

# Run the last command starting with 'ls'
!ls

# Run the last command containing 'grep'
!?grep
Command What It Does When to Use It
!! Run last command When you want to run the same command again
!number Run command by number When you know the command number
!string Run last command starting with string When you remember how the command started
!?string Run last command containing string When you remember part of the command

Tips for Success

Common Mistakes to Avoid

Best Practices

Advanced Techniques

Combining Shortcuts

# Edit a long command: Ctrl-a to start, then edit
# Use Alt-f and Alt-b to move by words
# Use Ctrl-k to cut parts you don't need
# Use Ctrl-y to paste them back if needed

# Use history with completion
!ls *.txt  # Run last ls command with .txt files

# Use multiple completions
cd ~/D[TAB]  # Complete to Downloads
ls *.txt[TAB]  # Show all .txt files