I started a vi session, forgot to do it as root, and now I can't save it
:w !sudo tee %
Dammit, this became a real issue when I started implementing sudo in my daily life. You need sudo (with correct permissions to the current account) and tee installed, which these days, is real common.
I want to run a long, complex-assed command again, but with one minor change
I found myself doing this with some complicated for-while loops at the command line during DNS dig queries. !! (pronounced, "bang bang" ...really) is also useful for "run last command" when you get into sudo problems.
[you@localhost]$ make sandwich You do not have permissions to do this. [you@localhost]$ sudo !! Enter sudo password:
All set! Note: ^foo^bar also works on MOST systems, but it only works on the FIRST match, and the rest are ignored.
I did an ls to a directory, now I want to cd to it
cd [esc] .
That's the command, the escape key, and a period. It will fill in the last parameter. !$ (bang dollar-sign) also works.
How to I write to dev null again? Fucking hate crontab reports.
[command] > /dev/null 2>&1
I forget the order of the 2 and 1 and & symbol all the time
Maybe this will help others.