this post was submitted on 21 Sep 2024
218 points (96.6% liked)

Asklemmy

43597 readers
1474 users here now

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_[email protected]~

founded 5 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] 71 points 3 weeks ago (5 children)

sudo !! to rerun last command as sudo.

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

load more comments (5 replies)
[–] [email protected] 56 points 3 weeks ago* (last edited 3 weeks ago) (5 children)

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

[–] [email protected] 13 points 3 weeks ago

I use -A instead, which doesn't show "." and ".."

load more comments (4 replies)
[–] [email protected] 45 points 3 weeks ago (3 children)

I really like that cd command. :P

[–] [email protected] 20 points 3 weeks ago (8 children)
load more comments (8 replies)
load more comments (2 replies)
[–] [email protected] 41 points 3 weeks ago (1 children)

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

[–] [email protected] 27 points 3 weeks ago (7 children)

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.

load more comments (7 replies)
[–] [email protected] 38 points 3 weeks ago (1 children)

sudo udevadm monitor

Figuring out which usb device went on holiday.

load more comments (1 replies)
[–] [email protected] 38 points 3 weeks ago (4 children)

I went a little overboard and wrote a one-liner to accurately answer this question

history|cut -d " " -f 5|sort|uniq -c|sort -nr|head -5

Note: history displays like this for me 20622 2023-02-18 16:41:23 ls I don't know if that's because I set HISTTIMEFORMAT='%F %T ' in .bashrc, or if it's like that for everyone. If it's different for you change -f 5 to target the command. Use -f 5-7 to include flags and arguments.

My top 5 (since last install)

   2002 ls
   1296 cd
    455 hx
    427 g
    316 find

g is an alias for gitui. When I include flags and arguments most of the top commands are aliases, often shortcuts to a project directory.

Not to ramble, but after doing this I figured I should alias the longest, most-used commands (even aliasing ls to l could have saved 2002 keystrokes :P) So I wrote another one-liner to check for available single characters to alias with:

for c in a b c d e f g h i j k l m n o p q r s t u v w x y z; do [[ ! $(command -v $c) ]] && echo $c; done

In .bash_aliases I've added alias b='hx ${HOME}/.bash_aliases' to quickly edit aliases and alias r='source ${HOME}/.bashrc' to reload them.

[–] [email protected] 10 points 3 weeks ago (3 children)
load more comments (3 replies)
load more comments (3 replies)
[–] [email protected] 38 points 3 weeks ago (3 children)

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
load more comments (3 replies)
[–] [email protected] 37 points 3 weeks ago (1 children)

Sudo !!

It reruns the last command as sudo.

Pretty useful since I'm always forgetting.

load more comments (1 replies)
[–] [email protected] 36 points 3 weeks ago (2 children)

control+R

in bash, it lets you quickly search for previously executed commands.

its very useful and makes things much quicker, i recommend you give it a try.

load more comments (2 replies)
[–] [email protected] 32 points 3 weeks ago (21 children)

Since nobody has said yet, I use screen pretty heavily. Want to run a long running task, starting it from your phone? Run screen to create a detachable session then the long running command. You can then safely close out of your terminal or detach with ctrl a, d and continue in your terminal doing something else. screen -r to get back to it.

load more comments (21 replies)
[–] [email protected] 31 points 3 weeks ago (7 children)

clear because apparently I am too scatterbrained to comprehend more than one full page of text in the terminal

load more comments (7 replies)
[–] [email protected] 26 points 3 weeks ago (3 children)

Not a specific command, but I learned recently you can just dump any executable script into ~/bin and run it from the terminal.

I suffer greatly from analysis paralysis, I have a very hard time making decisions especially if there's many options. So I wrote a script that reads a text file full of tasks and just picks one. It took me like ten minutes to write and now I spend far more time doing stuff instead of doing nothing and feeling badly that I can't decide what to do.

[–] [email protected] 23 points 3 weeks ago

This is because $HOME/bin is in your $PATH environment variable. You can add more paths that you'd like to execute scripts from, like a personal git repo that contains your scripts.

[–] [email protected] 19 points 3 weeks ago

I think the standard is ~/.local/bin, for the people that like standards.

load more comments (1 replies)
[–] [email protected] 25 points 3 weeks ago (5 children)

pushd and popd to change directory and go back when done there.

load more comments (5 replies)
[–] [email protected] 24 points 3 weeks ago* (last edited 3 weeks ago)

After using too much WINE, I type pwd, whoami

[–] [email protected] 22 points 3 weeks ago (4 children)

clear. Constantly, and for no reason.

[–] [email protected] 31 points 3 weeks ago (4 children)
[–] [email protected] 26 points 3 weeks ago (1 children)

Oh. I know. But you don't understand - I'm compelled to type it out. I must.

load more comments (1 replies)
load more comments (3 replies)
load more comments (3 replies)
[–] [email protected] 21 points 3 weeks ago

pv (Pipe Viewer) is a command line tool to view verbose information about data streamed/piped through it. The data can be of any source like files, block devices, network streams etc. It shows the amount of data passed through, time running, progress bar, percentage and the estimated completion time.

[–] [email protected] 20 points 3 weeks ago* (last edited 3 weeks ago) (2 children)

As primarily a Windows admin (Yes, we exist on Lemmy ;) ) here are few I use often.

  • Enter-PSSesion
  • Get-ADUser (also group and computer)
  • CLS (aka the superior clear)
  • ii . (short for Invoke-Item . which runs the selected object using the default method. For paths (like .) the default is explorer, so ii . opens the current directory using explorer.)
  • ft (short for Format-Table formats piped input as a table.)
  • fl (short for format-like. Used like ft but for lists.)
  • Where-Object
  • Select-Object
[–] [email protected] 20 points 3 weeks ago (1 children)

Uhhh...sudo su

Don't be like me

load more comments (1 replies)
[–] [email protected] 17 points 3 weeks ago (1 children)
load more comments (1 replies)
[–] [email protected] 16 points 3 weeks ago (2 children)
load more comments (2 replies)
[–] [email protected] 16 points 3 weeks ago (5 children)

CTR + u will delete the whole command. I use that a lot so I don't have to backspace. It's saved me a ton of time

[–] [email protected] 17 points 3 weeks ago

Related: Alt + ., to cycle through arguments used in previous commands

load more comments (4 replies)
[–] [email protected] 14 points 3 weeks ago

xdg-open FILE - opens a file with the default GUI app. I use it for example to open PDFs and PNG. I have a one letter alias for that. It can also open a file explorer in the current directory xdg-open . . Should work on any compliant desktop environment (gnome/kde).

[–] [email protected] 13 points 3 weeks ago (2 children)
load more comments (2 replies)
[–] [email protected] 12 points 3 weeks ago (1 children)
load more comments (1 replies)
[–] [email protected] 12 points 3 weeks ago (1 children)
[–] [email protected] 12 points 3 weeks ago (1 children)
[–] [email protected] 15 points 3 weeks ago (1 children)

LambdaRX is not in the sudoers file. This incident will be reported

load more comments (1 replies)
[–] [email protected] 11 points 3 weeks ago* (last edited 3 weeks ago)
  • man
  • fd
  • entr
  • rg
  • gitui
  • nvim
  • tee
  • cd
  • mv
  • rm
  • ls
  • tmux
  • btop
  • yazi
  • du
  • xargs
  • cat
  • less
[–] [email protected] 11 points 3 weeks ago (3 children)

sudo rm -rf /

Very powerful yet helpful command :-)

[–] [email protected] 18 points 3 weeks ago (5 children)

Someone has to say this. Don't do it anyone

[–] [email protected] 15 points 3 weeks ago

Agree. Don’t just copy and paste CLI commands you find on the internet, suggested by a stranger

load more comments (4 replies)
[–] [email protected] 12 points 3 weeks ago

The most deceptive joke I've seen on this is sudo rm -fr / to remove the French language pack

load more comments (1 replies)
[–] [email protected] 11 points 3 weeks ago (6 children)
load more comments (6 replies)
[–] [email protected] 10 points 3 weeks ago (1 children)

On my desktop: df -h to check disk usage htop to see resource usage ll list directory contents

[–] [email protected] 11 points 3 weeks ago (1 children)

I recently found btop and am trying to use that instead of htop.

load more comments (1 replies)
[–] [email protected] 9 points 3 weeks ago

nmtui. But that's because my router is trash.

load more comments
view more: next β€Ί