AI Hints
Home›Linux Tutorial›Troubleshooting and Tricks
Linux · Lesson 116 of 120

Productivity Tricks

Work faster in the terminal.

⏱ 2 min read▶ Video at 2:35:38🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

Experienced Linux users type surprisingly little. They know a handful of tricks that save thousands of keystrokes. Here are the best ones.

Productivity Tricks
From the video: Productivity Tricks
  • Experts type little
  • A handful of tricks
  • Thousands of keystrokes saved

Brace expansion

Curly braces expand into several words. Make dir dash P project, with src, docs, and tests in braces, makes three folders in one go. CP notes dot TXT, comma dot bak, copies the file to notes dot TXT dot bak. And braces with dot dot count for you.

Terminal
mkdir -p project/{src,docs,tests} && ls project
docs  src  tests
cp notes.txt{,.bak} && ls notes*
notes.txt  notes.txt.bak
echo file{1..5}.txt
file1.txt file2.txt file3.txt file4.txt file5.txt

Jumping back

CD dash takes you back to the folder you were just in, and prints it. Run it again, and you jump back again. It's perfect for switching between two folders.

Terminal
cd /var/log
cd -
/home/sam
cd -
/var/log

Shortcuts to remember

Bang bang repeats the last command, so sudo bang bang reruns it with sudo, when you forgot. Control R searches your history as you type. Alt dot pastes the last argument of the previous command. And control L clears the screen, just like clear.

keyvalue
sudo !!last command, with sudo
Ctrl + Rsearch your history
Alt + .last argument again
Ctrl + Lclear the screen

Summary

Braces make many names at once, CD dash jumps back, sudo bang bang fixes a forgotten sudo, and control R finds old commands. Next, getting ready for Linux interview questions.

Key takeaways
  • mkdir -p a/{b,c}
  • cd -
  • sudo !! and Ctrl + R
Next up: Interview Questions: Part 1 — files, processes, pipes