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 foo
output:
foo
Then use ^foo^bar
to swap the string
input:
^foo^bar
This will change the command to echo bar
.
output:
bar
You 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 pv
On Red Hat systems:
sudo yum install pv
On Debian/Ubuntu:
sudo apt install pv
Then 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/null
Run a command
input:
mkdir devops
Then 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 bash
output:
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]ash
output:
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.