sudo !!
to rerun last command as sudo.
history
can be paired with !5
to run the fifth command listed in history.
I believe it’s the fifth oldest - I think !-5
will get you the fifth impost recent, but I was shown that and haven’t put it into practice.
The most common usecase I do is something like history | grep docker
to find docker commands I’ve ran, then use !
followed by the number associated with the command I want to run in history.
@papertowels@lemmy.one I’ve been working in the bash shell since 1993 and did not know sudo !!
was a thing. Good lord, I no longer have to press up, press crtl-left a bunch of times, then type sudo enter space anymore. And I can give it an easy-to-remember alias like ‘resu’ or ‘redo’! Ahahaha, this changes everything! Thank you!!
cd
then ls
then cd
then ls
maybe I’ll throw a ls -a
I really like that cd
command. :P
Hm I wonder, is it really a command? I thought it is just a function of the shell to change the working directory.
tldr
because I am too impatient to read through man pages or google the exact syntax for what I want to do.
There are exactly three kinds of manpages:
- Way too detailed
- Not nearly detailed enough
- There is no manpage
I will take 1 any day over 2 or 3. Sometimes I even need 1, so I’m grateful for them.
But holy goddamn is it awful when I just want to use a command for aguably its most common use case and the flag or option for that is lost in a crowd of 30 other switches or buried under some modal subcommand. grep
helps if you already know the switch, which isn’t always.
You could argue commands like this don’t have “arguably most common usecases”, so manpages should be completely neutral on singling out examples. But I think the existence of tl;dr is the counterargument.
Tangent complaint: I thought the Unix philosophy was “do one thing, and do it well”? Why then do so many of these shell commands have a billion options? Mostly /s but sometimes it’s flustering.
tldr
is great. Basically a crowd-sourced alternative to man
with much more concise entries. Example:
$ tldr dhcpcd
DHCP client.
More information: <https://roy.marples.name/projects/dhcpcd>.
Release all address leases:
sudo dhcpcd --release
Request the DHCP server for new leases:
sudo dhcpcd --rebind