68 points

sudo !! to rerun last command as sudo.

history can be paired with !5 to run the fifth command listed in history.

permalink
report
reply
5 points

Fifth as in fifth most recent command or fifth oldest?

permalink
report
parent
reply
7 points
*

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.

permalink
report
parent
reply

@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!!

permalink
report
parent
reply
2 points

We’re all learning tricks in this thread! Grateful for all y’all nerds.

permalink
report
parent
reply
1 point

Love these, I used a terminal select from history with fuzzy finding to do the !5 as redo

permalink
report
parent
reply
56 points
*

cd then ls then cd then ls maybe I’ll throw a ls -a

permalink
report
reply
13 points

I use -A instead, which doesn’t show “.” and “…”

permalink
report
parent
reply
9 points

Nah you gotta alias ls -a to la for more efficiency.

permalink
report
parent
reply
2 points

l

permalink
report
parent
reply
2 points

Don’t forget your pwd thrown in to get back your bearings!

permalink
report
parent
reply
1 point

Done be silly, that’s part of my prompt.

permalink
report
parent
reply
44 points

I really like that cd command. :P

permalink
report
reply
19 points

You’ll love zoxide then.

permalink
report
parent
reply
0 points
*
Deleted by creator
permalink
report
parent
reply
20 points

The command is ‘z’

permalink
report
parent
reply
3 points

On arch the command is just z

permalink
report
parent
reply
3 points

When you set it up you tell it which command you want. Default is “cdi” but I changed it to “cd” immediately.

permalink
report
parent
reply
5 points

Hm I wonder, is it really a command? I thought it is just a function of the shell to change the working directory.

permalink
report
parent
reply
8 points

A command is anything you execute in the shell.

cd is just a built-in command

permalink
report
parent
reply
41 points

tldr because I am too impatient to read through man pages or google the exact syntax for what I want to do.

permalink
report
reply
26 points

There are exactly three kinds of manpages:

  1. Way too detailed
  2. Not nearly detailed enough
  3. 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.

permalink
report
parent
reply
8 points

tldr is the first of 4 ways I rtfm. Then -h, man, and then the arch wiki

permalink
report
parent
reply
4 points

i never use man at all. It’s just too confusing.

permalink
report
parent
reply
38 points

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
permalink
report
reply
9 points

Well…slap my ass and call me Mary…
Thanks kind internet stranger!

permalink
report
parent
reply
4 points

:O

permalink
report
parent
reply
3 points

Woah, that’s dope as heck. Thank you!

permalink
report
parent
reply

Asklemmy

!asklemmy@lemmy.ml

Create post

A loosely moderated place to ask open-ended questions

Search asklemmy 🔍

If your post meets the following criteria, it’s welcome here!

  1. Open-ended question
  2. Not offensive: at this point, we do not have the bandwidth to moderate overtly political discussions. Assume best intent and be excellent to each other.
  3. Not regarding using or support for Lemmy: context, see the list of support communities and tools for finding communities below
  4. Not ad nauseam inducing: please make sure it is a question that would be new to most members
  5. An actual topic of discussion

Looking for support?

Looking for a community?

Icon by @Double_A@discuss.tchncs.de

Community stats

  • 9.9K

    Monthly active users

  • 3.4K

    Posts

  • 73K

    Comments