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

Asklemmy

43940 readers
388 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 68 points 2 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 2 months ago* (last edited 2 months ago) (5 children)

cd then ls then cd then ls maybe Iโ€™ll throw a ls -a

[โ€“] vrighter@discuss.tchncs.de 13 points 2 months ago

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

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

I really like that cd command. :P

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

sudo udevadm monitor

Figuring out which usb device went on holiday.

load more comments (1 replies)
[โ€“] umbrella@lemmy.ml 36 points 2 months ago (1 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 (1 replies)
[โ€“] SinkingLotus@lemmy.world 36 points 2 months ago (1 children)

Sudo !!

It reruns the last command as sudo.

Pretty useful since I'm always forgetting.

load more comments (1 replies)
[โ€“] zlatiah@lemmy.world 31 points 2 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 29 points 2 months ago (16 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 (16 replies)
[โ€“] Bougie_Birdie@lemmy.blahaj.zone 26 points 2 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 2 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.

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

load more comments (1 replies)
[โ€“] Jozav@lemmy.world 24 points 2 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 2 months ago* (last edited 2 months ago)

After using too much WINE, I type pwd, whoami

[โ€“] sgtnasty@lemmy.ml 20 points 2 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 2 months ago (1 children)

Uhhh...sudo su

Don't be like me

load more comments (1 replies)
[โ€“] lud@lemm.ee 20 points 2 months ago* (last edited 2 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
[โ€“] HeartyOfGlass@lemm.ee 19 points 2 months ago (3 children)

clear. Constantly, and for no reason.

[โ€“] igorette@lemmy.ml 30 points 2 months ago (4 children)
[โ€“] HeartyOfGlass@lemm.ee 25 points 2 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 (2 replies)
[โ€“] some_guy@lemmy.sdf.org 17 points 2 months ago (1 children)
load more comments (1 replies)
[โ€“] Appoxo@lemmy.dbzer0.com 16 points 2 months ago (2 children)
load more comments (2 replies)
[โ€“] RagingRobot@lemmy.world 15 points 2 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 2 months ago

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

load more comments (4 replies)
[โ€“] lluki 14 points 2 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).

[โ€“] ripcord@lemmy.world 12 points 2 months ago (1 children)
load more comments (1 replies)
[โ€“] Shimon@slrpnk.net 11 points 2 months ago (2 children)
load more comments (2 replies)
[โ€“] majestictechie@lemmy.fosshost.com 10 points 2 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 2 months ago (1 children)

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

looks up btop ooooo

[โ€“] technocat@lemm.ee 9 points 2 months ago* (last edited 2 months ago)
  • man
  • fd
  • entr
  • rg
  • gitui
  • nvim
  • tee
  • cd
  • mv
  • rm
  • ls
  • tmux
  • btop
  • yazi
  • du
  • xargs
  • cat
  • less
[โ€“] hit_the_rails@reddthat.com 9 points 2 months ago (6 children)
load more comments (6 replies)
[โ€“] blackstrat@lemmy.fwgx.uk 9 points 2 months ago (3 children)
load more comments (3 replies)
load more comments
view more: next โ€บ