Ready to level up? Since you've mastered the basics, here are some advanced terminal shortcuts and tricks that "power users" use to work faster in the LabEx environment.
1. Advanced History Manipulation
Beyond just the arrow keys, you can interact with your command history using the ! (exclamation mark) operator:
!string: Runs the most recent command that starts with "string". For example,!dawould automatically rundateif that was your last command starting with those letters.!$: This represents the last argument of the previous command.- Example: If you just typed
echo "Hello LabEx", you could then typeprint !$and it would act as if you typedprint "Hello LabEx".
- Example: If you just typed
history: Type this command to see a numbered list of every command you've typed in this session.
2. Powerful Process Management
Ctrl + Z: Suspends (pauses) a running process and puts it in the background. You can get back to it later by typingfg(foreground).Ctrl + S: Freezes the terminal output (useful if a lot of text is scrolling by too fast to read).Ctrl + Q: Unfreezes the terminal after usingCtrl + S.
3. Cursor "Surgery"
If you have a very long command and made a typo in the middle:
Alt + D: Delete the word after the cursor.Ctrl + T: Swap the character under the cursor with the one before it (great for fixing typos likeeckotoecho).Alt + T: Swap the current word with the previous word.
4. Terminal Control
Ctrl + Shift + C/Ctrl + Shift + V: These are often used for Copy and Paste inside the Linux terminal (sinceCtrl+Cis reserved for stopping processes).reset: If your terminal screen gets "garbled" with strange symbols (which sometimes happens if you try to read a binary file), typingresetre-initializes the entire terminal window settings.
5. Multi-Command Magic
You can run multiple commands at once using these symbols:
;(Semicolon): Run commands one after another.- Try:
clear; date; cal
- Try:
&&(Logical AND): Run the second command only if the first one was successful.- Try:
echo "Success" && date
- Try:
Challenge: Try combining them! Type clear && echo "The date is:" && date.
Which of these feels like it would save you the most time?