5 Linux Shell Tricks

5 Linux Shell Tricks

  • 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
    • ctrl+k 刪除後面的文字
    • ctrl+u 刪除前面的文字
    • ctrl+y 貼上剛才刪除的文字
    • ctrl+w 刪除一個字 (word)
  • 4:04 use ‘less +F’ to view logfiles, instead of ‘tail’ (ctrl-c, shift-f, q to quit)
    • 在 less +F 的狀況下按下 ctrl+c 可以直接瀏覽檔案,就不用在 vim
    • shift+f 退出 ctrl+c 的環境
    • q 退出 less +F 的環境
  • 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