Modern Unix
Modern Unix command
-
tee: Outputting to stdout and a File -
bat: modern ofcat -
exa: modern ofls, e.g.$exa --git -l --tree -
fd: modern offind, e.g.$fd ^foo -
rg: modern ofgrep -
jq: sed for json data -
cheat: cheatsheet, modern ofman -
tldr: modern ofman -
btm: modern oftop,bottom -
glances: modern oftop -
dog: DNS client, modern ofdig -
hyperfine: benchmarking tool -
gping: modern ofping -
curlie: modern ofcurl -
dust: modern ofdu, disk usage statistic by file -
duf: modern ofdu, show disk free space -
wrk: monitoring and benchmark -
tmux: terminal multiplexer: project session-* multi windows -* panes
tmux - terminal multiplexer
-
ctrl+b+c/&: create/exit new window -
ctrl+b+%/"/x: split pane vertically/horizontally/exit
ssh - send file to remote ssh host
-
$SSH username@ip-address: login into a remote Linux machine using SSH -
$put file: upload ‘file’ from local to remote computer -
$get file: Download ‘file’ from remote to local computer -
$quit: Logout
tar - compression
$ tar cvzf archive_name.tar dirname/: compress
$ tar xvf archive_name.tar: uncompress
sed - text processor
sed 's/.$//' filename: Print file content in reverse order $sed -n '1!G;h;$p' thegeekstuff.txt: Add line number for all non-empty-lines in a file
xargs - execute util
fd -t f -e jpg -x tar -czf images.tar.gz
ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory
cat url-list.txt | xargs wget –c
IO direction
-
cmd < file: Input of cmd from file -
cmd1 <(cmd2): Output of cmd2 as file input to cmd1 -
cmd > file: Standard output (stdout) of cmd to file -
cmd > /dev/null: Discard stdout of cmd -
cmd >> file: Append stdout to file -
cmd 2> file: Error output (stderr) of cmd to file -
cmd 1>&2: stdout to same place as stderr -
cmd 2>&1: stderr to same place as stdout -
cmd &> file: Every output of cmd to file
Pipes
-
cmd1 | cmd2: stdout of cmd1 to cmd2 -
cmd1 |& cmd2: stderr of cmd1 to cmd2 -
cmd1 ; cmd2: Run cmd1 then cmd2 -
cmd1 && cmd2: Run cmd2 if cmd1 is successful -
cmd1 || cmd2: Run cmd2 if cmd1 is not successful -
cmd &: Run cmd in a subshell
parallels keyboard settings (osx)
-
cmd left = home
-
shift cmd left = shifthome
-
cmd right= end
-
shift cmd right= shift end
-
cmd= ctrl
print two pages per PDF sheet (osx)
-
create virtual postscript driver > system perf > add new printer
-
Choose IP > choose Line Printer Daemon - LPD
-
In the Address field, type in localhost
-
preview > print > change preview to layout > change pages per sheet to 2
-
change back from layout to preview > turn scale to x%