this post was submitted on 25 Aug 2025
1537 points (98.9% liked)

linuxmemes

26992 readers
1404 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
  • Don't get baited into back-and-forth insults. We are not animals.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn, no politics, no trolling or ragebaiting.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
  • 5. πŸ‡¬πŸ‡§ Language/язык/Sprache
  • This is primarily an English-speaking community. πŸ‡¬πŸ‡§πŸ‡¦πŸ‡ΊπŸ‡ΊπŸ‡Έ
  • Comments written in other languages are allowed.
  • The substance of a post should be comprehensible for people who only speak English.
  • Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
  • 6. (NEW!) Regarding public figuresWe all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations.
  • Keep discussions polite and free of disparagement.
  • We are never in possession of all of the facts. Defamatory comments will not be tolerated.
  • Discussions that get too heated will be locked and offending comments removed.
  • Β 

    Please report posts and comments that break these rules!


    Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.

    founded 2 years ago
    MODERATORS
     
    top 50 comments
    sorted by: hot top controversial new old
    [–] ozymandias@lemmy.dbzer0.com 1 points 32 minutes ago

    bash users… zsh is much better

    [–] Reygle@lemmy.world 4 points 1 day ago

    .. And waste an opportunity to type on my ludicrously expensive mechanical keyboard?

    FRIG no

    [–] PhAzE@lemmy.ca 26 points 2 days ago* (last edited 2 days ago) (2 children)

    Ctrl + R and start typing the command, it'll come up, press enter. Im just more lazy because I know there are still faster ways.

    Edit: instead of hitting enter, keep pressing ctrl + R to cycle through history commands that contain what you typed in

    [–] ChogChog@lemmy.world 4 points 2 days ago

    Note: if the above isn’t working, you may need to first set your shell to accept emacs commands:

    set -o emacs
    
    [–] Inkstainthebat@pawb.social 4 points 2 days ago

    Oh my freaking god thank you

    [–] beerclue@lemmy.world 186 points 3 days ago (18 children)
    [–] serpineslair@lemmy.world 52 points 3 days ago (9 children)

    What the fuck!? How am I only learning this now, after years of linux as daily driver?!

    [–] ch00f@lemmy.world 39 points 3 days ago (10 children)

    Shit is usually a pain in the ass. The challenge is divining how much of a pain in the ass something has to be that someone else might have made a solution for it.

    I didn't know you could ctrl+shift+c to copy in the terminal until a month ago when my linux n00b wife said "there has to be a better way to do this. I've been right clicking to copy for 10 years.

    [–] Neverclear@lemmy.dbzer0.com 23 points 3 days ago (6 children)

    most DE's have a thing where you can paste highlighted text using the middle mouse button

    load more comments (6 replies)
    [–] Atherel@lemmy.dbzer0.com 19 points 3 days ago (1 children)

    And ctrl + shift + v to paste, just in case

    load more comments (1 replies)
    load more comments (8 replies)
    load more comments (7 replies)
    load more comments (17 replies)
    [–] Evotech@lemmy.world 66 points 3 days ago (4 children)
    load more comments (4 replies)

    Ctrl + p is the way.

    [–] djvinniev77@lemmy.ca 13 points 2 days ago (6 children)
    load more comments (6 replies)
    [–] bdonvr@thelemmy.club 71 points 3 days ago* (last edited 3 days ago) (7 children)

    I used to be like this but people seriously. CTRL+R

    Do it. Don't make this one of those things you've heard about and just never got around to trying. Open your terminal right now and CTRL+R and type any part of the command you did before. If the command you want is not showing first just hit CTRL+R again to go to the next one back.

    DO IT.

    Edit: I did learn from this thread today though that ZSH has it set to where you can just type part of what you're looking for then hit up to do the same thing. Neat!

    [–] harsh3466@lemmy.ml 19 points 3 days ago* (last edited 3 days ago)

    Holy shit. I just tried it. ctrl+r is a revelation! How the fuck did I not know about this?

    [–] Danitos@reddthat.com 19 points 3 days ago* (last edited 3 days ago)

    You can empower Ctrl+r event more by using fzf. After I started using it, I can't imagine going back to without it.

    [–] AkatsukiLevi@lemmy.world 19 points 3 days ago

    WHAT THE FUCJ IS THIS SORCERY BRO I'VE BEEN USING LINUX FOR AGES AND NEVER KNEW THIS BROOOOOOOOOO

    [–] lepinkainen@lemmy.world 13 points 3 days ago

    If you want to level up ctrl-r, upgrade to Atuin: https://atuin.sh/

    load more comments (3 replies)
    [–] bisby@lemmy.world 94 points 3 days ago (5 children)
    load more comments (5 replies)
    [–] rumba@lemmy.zip 11 points 2 days ago (1 children)

    You're in vim, you forgot to sudo, the file is read only and you have loads of changed you don't feel like saving off to /tmp and playing the copy file shell game.

    [esc]:w !sudo tee %

    it shoves the current buffer through tee (termina adapter) with sudo privs vim will warn you that the file changed, just [esc]:q! and don't let it save, you already saved it.

    [–] NeatNit@discuss.tchncs.de 2 points 2 days ago (1 children)

    I don't see how this is relevant but thanks for the tip.

    [–] rumba@lemmy.zip 1 points 1 day ago

    I offered one for !ssh, then noticed people were giving other obscure tips so i offered this one.

    [–] rumba@lemmy.zip 11 points 2 days ago (1 children)

    !ssh

    run the last command that started with ssh

    [–] Ashiette@lemmy.world 7 points 2 days ago (1 children)
    [–] rumba@lemmy.zip 6 points 2 days ago

    It's as amazing as it is dangerous :) use with care!

    [–] BigDanishGuy@sh.itjust.works 21 points 3 days ago (1 children)

    More like ⬆️⬆️⬆️⬆️⬆️⬆️ mother fucker ⬇️

    load more comments (1 replies)
    [–] interdimensionalmeme@lemmy.ml 13 points 3 days ago (2 children)

    history | grep thethingyou'relookingfor

    load more comments (2 replies)
    [–] Zink@programming.dev 8 points 2 days ago* (last edited 2 days ago) (2 children)

    Ah crap how did I set my battery charge interval again?

    history | grep battery

    history | grep bios

    history | grep sudo smbios

    Ah! There you are you little shit!

    edit to add: Actually, I think the last time I did this I remembered some numbers I set it to before. So it worked well with something like "history | grep 75" even though there were a bunch of results.

    load more comments (2 replies)
    [–] A_Random_Idiot@lemmy.world 6 points 2 days ago

    Why are you making personal attacks against me.

    [–] KiwiTB@lemmy.world 42 points 3 days ago

    What, and type 'ls' again?

    [–] MehBlah@lemmy.world 1 points 1 day ago (1 children)

    If I haven't ran it in a while or I don't know it by heart then I 'nano /home/mehblah/.bash_history'

    [–] int32@lemmy.dbzer0.com 1 points 1 day ago (1 children)

    I do history | grep keyword.

    [–] MehBlah@lemmy.world 2 points 1 day ago

    I forget that exist. One problem with being really old school on linux is you don't adopt new ways unless there is a reason to do so.

    [–] JATtho@lemmy.world 12 points 3 days ago

    zsh-history-substring-search

    I lazily type part of the thing I want like "sys" and then ctrl+⬆️/⬇️ and sudo systemctl start libvirtd etc. appear like magic.

    [–] ___f____g___@lemmy.ca 9 points 3 days ago* (last edited 3 days ago) (4 children)

    I see everyone posting about Ctrl+R, here's a couple more useful CLI shortcuts you might enjoy:

    cd - (change directory to $OLDPWD usually the previous directory)

    git checkout - (similarly checkout the previous branch)

    Ctrl+A (return caret to beginning of command, great when you forgot a positional argument and you were almost done typing the command)

    Ctrl+E (similar to Ctrl+A but move to the end of the command)

    [–] ytg@sopuli.xyz 5 points 2 days ago

    Ctrl+A, Ctrl+E

    Many more basic Emacs keybindings work, actually! Including C-f, C-b, C-p and C-n (if you prefer them over arrow keys) as well as M-f and M-b to move by words, C-k, M-d and C-y for killing/yanking (but not M-w) and C-SPC, C-w, C-x C-x for region manipulation (tested in Bash and ZSH)

    load more comments (3 replies)
    [–] onebonestone@lemmy.world 7 points 3 days ago (3 children)

    Or just use fish shell. Rarely need ctrl+r anymore.

    load more comments (3 replies)
    [–] DJKJuicy@sh.itjust.works 7 points 3 days ago* (last edited 3 days ago)

    history 500 | grep *snippet of command*

    [–] IcedRaktajino@startrek.website 23 points 3 days ago* (last edited 3 days ago) (10 children)

    Pretty much, yeah.

    Rather than jot down in a text file the various ffmpeg commands I use frequently...

    Raktajino@laptop:~/Downloads$ history | grep ffmpeg
       12  sudo apt install audacity gimp ffmpeg mplayer
      184  history | grep ffmpeg
      215  ffmpeg -i source.mkv -ss 629 -t 7 out.mkv
      217  ffmpeg -i out.mkv -s 0.5 -vf scale=1280:720 out.mp4
      218  ffmpeg -i out.mkv -ss 0.5 -vf scale=1280:720 out.mp4
      231  ffmpeg -i out.mp4 -vf "subtitles=out.srt" final.mp4
      503  ffmpeg -i toofat.wav toofat.mp3
      ...
      682  history | grep ffmpeg
      684  ffmpeg -i 1.gif -i 2.gif -filter_complex "[1:0] [2:0] concat=n=2" out.gif
      685  ffmpeg -i 1.gif -i 2.gif -filter_complex "[1:0] [2:0] concat=n=2:v=1" out.gif
      686  ffmpeg -i 1.gif -i 2.gif -filter_complex "[1:0] [2:0] concat=n=2:v=1" -map '[v]' out.gif
      687  history | grep ffmpeg
      688  ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] 12:0] concat=n=2:v=1" -map '[v]' out.gif
      689  ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] 1:0] concat=n=2:v=1" -map '[v]' out.gif
      690  ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] [1:0] concat=n=2:v=1" -map '[v]' out.gif
      691  ffmpeg -i 1.gif -i 2.gif -filter_complex "[0:0] [1:0] concat=n=2"  out.gif
      694  history | grep ffmpeg
    
    load more comments (10 replies)
    [–] iAvicenna@lemmy.world 13 points 3 days ago

    history | grep then !cmd_number

    load more comments
    view more: next β€Ί