bash
-
options
--: disable further option processing.-i: interactive-l: login-shell
-
man [command]: show manual for command -
apropos [reg-exp]: search in the DESCRIPTION field of all manuals. -
shortcuts
ctrl-wdelete last wordctrl-a/e: move cursor to the beginning/ending.ctrk-l: clear screenalt-b/f: move cursor word-wisealt-#: comment the current command and run it.
-
!$the parameters from the last command. -
pgrep -a [pattern]: list processes matching pattern. (a means list-all)- similar to
ps aux | grep [pattern]
- similar to
-
pkill [pattern]: kill processes matching pattern. -
traceback bash error:
set -euo pipefail trap "echo 'error: Script failed: see failed command above'" ERRbash -
locally move working directory:
# do something in current dir (cd /some/other/dir && other-command) # continue in original dirbash -
login shells v.s. non-login shells
/etc/profile, ~/.profile, ~/.bash_profile: for login shells (the first process that executes under your user ID, e.g., bysuorssh)~/.bashrc: for interactive non-login shells (shells started in an existing session).
-
sudo -u [user]: run command as user. -
repren: batch rename- [tbc]
-
the fastest way to delete large amount of files:
mkdir empty && rsync -r --delete empty/ some-dir && rmdir some-dirbash -
tac: reversedcat -
ncdu: n-curses versiondu. -
tar xf <file>: one command to uncompress all kind oftar/tar.xz/tar.gz