I have another document with some other tricks we didn't cover last night here: https://gist.github.com/rubbsdecvik/431adebd1daa2aecfcc333d3a433e9c4
For example:
Run a command.
input:
whoami
output:
pregan
Then use !! to substitute:
input:
sudo !!output:
root
Run a command:
input:
echo foooutput:
fooThen use ^foo^bar to swap the string
input:
^foo^barThis will change the command to echo bar.
output:
barYou can put a command into your editor with fc which will put the previous command into an editing session. Once you save and quit, it will execute the contents of your editor buffer.
First you will need to install pv
On Fedora systems:
sudo dnf install pvOn Red Hat systems:
sudo yum install pvOn Debian/Ubuntu:
sudo apt install pvThen you can use it anywhere you can use cat but the stderr will now contain a progress bar.
For example:
pv Downloads/Fedora-Workstation-Live-x86_64-24-1.2.iso > /dev/nullRun a command
input:
mkdir devopsThen use `!$! to get the last "word" from the previous command
input:
cd !$This will change directories to devops
When you are grepping through a list of ps output, you will match on the very search you're making.
input:
ps aux | grep bashoutput:
pregan 6925 0.0 0.0 133788 4976 pts/13 Ss Feb17 0:00 bash
pregan 7672 0.0 0.0 119376 960 pts/11 S+ 12:47 0:00 grep --color=auto bash
pregan 9390 0.0 0.0 134304 5672 pts/7 Ss+ Mar02 0:00 -bash
You can remove that by using [] within your grep search.
input:
ps aux | grep [b]ashoutput:
pregan 6925 0.0 0.0 133788 4976 pts/13 Ss Feb17 0:00 bash
pregan 9390 0.0 0.0 134304 5672 pts/7 Ss+ Mar02 0:00 -bash
You can use alias to see a list of your aliases and then how to use the alias command to create new ones.
One useful one is:
alias bel='tput bel'After this alias has been created, you then can use the command bel to make your terminal make a noise.
Tmux is a multiplexer, which just means it can act as multiple terminals inside the same terminal session. This is very helpful if you are connected via ssh. You can learn more about Tmux here.