Skip to content

Instantly share code, notes, and snippets.

@Kiollpt
Last active July 19, 2021 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kiollpt/305776724b2444fca561d57865c599c9 to your computer and use it in GitHub Desktop.
Save Kiollpt/305776724b2444fca561d57865c599c9 to your computer and use it in GitHub Desktop.
#Linux
LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS; ls
export LS_OPTIONS='--color=auto'
#eval "$(dircolors -b)"
alias ls='ls $LS_OPTIONS'
# tmux
alias tmux="TERM=screen-256color-bce tmux"
$ cd -
switch to the previous directory
$ pv access.log | gzip > access.log.gz
611MB 0:00:11 [58.3MB/s] [=> ] 15% ETA 0:00:59
$ sudo !!
Rerun the previous command as root.
Ctrl-R
searches the command history.
ALT-. (ESC+. in some terminals) copies last used argument (super-useful)
CTRL-W deletes word
CTRL-L clear terminal (like clear command but faster)
ALT-B (ESC+B in some terminals) move backward a word
ALT-F (ESC+F in some terminals) move forward a word
CTRL-E jump to EOL
CTRL-A jump to BOL and CTRL-K delete the line
for item in items; do `echo` ricky-action; done
add `echo` before committing like `rm $files` (varibale expansion[preceed with $], or glob[* ?])
set -x
check the flow of script
$ watch
watch tail logfile1 logfile2
$ grep -l : only matched filename
-L : only not matched filename
-n : show the number of line
-w : not substring
$ find . -type l
find symbolic link
$ find . -name * | xargs grep
combination with gerp and find
combination
sudo find . -name "*.py" | xargs grep -wsl fairseq --color | awk 'BEGIN{FS="/";OFS="/"} {print $2,$3}' | uniq -d
$ nohup:
- nohup my_command > my.log 2>&1 &
- echo $! > save_pid.txt
# shell instance PID
echo "$$"
# find the process by giving PID
ps -p <PID>
$ sed:
- sed -n '{200,250p}' article_tagging_min.py
$ lsof | grep nohup.out
$ awk:
combin=$(IFS='|' ; echo "${data[*]}")
pattern="/(${combin})($|,)/"
echo $pattern
awk "$pattern" $INPUT > $OUTPUT
# check ICMP (Ping) enabled(0), disabled(1)
cat /proc/sys/net/ipv4/icmp_echo_ignore_all
# dig xxx ANY: all record
# dig -x: query PTR(IP -> domain name)
# sudo -i : become root and use `root` shell (path / env)
# (sudo) su - become root and use `root` shell but not in /home/root
su cindy: become cindy but use harry shell
su - cindy: become cindy and use cindy shell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment