this post was submitted on 21 Sep 2024
221 points (97.4% liked)

Asklemmy

44145 readers
1322 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_A@discuss.tchncs.de~

founded 5 years ago
MODERATORS
top 50 comments
sorted by: hot top controversial new old
[–] papertowels@lemmy.one 70 points 3 months 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)
[–] LazaroFilm@lemmy.world 56 points 3 months ago* (last edited 3 months ago) (5 children)

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

[–] vrighter@discuss.tchncs.de 13 points 3 months ago

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

load more comments (4 replies)
[–] emb@lemmy.world 44 points 3 months ago (3 children)

I really like that cd command. :P

[–] unknowing8343@discuss.tchncs.de 19 points 3 months ago (8 children)
load more comments (8 replies)
load more comments (2 replies)
[–] LaSirena@lemmy.world 41 points 3 months 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.

[–] pixelscript@lemm.ee 26 points 3 months 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)
[–] pemptago@lemmy.ml 38 points 3 months 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.

[–] renzev@lemmy.world 38 points 3 months 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)
[–] SinkingLotus@lemmy.world 36 points 3 months ago (1 children)

Sudo !!

It reruns the last command as sudo.

Pretty useful since I'm always forgetting.

load more comments (1 replies)
[–] umbrella@lemmy.ml 36 points 3 months 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)
[–] I_Miss_Daniel@lemmy.world 36 points 3 months ago (1 children)

sudo udevadm monitor

Figuring out which usb device went on holiday.

load more comments (1 replies)
[–] zlatiah@lemmy.world 31 points 3 months 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)
[–] notfromhere@lemmy.ml 30 points 3 months ago (17 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.

[–] sgtlion@hexbear.net 9 points 3 months ago (4 children)

I would know this as tmux, is there a difference?

load more comments (4 replies)
load more comments (16 replies)
[–] Bougie_Birdie@lemmy.blahaj.zone 26 points 3 months 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.

[–] friend_of_satan@lemmy.world 23 points 3 months 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.

[–] unknowing8343@discuss.tchncs.de 19 points 3 months ago

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

load more comments (1 replies)
[–] Jozav@lemmy.world 24 points 3 months ago (5 children)

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

load more comments (5 replies)
[–] LambdaRX@sh.itjust.works 23 points 3 months ago* (last edited 3 months ago)

After using too much WINE, I type pwd, whoami

[–] HeartyOfGlass@lemm.ee 22 points 3 months ago (4 children)

clear. Constantly, and for no reason.

[–] igorette@lemmy.ml 31 points 3 months ago (4 children)
[–] HeartyOfGlass@lemm.ee 25 points 3 months 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)
[–] sgtnasty@lemmy.ml 21 points 3 months 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.

[–] Revan343@lemmy.ca 20 points 3 months ago (1 children)

Uhhh...sudo su

Don't be like me

load more comments (1 replies)
[–] lud@lemm.ee 20 points 3 months ago* (last edited 3 months 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
[–] some_guy@lemmy.sdf.org 17 points 3 months ago (1 children)
load more comments (1 replies)
[–] Appoxo@lemmy.dbzer0.com 16 points 3 months ago (2 children)
load more comments (2 replies)
[–] RagingRobot@lemmy.world 15 points 3 months 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

[–] call_me_xale@lemmy.zip 16 points 3 months ago

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

load more comments (4 replies)
[–] lluki@feddit.org 14 points 3 months 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).

[–] Shimon@slrpnk.net 12 points 3 months ago (2 children)
load more comments (2 replies)
[–] ripcord@lemmy.world 12 points 3 months ago (1 children)
load more comments (1 replies)
[–] hit_the_rails@reddthat.com 11 points 3 months ago (6 children)
load more comments (6 replies)
[–] JoMiran@lemmy.ml 11 points 3 months ago (1 children)
[–] LambdaRX@sh.itjust.works 12 points 3 months ago (1 children)
[–] nichtburningturtle@feddit.org 15 points 3 months ago (1 children)

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

load more comments (1 replies)
[–] technocat@lemm.ee 11 points 3 months ago* (last edited 3 months ago)
  • man
  • fd
  • entr
  • rg
  • gitui
  • nvim
  • tee
  • cd
  • mv
  • rm
  • ls
  • tmux
  • btop
  • yazi
  • du
  • xargs
  • cat
  • less
[–] majestictechie@lemmy.fosshost.com 10 points 3 months ago (1 children)

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

[–] Albbi@lemmy.ca 11 points 3 months ago (1 children)

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

load more comments (1 replies)
[–] sp451@lemmy.sdf.org 10 points 3 months ago (3 children)

sudo rm -rf /

Very powerful yet helpful command :-)

[–] makingStuffForFun@lemmy.ml 19 points 3 months ago (5 children)

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

[–] sp451@lemmy.sdf.org 15 points 3 months ago

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

load more comments (4 replies)
[–] papertowels@lemmy.one 12 points 3 months 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)
load more comments
view more: next β€Ί