Useful Bash Commands
-
Linux
CommandLine
CommandOfTheDay
Bash
Overview
- Shortcuts
- Clear Terminal
- Run Previous Command With Root/Sudo Privilege
- Run Previous Command With Search/Replace For First Instance
- Run Previous Command With Search/Replace For All The Instance
- Execute Command Without Saving in History
- Paste Last Argument of Most Recent Command
- Paste Selected Argument
- Reset Terminal
- Display Mount Filesystem in Nice Layout
- ASCII Table
- Compare Remote File with Local File
- Decide Which Command Run On Success and Fail
- Execute Command After Every 2 Seconds
- Check Last Command Status
NOTE!: If you feel some commands are missing in this post,
Feel free to add those commands in below comments box.
Shortcuts
/---------------------------------------------------------------------------------------\ | !! Repeat last command | | !char Repeat last command That started with char | | !num Repeat a command by its number in history output | | | | !-n Repeat a command entered n command back | | !?abc Repeat last command that contains (as opposed to ?started with?) abc | \---------------------------------------------------------------------------------------/
/---------------------------------------------------------------\ | UP DOWN Keys Scroll through previous commands | | Ctrl+r Reverse-i-search | \---------------------------------------------------------------/
Clear Terminal
Run Previous Command With Root/Sudo Privilege
Run Previous Command With Search/Replace For First Instance
Run Previous Command With Search/Replace For All The Instance
Execute Command Without Saving in History
- Prepending one or more spaces to your command won’t be saved in history.
NOTE!: HISTCONTROL=ignorespace
will ignore just the commands that begin with a space.
Use HISTCONTROL=ignoreboth
if you also want to ignore duplicates.
Paste Last Argument of Most Recent Command
/-----------------------------------------------------------------------\ | Esc . The escape key followed by a period. | | Alt+. Hold down alt key while pressing the period. | | !$ Only valid for last argument | \-----------------------------------------------------------------------/
Paste Selected Argument
- This comes in handy when you’ve written a long command with multiple arguments and you want to reuse one of them.
Reset Terminal
- Sometime we send binary output to the terminal, Which make terminal not useable.
- The
reset
command reset your terminal, Note that when you type reset its won’t properly echo back on terminal.
Display Mount Filesystem in Nice Layout
ASCII Table
Compare Remote File with Local File
Decide Which Command Run On Success and Fail
Execute Command After Every 2 Seconds
Check Last Command Status
- If command run Successfully then exit status is zero
- If command doesn’t run Successfully then exit status is non-zero
Newsletter
Get updated when I create new content.
Unsubscribe whenever. Never any spam.