My 5 Favorite Linux Shell Tricks for SPEEEEEED (and efficiency)

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ธ.ค. 2024

ความคิดเห็น • 732

  • @tutoriaLinux
    @tutoriaLinux  6 ปีที่แล้ว +216

    ~~~ Timestamps to specific sections are in the description! ~~~

    • @planktonfun1
      @planktonfun1 6 ปีที่แล้ว +9

      ctrl+a and ctrl +e goes to the start and last, I find myself using this most

    • @chaoswires2734
      @chaoswires2734 6 ปีที่แล้ว +1

      Thanks for tips! Few more useful commands. The easiest way to create empty file is typing >filename
      I also often need to convert unix timestamp to hooman readable form, "date --date=@your_date_in_unix_format" does the job.

    • @noele2980
      @noele2980 6 ปีที่แล้ว +2

      i literally screamed when i learned the kill / yank

    • @DaleHawkins
      @DaleHawkins 6 ปีที่แล้ว

      Becoming proficient in emacs makes the editing commands second nature. 🙂

    • @priit7777
      @priit7777 3 ปีที่แล้ว

      @@planktonfun1 but why? your keyboard also doesn't have home and end keys? much easier than some ctrl combinations.

  • @hellangel28
    @hellangel28 6 ปีที่แล้ว +201

    i really love the fact that you wrote exactly what you are going to explain in the description with timestamps!

    • @weasel6205
      @weasel6205 3 ปีที่แล้ว +1

      Yeh, same, I was prompted to subscribe as my patience run out not because I should definitely learn the rest of the content but because,"ADHD," 🤣, prompted straight to subbing and turning notification on, lamo.

  • @ernestogutierrez7877
    @ernestogutierrez7877 3 ปีที่แล้ว +6

    you had me at `sudo !! `
    shaking my head at the amount of time i've wasted not knowing about this...

  • @whiskeytuesday
    @whiskeytuesday 6 ปีที่แล้ว +8

    Instead of you can also just use !$ the same way you used !! in the first tip. There's actually a lot of notation for this which is terminal agnostic and supported in zsh as well as bash and probably others. For instance !-2 gives you the command before last, !-3 the one before that etc. $ on the end gives you the last argument of that command. !^ gives you the first argument, !:2 or !* gives the second argument. All of these things can be combined too, for instance !-3:2-$, which gives the second to last argument of the third-last command or !-3:2-3 which gives the second and third arguments to the third last command. Hard to keep straight at first but a very powerful way of getting around once you jam it into your head.

  • @jony7779
    @jony7779 6 ปีที่แล้ว +97

    If you ever need to purposefully mess up a terminal like for 9:47, I've found the command "sleep 1 | vim" will do that consistently on any terminal.

    • @SeanNicholsEh
      @SeanNicholsEh 6 ปีที่แล้ว +34

      Can't believe I just upvoted a guy for messing up my terminal... XD

    • @tobiaskrischer9950
      @tobiaskrischer9950 6 ปีที่แล้ว +20

      could not confirm:
      root@debootstrap:~# sleep 1 | vim
      -bash: vim: command not found
      root@debootstrap:~#
      /s

    • @iam3377
      @iam3377 4 ปีที่แล้ว +8

      Vim is seriously the best text editor

    • @aeelinnannelie5651
      @aeelinnannelie5651 4 ปีที่แล้ว +4

      It does not happened to me. Maybe because I have Neovim installed

    • @twb0109
      @twb0109 3 ปีที่แล้ว +3

      @@iam3377 laughs in nvim

  • @AndrewDeFaria
    @AndrewDeFaria 3 ปีที่แล้ว

    Good video. I learned a couple of new tricks!
    One trick I knew already and always use is the Alt- thing. I describe it to others this way - Alt- brings up the last "word" of the previous command. Think of it as an object. So you do ls /tmp/file. Now /tmp/file is the object. Want to know more about the object? Type ls -l Alt-. Contents? - more (or less) Alt-. File's junk - rm Alt-.
    But what's more is say you have this in your history:
    501 touch /tmp/file
    502 ls /tmp/file
    503 echo file?
    504 uname -a
    505 history
    Typing Alt- at the command prompt will bring forth "history". But typing another Alt- will bring up "-a". Another one and you get "file?". One more and you get "/tmp/file". So if you want that Alt- object because it was say a filename object but it was not the last word of the immediately preceding command then keep hitting Alt- until you get back that file object.

  • @jplflyer
    @jplflyer 3 ปีที่แล้ว +12

    I've been programming professionally for 40 years, most of that in the Linux world, and it's amazing the learning process never ends.

    • @JerryPenna
      @JerryPenna 3 ปีที่แล้ว +1

      Yeah, I’ve used less a ton but not with other flags. I tried less +F but didn’t work.

    • @allen_joji
      @allen_joji 2 ปีที่แล้ว

      Do you still love programming ?

    • @jplflyer
      @jplflyer 2 ปีที่แล้ว +2

      @@allen_joji Yeah, I do. I'll eventually retire, but it's unlikely I'll ever stop programming. I'll do my own projects is all.
      My opinion about careers: you should find something you can be passionate about, that you want to do even if you weren't being paid. We spent far too much of our lives at our jobs, and do you want it to be soul-sucking?
      The last people I want to work with: the ones who see it as a job. They're only there for the paycheck. Yeah, if I won the lottery, I'd quit the day job. But I'd still program. I'd just get to pick what I work on.

  • @mostafafarzan5363
    @mostafafarzan5363 3 ปีที่แล้ว +5

    Another nice trick worth mentioning is reverse search (Ctrl + r), where you can type a part of your command and it'll bring on the last command entered with the expression in it. You can see older/newer commands by pressing Ctrl+r and Ctrl+R respectively.
    It's a bit more common so maybe not really a trick, but still some people might not know about it.

  • @GBGSK
    @GBGSK 6 ปีที่แล้ว +155

    > Bang bang
    > password shot me down
    > Sudo .. BANG BANG
    "Torvald Sinatra"

    • @karlheinzneugebauer
      @karlheinzneugebauer 3 ปีที่แล้ว +4

      BANG BANG rather reminds me of "Rammstein - Feuer Frei"

    • @vass0922
      @vass0922 3 ปีที่แล้ว

      @@karlheinzneugebauer hey thanks thats a great way to remember that!

    • @hayksk
      @hayksk 3 ปีที่แล้ว +2

      Nancy Sinatra :) ?

    • @karlheinzneugebauer
      @karlheinzneugebauer 3 ปีที่แล้ว +1

      @@hayksk Had to google who that is. Appears to be the daughter of Frank. Interesting.

    • @hayksk
      @hayksk 3 ปีที่แล้ว

      @@karlheinzneugebauer Yes, she is.

  • @HenrikAlsingFriberg
    @HenrikAlsingFriberg 6 ปีที่แล้ว +196

    "Alt + backspace" is more useful than "ctrl + w" in my oppinion. While the latter only stops at whitespaces, the former also stops at special characters, e.g. slashes, so you can edit your way to parent directories much faster.

    • @tutoriaLinux
      @tutoriaLinux  3 ปีที่แล้ว +18

      Solid advice! Will try to re-wire my brain to try it out.

    • @sarthaks95
      @sarthaks95 3 ปีที่แล้ว +1

      Both are useful but for different cases. Clear entire arg or go word by word. Personally I use both depending on the case.

    • @rcatyvr
      @rcatyvr 3 ปีที่แล้ว +3

      I use a Mac terminal and there is no Alt key, but ^w works just fine enough for me

    • @novimartyn
      @novimartyn 3 ปีที่แล้ว +1

      @@rcatyvr On the Mac I think you need to use Escape instead of Alt

    • @ernestdesouza8888
      @ernestdesouza8888 3 ปีที่แล้ว

      @@rcatyvr dump Ur mac if ur using Linux !
      Actually anything is fine ...depends on the person !!!

  • @elijah11162
    @elijah11162 3 ปีที่แล้ว +3

    11 minutes later and I don't know how I survived without these tricks for so long. Great stuff man

  • @DDBAA24
    @DDBAA24 5 ปีที่แล้ว

    I remember a while back you saying your co workers would give you a hard time about using advanced commands... I can see why , I have watched a lot of tutorials , some of the things you do I haven't seen ANYWHERE else. I like this channel because even if I go way back in your history everything is still relevant and useful. I've been subscribed but I forgot to hit the bell icon , so I didn't even know you were back. Glad to hear it though.

  • @Barbarian.Streisand
    @Barbarian.Streisand 4 ปีที่แล้ว +47

    i could definitely have a beer with this guy.

    • @cgme7076
      @cgme7076 3 ปีที่แล้ว +2

      Yeah, he seems like a cool guy

  • @joachimjohansen5796
    @joachimjohansen5796 6 ปีที่แล้ว +1

    Great idea with the less +F , I prefer using regular old less then pressing shift+G, it takes you to the bottom of the file and you can scroll up without gluing.

  • @ChunkyDrew33136
    @ChunkyDrew33136 5 ปีที่แล้ว +12

    VERY useful tips here, I plan to start using them regularly. You’re proving to be my most useful resource on YT in my Linux journey. Also enjoying your sysadmin series.

  • @tobiassinghania3698
    @tobiassinghania3698 6 ปีที่แล้ว +12

    Great video! What I use probably the most is Ctrl+r to quickly search the command history. By using Ctrl+r you can go to the next hit and with Ctrl+R to the previous.

    • @josephknightcom
      @josephknightcom 6 ปีที่แล้ว +1

      thanks

    • @frydac
      @frydac 3 ปีที่แล้ว +1

      try fzf, it makes ctrl-r a dropdown list (i think it opens a tmux pane on the fly iirc) and lets you search in a fuzzy manner. And also search for files like that, I can't live without it anymore..

    • @tobiassinghania3698
      @tobiassinghania3698 3 ปีที่แล้ว

      @@frydac yes, fzf is really awesome in various regards :)

  • @TheDave000
    @TheDave000 6 ปีที่แล้ว +14

    How did I not know about less +F? This literally changes everything in my job!

    • @nonconsensualopinion
      @nonconsensualopinion 3 ปีที่แล้ว +4

      Maybe it's overkill, but I always just use vim. It loads very quickly and gives me the ability to search all around any log, jump to the bottom, etc. vim logfile, shift-g to get to bottom, :q to exit. Done.

    • @SJmurov
      @SJmurov 3 ปีที่แล้ว

      @@nonconsensualopinion But does it follow?

    • @edgarbonet1
      @edgarbonet1 5 หลายเดือนก่อน

      I learned about `less +F` by reading `man less`. I may be a weirdo, I read man pages. ;-)

  • @locusinbloom
    @locusinbloom 6 ปีที่แล้ว

    I was expecting to be disappointed (didn't notice who published it before I clicked watch, lol) but I didn't know a single one of these, thank you! All of your videos are great.

  • @momashi69
    @momashi69 6 ปีที่แล้ว +1

    Huge Thanks for the 2 shell videos you've made. Been using CLI over a decade but did not know any of these tricks and have always found it slow and clunky when compared to the gui. Well no more, not after these massive quality of life improvements... Been 6 months since I watched these videos but I still think of you and smile the endless times a day I use these tricks!

  • @IRgEEK
    @IRgEEK 6 ปีที่แล้ว

    Fantastic post Man! Wanted some Ninja tricks to share with my Students tomorrow and these are perfect! Thanks so much!

  • @AleksandarBosakov
    @AleksandarBosakov 6 ปีที่แล้ว +25

    Holy cow, it's been 12 years since the last time I used Windows on my home PC, and I do use the CLI a lot, yet I didn't know some of those tricks. Great work!

  • @vrvrvr81
    @vrvrvr81 6 ปีที่แล้ว +2

    first useful shell video tutorial I ever ran into

  • @EdselAdap
    @EdselAdap 3 ปีที่แล้ว

    Great video! I consider myself a seasoned shell user since I've been doing this stuff for 30+ years but you've taught me some new stuff. Two things to add though to fix a borked terminal is "stty sane" and "echo ctrl-v ctrl-o". Excellent tutorial!

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 3 ปีที่แล้ว

    4:51 A few further tips with less:
    * I like to add the -i and -X options. -X stops it clearing the screen when it exits, and -i means searches are case-insensitive. In fact, I like to have the alias “more='less -iX'” defined, since I don’t see the point in the standard “more” command.
    * The +F option corresponds to pressing F while already in less. This is true of all the options beginning “+”: they correspond to keystrokes you type within a less display. Another useful one is +G, to start viewing the file from its current end.

  • @felaflame
    @felaflame 6 ปีที่แล้ว +4

    Thanks for the video. Although I am using GNU/Linux for more than 15 years, I forgot about !! and I didn't know about C-x-e.
    Thanks.

  • @KirtFitzpatrick
    @KirtFitzpatrick 3 ปีที่แล้ว +1

    Great tips, thanks for sharing! I'm proud that I knew a couple already but most are new to me. I'm going to incorporate these into my day to day for sure. The comment section is gold too.

  • @AjitV
    @AjitV 3 ปีที่แล้ว

    BONUS tip was the best.
    I have the issue all the time especially after using gdb ...
    Thank you sir, U've earned a Subscriber

  • @kleetus88
    @kleetus88 6 ปีที่แล้ว +13

    as an adjunct to !!, I find I use !$ A LOT. This handy thing refers to the last argument on the last command. e.g. mkdir -p /home, then cd !$. This will be equiv to cd /home.

  • @Colony28
    @Colony28 5 ปีที่แล้ว

    Thanks for the tips! When I saw the alt+f/b, I realized how annoying it is without it.
    About less +F, it's great for one logfile, but I can do tail multiple logs with tail, which is sometimes useful: tail -f /var/log/something/*.log

  • @sarundayo
    @sarundayo 6 ปีที่แล้ว +4

    Just came across this channel and I love it!
    Thanks for showing us how wonderful Linux can be and how to use it.

  • @ryanbard3560
    @ryanbard3560 6 ปีที่แล้ว +57

    Fyi, another nice thing about using less over tail is that you can put in some search terms before kicking on the live tail mode and they'll be highlighted.
    Ex.
    put in a /error|warning|critical
    then hit shift+F and as things scroll by, error, warning, and critical will be highlighted.

    • @beeeeep
      @beeeeep 6 ปีที่แล้ว +3

      You can even use & interested of / to filter what you like to see.

    • @ALTracer
      @ALTracer 5 ปีที่แล้ว +1

      | ccze --mode ansi
      also does that

    • @KirtFitzpatrick
      @KirtFitzpatrick 3 ปีที่แล้ว

      I wonder if there is a way to get automatic highlighting like with bat.

  • @codenamelambda
    @codenamelambda 6 ปีที่แล้ว +2

    My recommendation for vim users: add ```set -o vi``` (or something like that, too lazy to look it up) to your bashrc, and use your favorite vi-keybindings in your shell (press esc to get into normal mode)

  • @Breemskin
    @Breemskin 2 ปีที่แล้ว

    Less +F is brilliant! That will be quite useful for me, thanks.

  • @CoreDump07
    @CoreDump07 6 ปีที่แล้ว

    very informative, i often use for example "ssh " to repeat the last ssh ... command

  • @htl2001
    @htl2001 6 ปีที่แล้ว +17

    less -n helps a TON on large files (doesn't count line numbers). -S can be useful in logs as well (no wrap)

    • @codeman99-dev
      @codeman99-dev 3 ปีที่แล้ว +3

      I almost always use `less -FRS`
      -F will "quit if one screen" or "there is no need for scrolling"
      -R will allow correct width calculation of control characters. Especially useful if you are piping a command and still want the color output.

    • @JerryPenna
      @JerryPenna 3 ปีที่แล้ว

      Ok I’ve been using less longer than I want to admit. Will try “less -FRS”. 😂

  • @Albertux
    @Albertux 6 ปีที่แล้ว +27

    One thing to mention, keyboard shortcuts are using emacs key bindings bash, you can run "set -o vi" to have vi key bindings

    • @tutoriaLinux
      @tutoriaLinux  6 ปีที่แล้ว +1

      Yep, I mention that in the basics tutorial linked at the beginning of the video -- but it's useful to have here as well. Thanks!

    • @davidmaxwaterman
      @davidmaxwaterman 6 ปีที่แล้ว +2

      Yeah, it seems really odd to see him use Emacs on the command line but then use vi for editing. Better to be consistent one way or the other, imo.

    • @bloodgain
      @bloodgain 6 ปีที่แล้ว +8

      Well, it's not technically emacs bindings, but readline bindings, which were based on emacs since it was written first. Since it's so ubiquitous in GNU shell apps, it's a good idea to be relatively familiar with it, no matter what your favorite editor is. Using it every day in your shell is a good way to remain familiar. It also means you can walk up to an unconfigured shell (e.g. someone else's) and function normally.
      Plus, modal editing makes a lot of sense for a file, but less so for your command line, until you need to edit a complicated multi-line command. So I leave my bash settings at the readline default, and just fire up Vim with Ctrl-x,e when I need it -- best of both worlds.

    • @thomasmarshall4472
      @thomasmarshall4472 6 ปีที่แล้ว

      bloodgain , I just love that people seem to be re-"discovering" vi{m} again for text editing. Keeping your hands on the primary keys is SUCH a win over getting emacs-pinky and/or lifting your hand up to jump to the arrow keys. Been using it since the 80's, and if only the "vi-like" plugins for IntelliJ and Netbeans worked as well.

    • @bloodgain
      @bloodgain 6 ปีที่แล้ว

      Thomas Marshall The Vim plugin for IDEA-based editors like IntelliJ is pretty decent, but I agree that in general they leave a lot to be desired over native Vim. I'd much rather see Vim integrated as an editor. That's not too difficult with emacs, but it's much harder with Vim. I think Neovim is trying to address that; let's hope they succeed!
      Anecdotally, I find that the kind of people who are lifelong learners tend to take quickly to Vim once they get a taste of modal editing. I'm helping a PhD engineer learn it at work now, and he mostly writes Matlab for us (though he's falling in love with Python, as you might expect).

  • @uniquechannelnames
    @uniquechannelnames 3 ปีที่แล้ว

    Thank you for all the work putting this together, and for teaching all us terminal plebs how to kick ass at terminal lol.
    Again, thank you!

  • @RedStefan
    @RedStefan 5 ปีที่แล้ว +55

    Sudo!!
    I hit the ground
    Sudo!!
    That awful sound
    Sudo!!
    My baby shot me down

  • @imansh6995
    @imansh6995 3 ปีที่แล้ว

    bro at first i thought you are gonna say some interesting but not useful stuff, but it was great. Thanks for Sharing , Keep up

  • @aronhegedus
    @aronhegedus 4 ปีที่แล้ว +1

    I already know I'm going to use that command line yanking so much, thank you!

  • @tildessmoo
    @tildessmoo 6 ปีที่แล้ว +11

    Quick note on the keyboard shortcuts: These are default Bash terminal commands, which are based on Emacs commands; however, you can also add "set -o vi" to your .bashrc to set Vi mode, and then you can use Vi shortcuts instead. Since one of the big things that keeps Vi[m] competitive with Emacs is the power of its navigation commands, this can make you even more efficient, though the learning curve is pretty severe if you're not already used to navigating in Vi, so obviously this is only something to do if it's already your preferred editor.

  • @zerbitx
    @zerbitx 3 ปีที่แล้ว +1

    The ctrl-x-e trick is great for small modifications to commands from your history as well. You can up arrow, or bang or history | grep or whatever to a previous long gnarly command, then hit ctrl-x-e to make easier surgical modifications to it.

  • @simonleonard4084
    @simonleonard4084 3 ปีที่แล้ว

    I liked the less +F tip, but Ctrl-x-e is what made me follow you

  • @MmmBopsPops
    @MmmBopsPops 6 ปีที่แล้ว

    Another really handy one is "fc -s PAT=REP" ... if you fat-finger and put:
    ls /var/log/syslog
    but you really meant to CAT or LESS it, just type
    fc -s ls=cat
    it'll replace the previous command "ls" with "cat", making it:
    cat /var/log/syslog
    can be a little dangerous, but a big saver for me - even more-so than sudo !!

  • @dukercs
    @dukercs 3 ปีที่แล้ว +1

    Thank you!!! This video should never die!

  • @toncho1986
    @toncho1986 6 ปีที่แล้ว +21

    Nice work, dude!
    I love your videos, keep it up :D

  • @jefferytownsend7787
    @jefferytownsend7787 3 ปีที่แล้ว

    That Ctrl + K and Ctrl + Y is legit. Thanks.

  • @stephanerolland9800
    @stephanerolland9800 3 ปีที่แล้ว

    instead of your suggestion Ctrl + U type sudo Ctrl Ctrl + Y, I would prefer Ctrl + A type sudo then Ctrl + E if I ever have to continue to add stuffs.
    thanks fro your tip. !! definitely is super useful.

  • @firexfly
    @firexfly 6 ปีที่แล้ว +8

    Thanks for 'less +F'. There's also a program called multitail which I have been installing on servers I manage for quite a while. It lets you follow multiple log files at once, also colors.

    • @shanecole401
      @shanecole401 3 ปีที่แล้ว

      try using tail -qf foo.log bar.log and it will show new lines to both files ordered, and if one rotates and goes away but appears later keep tailing it, all as if it was just one file

  • @LycoLoco
    @LycoLoco 6 ปีที่แล้ว

    Good stuff! Also in addition to alt+. you can also do alt+# (as in 1 or 2, not pound) then alt+. and you'll get the next to last argument for 1, second to last argument with 2...and so on.

  • @leteveryoneknow
    @leteveryoneknow 6 ปีที่แล้ว +1

    Thank you for sharing information which is immediately effective and useful.

  • @dylanwestphal3582
    @dylanwestphal3582 3 ปีที่แล้ว

    Love these hints and tricks, I'm probably pulling at least a few into daily life - Shot dude!

  • @osquigene
    @osquigene 6 ปีที่แล้ว +8

    For tip 5 you can just do "mtr !$" (last argument) or "mtr !*" (all arguments) which both have the advantage of not being terminal dependent (just relies on history). I think even without history "mtr $_" would work.
    Or you can even have a bit of fun "^ping^mtr^"

    • @osquigene
      @osquigene 6 ปีที่แล้ว +3

      Yes, if you want the detail of that you can refer to 9.3.1 and 9.3.3 in bash manual.
      You can do stuff like, creating a file:
      touch A/B/C/d.txt
      then moving to the directory:
      cd !$:h # h: Remove a trailing pathname component, leaving only the head.
      You'll also see:
      ^string1^string2^ Quick Substitution. Repeat the last command, replacing string1 with string2. Equivalent to !!:s/string1/string2/.
      Similar things exists for parameter substitution (which I personally only use for file names/paths manipulation):
      www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion
      www.tldp.org/LDP/abs/html/parameter-substitution.html
      You have an example in the documentation that shows how this can be used:
      www.gnu.org/software/bash/manual/bashref.html#A-Programmable-Completion-Example

  • @TomGrubbe
    @TomGrubbe 3 ปีที่แล้ว

    Thx for the ctrl-k, ctrl-u, ctrl-w, ctrl-y tip. I didn't know that one. Even works in Zsh.

  • @dawidpomioto1595
    @dawidpomioto1595 5 ปีที่แล้ว

    Realy cool shortcuts. It helped me a lot. You are great!

  • @pianochannel100
    @pianochannel100 3 ปีที่แล้ว

    One of the best projects we had in university was building our own copy of bash (stripped down a bit obviously) from scratch in C. Even though I have built my own, I learn new stuff everytime i see videos like these.

  • @donaldwebster2866
    @donaldwebster2866 3 ปีที่แล้ว

    If your terminal is really borked, you may need to use Ctr-J (before and after reset) instead of as in: reset. Also, G and 1G in less are super useful, being go to the end or beginning of a file. I like Alt-. I might start using that instead of !$ The other bang command is ! which is insert the last command that starts with . In you one example, if find wasn't the previous command, you could have run "sudo !find" or what I do many times is "!le" to run my last less command; likewise "!ls"

  • @ManishKumar-uy5io
    @ManishKumar-uy5io 3 ปีที่แล้ว

    Dude I'm watching this in 2021 and this super helpful. Kinda regretting went TH-cam didn't recommend earlier

  • @walkerneo
    @walkerneo หลายเดือนก่อน

    Great video! Clear, concise, and useful. Learned a few things from it

  • @vincentdeo5740
    @vincentdeo5740 6 ปีที่แล้ว

    kudos for sudo !!
    However, I'm reluctant with the ctrl+u, type 'sudo ', ctrl+y. I have the right hand always pretty close to home and end keys. So i'll do home, type in my sudo, then end. Less keypresses !

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 6 ปีที่แล้ว +1

    8:46 That’s actually a readline feature. ALT-. is the default keybinding for “yank-last-arg”. See the bash docs for other useful readline commands you can bind to keys.

  • @asanz1665
    @asanz1665 6 ปีที่แล้ว

    Some of those I didn’t know. You saved me loooots of minutes for sure.
    Thanks!

  • @eduardosanchez9245
    @eduardosanchez9245 6 ปีที่แล้ว +1

    Loved the "BONUS ROUND!" :)

  • @0Hasaname0
    @0Hasaname0 3 ปีที่แล้ว

    Nice examples! Did learn something new! Thank you! I would also mention "Ctrl - r" for searching in .bash_history. Something I use often...
    Good work, guy!

  • @awuma
    @awuma 6 ปีที่แล้ว +9

    Many thanks! On linux since 1995, yet most of this was new to me.

    • @sashamc309
      @sashamc309 6 ปีที่แล้ว +1

      awuma whoah! you really should have known about !! or Ctrl+W. I'm working on the terminal for 3 years and I knew most of this.

    • @stefan_dobre
      @stefan_dobre 6 ปีที่แล้ว

      @@sashamc309 congrats

    • @JerryPenna
      @JerryPenna 3 ปีที่แล้ว

      1999 abs same feeling.

  • @cupajoesir
    @cupajoesir 6 ปีที่แล้ว +3

    I actually found the --curses tangent to be useful. I have cursed ubuntu myself when it popped up in a gui. Great tips keep up the good work.

  • @ShamanRing
    @ShamanRing 4 ปีที่แล้ว +1

    7:30 for those who got confused on how to leave vim, he hit ESC then hit ":" and type wq then enter.

  • @TesserId
    @TesserId 3 ปีที่แล้ว +30

    8:52 LOL "Dammit Ubuntu. Ruin even..." Now I know you're a command-line warrior.

  • @neloangelo__13
    @neloangelo__13 6 ปีที่แล้ว +1

    Thank you so much Dave for sharing your knowledge, looking forward for future videos. Keep it up mate!

  • @nissieln
    @nissieln 3 ปีที่แล้ว

    Alt . is a winner! Thanks for the vid and the timestamps ^^

  • @sampathkumar2506
    @sampathkumar2506 5 หลายเดือนก่อน

    I love the content in bash programming playlist🙂..It was really helpful to know the basics in bash programming..!!!

  • @nnionline
    @nnionline ปีที่แล้ว

    Great video even after 4 years. What I learned couple of days ago which is imho really helpful is ALT+#. This adds # at the beginning of the line. It is helpful if you want to keep this line for later without executing it.

    • @tutoriaLinux
      @tutoriaLinux  ปีที่แล้ว

      Love it, thanks for sharing! I didn't know about that, and manually do this all the time (ctrl-a to go to beginning of line, then #, then enter). I'll start using that right now.

  • @BibleBeltPearlist
    @BibleBeltPearlist 6 ปีที่แล้ว +79

    One that I recently learned that helped a bunch was "~ ." after you lose connection to a remote ssh session. Basically your terminal becomes useless you can't type anything and nothing is happening...press ~ then period and you have your shell back...can't remember if you already mentioned this or not somewhere else.

    • @tutoriaLinux
      @tutoriaLinux  6 ปีที่แล้ว +27

      I LOVE this one, and manage to forget it every single time I actually need it. Should get that tattooed on my hand or something...

    • @ionsquare
      @ionsquare 6 ปีที่แล้ว +9

      One note, it needs to be after a newline, if it doesn't work try pressing enter first.
      Also if you're connected to another host over ssh and you're using tmux and connecting to other hosts (like two ssh jumps), you can still use this trick to kill the remote ssh sessions by using tmux send-keys. `ctrl+b :` and then at the tmux prompt type `send-keys "~."`

    • @BantuTu
      @BantuTu 3 ปีที่แล้ว +2

      Enter
      ~
      Ctrl-z
      Suspend an ssh session. Use this alot when doing things on the phone with termux.

    • @raghavrao5221
      @raghavrao5221 3 ปีที่แล้ว +1

      @@BantuTu super useful thanks. I use termux launcher

    • @yonatanbenporat4889
      @yonatanbenporat4889 3 ปีที่แล้ว

      Hey
      It doesnt work for me over putty if I do "~ .", I know that there is a shortcut for that with ~ but I can't find in the internet... Can u say what am I doing wrong?

  • @aemonge88
    @aemonge88 6 ปีที่แล้ว

    This works for a chosen default input method. Bash auto set the option "set -o emacs", so you can move in the line like you would move in emacs. For VIM input method like you can set it to vi "set -o vi", then you can move vi style. Important to remap you esc key to some key which is more near to your fingers ( like blocCaps ), since vi heavelly relays on the esc key to switch from and to visual and insert modes

  • @linuxgeex
    @linuxgeex 6 ปีที่แล้ว

    Nice hints. I have a couple more super useful less features for you:
    less *.log ; then :n or:p to jump between the globbed files
    / to search; -i to switch case sensitivity on/off; g for regex search; g! for negative search
    note that you can / search within a g search!

  • @DarrensTechTutorials
    @DarrensTechTutorials 6 ปีที่แล้ว +18

    sudo !! is the handiest thing ever! Thanks for sharing :)

    • @sakishrist
      @sakishrist 6 ปีที่แล้ว

      Why would that be handy? It's the same as up->home->sudo ...
      I really don't get it

    • @DarrensTechTutorials
      @DarrensTechTutorials 6 ปีที่แล้ว

      Just fine it easier to type that rather than up -> home -> sudo, each to their own though :)

    • @tutoriaLinux
      @tutoriaLinux  6 ปีที่แล้ว +2

      I think the advantage is that your fingers don't need to leave the home row, and you don't have to look away from the screen. It seems minor but makes a noticeable difference at higher typing speeds.

    • @brinckau
      @brinckau 6 ปีที่แล้ว

      It's handy to know !! because it can be used in any bash command. It has nothing to do with sudo, it's interpreted by bash.

  • @8bitRaccoon
    @8bitRaccoon 3 ปีที่แล้ว

    haha! thats you! my favorite devtips blogger! i recognize you after singing))))

  • @rapier992
    @rapier992 3 ปีที่แล้ว

    ctrl Z suspends the execution of a program
    example:
    ./slow_program
    ctrl+Z # program is suspended, you are back into your shell
    Now, you can do either
    fg => brings back the program into the foreground
    bg => let the program run again in the background, as if you ran ./slow_program & initially
    you can suspend multiple processes like this, and list them by using the following command:
    jobs
    and then use fg 1 for example
    (pasta@nanotrasen)[21:47:29] ~
    $> ls -R / >/dev/null 2>&1
    ^Z
    [1]+ Stopped ls -CF --color=auto -R / > /dev/null 2>&1
    (pasta@nanotrasen)[21:47:42] ~
    $> jobs
    [1]+ Stopped ls -CF --color=auto -R / > /dev/null 2>&1
    (pasta@nanotrasen)[21:48:05] ~
    $> emacs file.txt
    ^Z
    [2]+ Stopped emacs file.txt
    (pasta@nanotrasen)[21:48:11] ~
    $> jobs
    [1]- Stopped ls -CF --color=auto -R / > /dev/null 2>&1
    [2]+ Stopped emacs file.txt
    (pasta@nanotrasen)[21:48:19] ~
    $> fg 1
    ls -CF --color=auto -R / > /dev/null 2>&1

  • @KingstonFortune
    @KingstonFortune 2 ปีที่แล้ว

    wow this is just wonderful, especially the reset command for me cos lately I have been using a remote shell and it usually gets weird after a while, but I tend to just manage...so this definitely works and I will be using it from now on, thanks!

  • @ChrisCox-wv7oo
    @ChrisCox-wv7oo 7 หลายเดือนก่อน

    The less instead of tail tip is great.

  • @christiansmyth1466
    @christiansmyth1466 3 ปีที่แล้ว

    some alternatives, if you are old-school (or just old like me) and use "set -o vi"...
    1. kisudo
    2. D or d0, u to undo
    2a.

  • @ojkolsrud1
    @ojkolsrud1 3 ปีที่แล้ว

    ctrl+x+e
    That was a *really* nice trick. I didn't know about that one! I think it would also be very useful when you're testing things. At least that's my workflow - I'll write my program, but need to test a specific command or something. I then go to just a shell and experiment. I could write a temporary script that does this, but to drop into a temporary file like that, directly from the shell, is probably much nicer.

  • @misterikkit
    @misterikkit 6 ปีที่แล้ว +3

    my favorite way to bork a shell is `cat /Dev/urandom`
    Thanks for the tips!

  • @joeleenkado5761
    @joeleenkado5761 5 ปีที่แล้ว

    Thanks for posting the Cheat Sheet; These things are soo handy for me.

  • @tomwimmenhove4652
    @tomwimmenhove4652 3 ปีที่แล้ว

    I did not know less' +F option. Thanks a bunch, I'm sure that'll come in handy.

  • @bassam.2023
    @bassam.2023 3 ปีที่แล้ว

    ctrl-k, ctrl-u, ctrl-w, ctrl-y
    Game changers for me. Thanks!

  • @meltedcheese1908
    @meltedcheese1908 6 ปีที่แล้ว

    That first one is going to be really useful.

  • @cprn.
    @cprn. 6 ปีที่แล้ว

    What you're talking about here are emacs-style GNU `readline` keybindings which are the default. GNU `readline` is used by variety of applications, including shells, `python`, `gdb`, `bc`, `gnuplot`, `smbclient`, many more. If you already know `emacs`, great, you don't have to learn anything, just go be an awesome CLI ninja. If you don't know `emacs` but you know `vi`, you can switch your shell's keybindings to a vim-style scheme by calling `set -o vi` (just add it to your shell's `rc` file). If you know either, well, there's no point learning both, just go through `vim` tutorial and thank me later. You can set input keybindings for most of your CLI applications in `~/.inputrc` file (two lines: `set edit-mode vi` and `set keymap vi-command`).

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 6 ปีที่แล้ว

    7:38 If you try examining what was entered into your command history, you will see that the 3 lines have been turned into 1 line, with semicolons inserted to separate the statements.

  • @rikfomiharbi6077
    @rikfomiharbi6077 3 ปีที่แล้ว +1

    Sudo bang bang !
    Something can never be forgotten 😂❤

  • @cdnuzzo
    @cdnuzzo 6 ปีที่แล้ว

    These videos are great! Looking forward to more and more in-depth practical and theory based tutorials.

    • @tutoriaLinux
      @tutoriaLinux  6 ปีที่แล้ว +1

      Yeah, I've got some advanced ones coming -- in-depth systemd tutorials, compiling a kernel, writing your own syscalls. Woohoo!

  • @TimStCroix
    @TimStCroix 3 ปีที่แล้ว

    My candidate for number 6 would be ^^^
    Replaces with in the previous command. Ex:
    #sudo apt update
    #^date^grade^
    For something this simple you can omit the final ^, so #^date^grade

  • @apmechev
    @apmechev 6 ปีที่แล้ว

    Heads up, ctrl+W uses spaces to delimit words only if your $IFS is equal to [SPACE]. It's the variable (bash) uses to determine what separates bash keywords

  • @abzs5811
    @abzs5811 10 หลายเดือนก่อน

    Some people just aren’t cut out to be teachers
    Now Colt Steele is a natural born teacher right there.

  • @dawiss9418
    @dawiss9418 6 ปีที่แล้ว

    Thanks i learned about ctrl + x + e and less +F.

  • @mr.w4ttz
    @mr.w4ttz 3 ปีที่แล้ว

    I like that we almost got to see your auth.log

  • @ResPaWn1911
    @ResPaWn1911 6 ปีที่แล้ว

    fc
    Fix command, opens last in $EDITOR to fix it. Awesome.
    Also, your commands are available if you set editing-mode to emacs (also I think is the default). If you set it to vi, then you can press Esc and start using vi bindings. Thats pretty awesome too if you are used to those things.

  • @adeshas83
    @adeshas83 6 ปีที่แล้ว

    I thought I knew a lot.... Great video... Thumbs up

  • @Tomab89
    @Tomab89 6 ปีที่แล้ว

    Very handy tips. Appreciated.

  • @RowlandOConnor
    @RowlandOConnor 4 ปีที่แล้ว +1

    Enable VI mode in BASH and leverage your existing VIM skills. Save time learning yet more key bindings.