DEV Community

Cover image for 10 Handy Linux Terminal Tricks Every Beginner Should Know
mio_sushi_mio
mio_sushi_mio

Posted on

10 Handy Linux Terminal Tricks Every Beginner Should Know

10 Handy Linux Terminal Tricks Every Beginner Should Know

Hi, I'm Mio! πŸ‘‹

You've learned the basic commands β€” now let's make your terminal life a little more enjoyable.
Here are 10 small but powerful tricks I use all the time.


1. !! β€” Re-run the Previous Command

$ ls
$ !!
Enter fullscreen mode Exit fullscreen mode

Repeats the exact command you just ran. Simple, but surprisingly handy.


2. !ls β€” Recall a Past Command by Name

$ !ls
Enter fullscreen mode Exit fullscreen mode

Runs the most recent ls command from your history β€” no need to scroll through history.


3. history | grep β€” Search Your Command History

$ history | grep ssh
  53  ssh user@192.168.0.10
 104  ssh user@example.com
Enter fullscreen mode Exit fullscreen mode

Can't remember a command you ran last week? Pipe history into grep and find it instantly.


4. alias β€” Create Your Own Shortcuts

$ alias ll='ls -la'
$ ll
Enter fullscreen mode Exit fullscreen mode

Tired of typing long commands? Create an alias. Add it to ~/.bashrc to make it permanent.


5. Tab Completion β€” Let the Terminal Type for You

$ cd Doc<Tab>
$ cd Documents/
Enter fullscreen mode Exit fullscreen mode

Press Tab to auto-complete file and directory names. Fewer typos, faster workflow.


6. Ctrl+A and Ctrl+E β€” Jump to Start or End of Line

  • Ctrl+A β†’ move to the beginning of the line
  • Ctrl+E β†’ move to the end of the line

A lifesaver when editing long commands.


7. Ctrl+C and Ctrl+Z β€” Stop or Pause a Process

  • Ctrl+C β†’ force quit a running process
  • Ctrl+Z β†’ suspend it (bring it back with fg)

8. >, >>, 2> β€” Redirect Output

$ ls > out.txt            # overwrite
$ ls >> out.txt           # append
$ ls notfound 2> err.txt  # redirect error output
Enter fullscreen mode Exit fullscreen mode

Great for saving logs or separating errors from normal output.


9. | less β€” Read Long Output One Page at a Time

$ dmesg | less
Enter fullscreen mode Exit fullscreen mode

When output overflows your screen, pipe it into less. Press q to quit.


10. clear vs reset β€” Clean Up Your Terminal

  • clear β†’ visually clears the screen (history stays)
  • reset β†’ fully reinitializes the terminal (useful when things look broken)

Bonus: Ctrl+R β€” Reverse Search Your History

(reverse-i-search)`ssh': ssh user@example.com
Enter fullscreen mode Exit fullscreen mode

Press Ctrl+R and start typing β€” it instantly finds matching commands from your history.
This is probably the most underrated shortcut in the terminal.


Quick Summary

Trick What it does
!! Re-run last command
!cmd Re-run last cmd
`history \ grep`
alias Create shortcuts
Tab Auto-complete
Ctrl+A / Ctrl+E Jump to line start/end
Ctrl+C / Ctrl+Z Stop / suspend process
> >> 2> Redirect output
`\ less`
clear / reset Clean up terminal
Ctrl+R Reverse history search

You don't need to memorize all of these at once.
Try one, feel the "oh, that's useful!" moment β€” and it's yours. ✨


πŸ’‘ Want to practice these right now?

Penguin Gym Linux is a free, browser-based Linux terminal where you can run real commands without installing anything.
No setup. Just open and start typing. 🐧

Top comments (0)