232

Twitter: Julia Evans @b0rk

Comments
  • 23
    Woooow thanks. Using linux terminal constantly for 6 years now and i didnt know few of those. But that might be because i use zsh
  • 9
    $ sudo !!666
  • 4
    @RustyCookie that...what even is that? :|
  • 10
    You can use !!<number> to recall commands from history.
  • 7
    @RustyCookie damn, didn't know that. Thanks :)
  • 5
    Each one of this I have used but loops will Convert a.PNG a.PNG.jpg so I would say you might want to extract the filename before convert.
    And the braces prefer seq command as you can set width like 01, 02, ... 10 .
    I would say sed is one of the most powerful tool I have come across
  • 4
    @Bitwise !! is used to run the last command entirely. If let's say you ran a command but it gave an error that you're not sudo, so you can just do "sudo !!" it will run the entire previous command with sudo.

    With "!$" you take only the last word of the previous command.
  • 3
    @Bitwise haha I might have interpreted it wrong, my bad.
  • 1
    Wow this is cool 😱😱😱
    Thank you 🤗🤗
  • 3
    just leaving my two cents, ctrl+d ends the session. as far as I can tell, it's the same as running "logout"

    but you probably know that
  • 6
    Cd will move you to home

    I know its basic, but alot of people always use cd ~
  • 3
    @Bitwise
    I use it when using arch for MPV or media player. Works like a charm
  • 2
    @Bitwise and if you want to get them back to the foreground process just use:

    jobs #lists all jobs running
    fg x # with x being the id of the process shown by the "jobs" command
  • 4
    also, there is the

    cd -

    which expands to

    cd /the/last/folder/you/were/in/

    this also works with git branches (e.g.: git checkout -)
  • 3
    My personal favorites: Ctrl+s and Ctrl+q.

    As an emacs user with a vim habit, the first one pauses the current process, the second resumes it.
  • 1
    @Bitwise I believe that if you ctrl-z, and then logout, it’ll kill the process because it was a child process of the current session. I think...
  • 2
    @vhoyer
    cd - stands for cd $OLD_PWD
    @natesymer
    I hate that one because I feel like I am saving hence I press it twice then writing something only to realise that it has paused then I press ctrl +q to see that I typed asdfsfssads
    Is there any practical use for it ?
  • 0
    I'd also include `set -o vi` :) For VIM users.

    And most of ${variable:XXX} expansions (the XXX parts). Every day they are always behind my belt.

    I'm glad noone mentioned backticks... Thanks God these are drowning in the past. It literally (yes, literally) hurts me see scripts written with backticks.
  • 1
    Ctrl-a and ctrl-e: for systems without home and end keys.
  • 3
    I like:

    $ suod superlongcommand --with-parameters

    😡

    $ ^suod^sudo.

    😄

    And I think it pays off to just learn the basics of all the commonly available tools:

    pwd, export, cat, less, nc, nl, wc, grep, tee, head/tail, tr, diff/comm/cmp, bc, pass, join, cut, awk, open, find, curl, wget, lsof, expr, which, ln, chmod, chown, uniq, sort... etc

    The true power of bash lies in piping & combining commands. A lot of commands to something very simple like manipulating a string or a file.

    When you use git, you might think: Oh I wish I could quickly purge all files with that password in it, or rebase all commits up to the point where it forked from master, or you want to remove all "fucks" from your commit messages before pushing -- Pipes |, expansions ${} and substitutions $() can make it easy to chain things together.

    And once you have a nice combination commands, don't forget to alias it in your bash (zsh/fish/etc) profile!
  • 1
    I tend abuse the subcommand.

    $kill $(ps -ef | grep mytask | awk -F '{print $2}')
  • 1
  • 2
    the most important trick I've found so far is:

    ALWAYS WRITE --HELP MESSAGES FOR YOUR CUSTOM SCRIPTS

    else your gonna find yourself opening that damn file so many times
  • 1
    Ctrl + u: remove everything left of cursor
    Ctrl + w: remove word left of cursor
  • 3
    Nice! thanks for sharing everyone!

    Thanks for sharing your .bashrc scripts @Bitwise 👍
    Your code looks good, clean and readable (Given it has a differemt indentation).
  • 2
    @Bitwise I will remember that space one for sure!
Add Comment