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

Поделиться
HTML-код
  • Опубликовано: 2 июн 2018
  • My favorite tricks for becoming a Linux Shell Speed Demon (this assumes Bash/readline)
    1:04 - sudo !! - re-run previous command with 'sudo' prepended
    1:53 - ctrl-k, ctrl-u, ctrl-w, ctrl-y - cutting and pasting text in the command line
    3:24 - practical kill/yank example
    4:04 - use 'less +F' to view logfiles, instead of 'tail' (ctrl-c, shift-f, q to quit)
    6:25 - ctrl-x-e - continue editing your current shell line in a text editor (uses $EDITOR)
    7:54 - alt-. - paste previous command's argument (useful for running multiple commands on the same resource)
    9:18 - reset - resets/unborks your terminal
    My step-by-step project-based Linux course for beginners: www.udemy.com/course/hands-on...
    Free Linux Sysadmin Course Playlist: • The Linux Basics Cours...
    DigitalOcean referral link: m.do.co/c/0380a1db56a6
    Patreon: / tutorialinux
    Official Site & e-mail list: tutorialinux.com/
    Twitter: / tutorialinux
    Facebook: / tutorialinux
    Podcast: kernelpanicpodcast.com
  • НаукаНаука

Комментарии • 729

  • @tutoriaLinux
    @tutoriaLinux  6 лет назад +211

    ~~~ 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 5 лет назад +2

      i literally screamed when i learned the kill / yank

    • @DaleHawkins
      @DaleHawkins 5 лет назад

      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 лет назад +200

    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.

  • @GBGSK
    @GBGSK 5 лет назад +154

    > 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 5 лет назад +195

    "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 года назад +16

      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.

    • @richardcampbell2438
      @richardcampbell2438 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

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

    • @ernestdesouza8888
      @ernestdesouza8888 3 года назад

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

  • @ChunkyDrew33136
    @ChunkyDrew33136 5 лет назад +11

    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.

  • @whiskeytuesday
    @whiskeytuesday 6 лет назад +7

    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.

  • @momashi69
    @momashi69 5 лет назад +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!

  • @jplflyer
    @jplflyer 3 года назад +11

    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 года назад +1

      @@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.

  • @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

  • @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.

  • @elijah11162
    @elijah11162 3 года назад +3

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

  • @toncho1986
    @toncho1986 6 лет назад +21

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

  • @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!

  • @neloangelo__13
    @neloangelo__13 6 лет назад +1

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

  • @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!

  • @IRgEEK
    @IRgEEK 5 лет назад

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

  • @dylanwestphal3582
    @dylanwestphal3582 3 года назад

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

  • @mostafafarzan5363
    @mostafafarzan5363 3 года назад +4

    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.

  • @ernestogutierrez7877
    @ernestogutierrez7877 3 года назад +4

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

  • @dawidpomioto1595
    @dawidpomioto1595 4 года назад

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

  • @asanz1665
    @asanz1665 5 лет назад

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

  • @aronhegedus
    @aronhegedus 3 года назад +1

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

  • @tobiassinghania3698
    @tobiassinghania3698 5 лет назад +11

    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 5 лет назад +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 :)

  • @dukercs
    @dukercs 3 года назад +1

    Thank you!!! This video should never die!

  • @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.

  • @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!

  • @TheDave000
    @TheDave000 5 лет назад +15

    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?

  • @jony7779
    @jony7779 6 лет назад +96

    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 5 лет назад +34

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

    • @tobiaskrischer9950
      @tobiaskrischer9950 5 лет назад +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 3 года назад +4

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

    • @twb0109
      @twb0109 3 года назад +3

      @@iam3377 laughs in nvim

  • @locusinbloom
    @locusinbloom 5 лет назад

    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.

  • @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.

  • @leteveryoneknow
    @leteveryoneknow 5 лет назад +1

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

  • @vrvrvr81
    @vrvrvr81 5 лет назад +2

    first useful shell video tutorial I ever ran into

  • @tildessmoo
    @tildessmoo 5 лет назад +10

    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.

  • @uniquechannelnames
    @uniquechannelnames 2 года назад

    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!

  • @KarenDian1
    @KarenDian1 6 лет назад

    Your awesome channel popped up in my recommendations. Subscribed!

  • @eduardosanchez9245
    @eduardosanchez9245 6 лет назад +1

    Loved the "BONUS ROUND!" :)

  • @Colony28
    @Colony28 4 года назад

    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

  • @hayksk
    @hayksk 3 года назад

    Super !! Thank you a lot!!!
    These were very useful tips.

  • @user-ug8qc6tr6b
    @user-ug8qc6tr6b 6 лет назад

    Nice tips and clean explanation. Thank you

  • @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!

  • @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

  • @Breemskin
    @Breemskin 2 года назад

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

  • @RedStefan
    @RedStefan 5 лет назад +55

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

  • @BBRR442
    @BBRR442 3 года назад

    Awesome vid!! Very helpful!

  • @CoreDump07
    @CoreDump07 6 лет назад

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

  • @fbicknel
    @fbicknel 3 года назад

    Nice collection. Thanks for the video!

  • @apistosig4173
    @apistosig4173 4 года назад

    fabulous presentation - muchas gracias

  • @anjumamute
    @anjumamute 6 лет назад

    Thank for the video, I already know someone of this tricks, but others were new.

  • @ryanbard3560
    @ryanbard3560 6 лет назад +59

    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 5 лет назад +4

      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.

  • @NoCPU
    @NoCPU 6 лет назад

    Great tut. Very useful

  • @Tomab89
    @Tomab89 5 лет назад

    Very handy tips. Appreciated.

  • @kpopempire1475
    @kpopempire1475 3 года назад +1

    Thank you! Very informative.

  • @rafaelcascalho4180
    @rafaelcascalho4180 6 лет назад

    These are veeeeeery helpful!! Thanks bro :D

  • @rampage241
    @rampage241 6 лет назад

    cool video bro. 2 min in and I already liked!

  • @flakkanon
    @flakkanon 6 лет назад

    Thanks for all your free content :)

  • @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!

  • @nissieln
    @nissieln 3 года назад

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

  • @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.

  • @pmdpaula
    @pmdpaula 6 лет назад

    Thanks a lot for these tricks.

  • @erezhazan100
    @erezhazan100 4 года назад +1

    Thanks!! really helpful commands!!

  • @amoohesam
    @amoohesam 5 лет назад +1

    Very nice tutorial, thanks

  • @mykolakriukov1252
    @mykolakriukov1252 3 года назад

    Awesome tips, thanks a lot!

  • @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

  • @codingwithgraceandtruth2456
    @codingwithgraceandtruth2456 2 года назад

    very good tutorial, powerful commands, thank you.

  • @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.

  • @3BMWHunter
    @3BMWHunter 6 лет назад

    extremely helpful! thanks for the great video

  • @joeleenkado5761
    @joeleenkado5761 4 года назад

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

  • @TheSimslash
    @TheSimslash 3 года назад

    nice vid man, thanks for the tips and keep it up ! :)

  • @fahadkhanchughtai3279
    @fahadkhanchughtai3279 3 года назад

    Just Wao, I am gonna use em. Thanks Dude!

  • @adeshas83
    @adeshas83 6 лет назад

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

  • @DivineRaven
    @DivineRaven 3 года назад

    You are a blessing, man. Thanks!

  • @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.

  • @nirmitpatel7536
    @nirmitpatel7536 6 лет назад

    These were great, thank you.

  • @andrewlemstrom3669
    @andrewlemstrom3669 2 года назад

    Helpful man. Thank you.

  • @keratishvili
    @keratishvili 6 лет назад +2

    Thank, I really appreciate less command explanation and would love to see more videos.

  • @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

  • @rikfomiharbi6077
    @rikfomiharbi6077 3 года назад +1

    Sudo bang bang !
    Something can never be forgotten 😂❤

  • @arpitparmar2121
    @arpitparmar2121 2 года назад

    Awesome video man, thank you :)

  • @osgnuru
    @osgnuru 5 лет назад

    Thanks for the video. Love it!

  • @Majlo2L8
    @Majlo2L8 6 лет назад

    Perfect tricks. thank you so much!

  • @parasarora5869
    @parasarora5869 4 года назад

    great one !!!...thanks for the video 😄

  • @joachimjohansen5796
    @joachimjohansen5796 5 лет назад

    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.

  • @firstlast7086
    @firstlast7086 3 года назад

    Excellent video!

  • @ddastoor
    @ddastoor 3 года назад

    awesome vid man !!!

  • @WaichiTsang
    @WaichiTsang 2 года назад

    These tricks saved my day

  • @StefanoPapaleo-TS
    @StefanoPapaleo-TS 6 лет назад

    Great tips. Thanks!

  • @Oidium45
    @Oidium45 4 года назад

    Great vid bro. Thanks!

  • @Idlecodex
    @Idlecodex 3 года назад

    Really cool! Thanks!

  • @DrAkyla1123
    @DrAkyla1123 5 лет назад

    Awesome stuff! Thank you very much :)

  • @tomwimmenhove4652
    @tomwimmenhove4652 3 года назад

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

  • @cottondai
    @cottondai 3 года назад

    This is awesome linux tips.

  • @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.

  • @ManishKumar-uy5io
    @ManishKumar-uy5io 3 года назад

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

  • @8bitRaccoon
    @8bitRaccoon 3 года назад

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

  • @CmdrStukov
    @CmdrStukov 6 лет назад +2

    Nice, subscribed immediately when I saw that Alt-. shortcut

  • @dawiss9418
    @dawiss9418 6 лет назад

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

  • @TesserId
    @TesserId 3 года назад +29

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

  • @TheImgoodman
    @TheImgoodman 2 года назад

    Thanks, man. Good video.

  • @DerekBraid
    @DerekBraid 3 года назад

    Thanks for sharing!