linux:
openssl passwd -crypt 12345
will generate different output every time but how to check the12345
send from client whether is same as the server.xargs
convert stdout to argsls |xargs echo
- press
c-v
in vim enter visual block then do the multi select - linux redirect link1,link2,link3,link4
- use
who
,last
to get all logined user curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -
for testing network speedman -k
orapropos
tail -n 20 /var/log/nginx/error.log
to find nginx problem.cat ~/.ssh/id_rsa.pub | ssh username@hostname ' mkdir -p .ssh && cat >>.ssh/authorized_keys'
copy public key to serverauthorized_key
.sudo chown -R group:user folder
change the folder user group.docker update --restart=no my-container
to update the running container flaggrep --color -R --exclude-dir=node_modules '\.js"\
to findcurl -v -H "Accept: application/json" https://httpbin.org/get
will see the request header and bodycurl -s -I -v http://www.baidu.com
simple get request and response headerfind / -type d -name "*Chrome.app"
find chromenpm-check -u
to check npm package healthcurl http://www.vdberg.org/~richard/tcpping -o tcpping
to download tcppingcat foo.c | sed '/^\s*#/d;/^\s*$/d' | wc -l
to count-non-blank-lines-of-code-in-bashstty -ixon
to enable XON/XOFF flow control then you can usectrl-s
to reverse-reverse-i-searchfind . -type f -name '*.gz' -exec rm {} +
to remove all file type endwith gzcurl cli.fyi/help
a++
is unarysetw -g mode-keys vi
for tmuxexport http_proxy='http://proxyServerSddress:proxyPort'
finallyunset http_proxy
echo 050100 | xxd -p -r | netcat -o out.txt {server} {port}
test socks5 proxysocat tcp-l:7654,fork,reuseaddr tcp:27.122.57.247:7654 &
socat UDP-LISTEN:7654,fork,reuseaddr dup:27.122.57.247:7654 &
for port forwardcp /home/sample.txt{,-old}
=>cp /home/sample.txt /home/sample.txt-oldx
apropos "list directory"
to recall commandcurl -o /dev/null -s -w 'Establish Connection: %{time_connect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' https://www.google.com
mtr='PATH=/usr/local/sbin:$PATH sudo mtr'
export PATH=/opt/local/bin:/usr/local/Cellar/mtr/0.92/sbin/:$PATH
enable mtr at mac..who | grep -v 'via mosh' | grep -oP '(?<=mosh \[)(\d+)(?=\])' | xargs kill
orkill pidof mosh-server
kill the mosh session belong to youps aux | grep "[f]nord"
orps aux | grep -v grep | grep "fnord"
orless -r output.txt
to view termnial-style txtsudo du -a / 2>/dev/null | sort -n -r | head -n 20
find big filesiptables-save |vi -
to check the rule scriptiptables -A INPUT -s 192.168.1.100 -p icmp -j DROP
oriptables -A INPUT -p icmp -j DROP
wireshark -k -i <( ssh -l root IP-of-probe /usr/bin/tshark -i eth0 -w - port 53 )
capture remote ssh network packagefind -type f -print0 2>/dev/null | xargs -0 -n 10 grep -i searchstring 2>/dev/null
Redirect standard error to /dev/nulldu -h -d 1 | sort -hr
see folder sizesh -x script [arg1 ...]
bash -x script [arg1 ...]
set -x
set +x
debug script- you need confirm your
.ssh
folder is accessible by user(you will get a key failed auth).chown -r owner-user:owner-group .ssh
for change to file owner - replace str
grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'
in OSXsed -i "" 's/str1/str2/g'
cat 0021500492.json | python -m json.tool |less
for view large json file.sudo add-apt-repository universe
thensudo apt-get install netcat-traditional
thensudo update-alternatives --config nc
finallySelect the option /bin/nc.traditional
curl -s -v -X HEAD http://foo.com/bar/baz.pdf 2>&1 | grep '^< Last-Modified:'
for query website upgrade timesocat tcp-l:4431,fork,reuseaddr tcp:152.32.191.48:4431 & socat UDP-LISTEN:4431,fork,reuseaddr dup:152.32.191.48:4431 &
proxyiftop -n -N -f "host 112.64.175.162"
filter the specified network trafficgrep -e "search_word" -rn folder
show the line number of fined fileecho $SHELL
orps -p $$
to determine current shell.ls -l node_modules/* | egrep "^l"
output the softlinkfind / -name art 2>/dev/null
to skip the error output.curl ip.sb
,curl ident.me
,curl ip.cn
%s/phrase to delete//gc
delete word in vim.apt-cache search keyword
. ubuntunpm list --depth=0 2> >(grep -v "extraneous")
npm list -s
ignore error message.find ./ -type d -name "node_modules" -exec rm -r {} \;
.docker build . -t application_name -f path_to_dockerfile
git ls-files | grep '\.py' | xargs wc -l
list number of code line.find . -name '*.php' | xargs wc -l
,wc -l **/*.tsx
.npm view webpack versions --json
ls -l -sh
,du -h
for file human readable sizesALL_PROXY=socks5://host:port brew update
brew upgrade --cask chromedriver
grep " install " /var/log/dpkg.log*
installed packages with installation datesshd -T | grep -E 'gatewayports|allowtcpforwarding'
Trouble enabling GatewayPorts for Remote Port Forwarding over SSH- Debug iptables
uptime
,last reboot
,log show --predicate 'eventMessage contains "reboot"' --last 1h
troubleshoot mac reboot issue.
iptables -t raw -A PREROUTING -p tcp --destination 192.168.0.0/24 --dport 80 -j TRACE
iptables -t raw -A OUTPUT -p tcp --destination 192.168.0.0/24 --dport 80 -j TRACE
cat /var/log/kern.log | grep 'TRACE:'
crontab -l
,crontab -e
cat /proc/meminfo
,free -g
to check memory infosudo chown --reference ${DEST_DIR} -R ${DEST_DIR}/copied_dir
,chmod --reference=file1 file2
ssh -L local_port:remote_host:remote_port ssh_host
make remote resource accessible in client.ssh -D local_port [email protected]
as socks5 proxy provider.- list files size
du -sh * | sort -h|tail -n 20
- copy exclude
cp -r
ls -A |grep -E -v "@storybook|@nx|typescript|.cache|.bin|@nrwl|@babel|@jest"desition_folder
- do the same above
rsync -av --progress sourcefolder /destinationfolder --exclude thefoldertoexclude --exclude anotherfoldertoexclude
git:
1. git show head~1:/path/to/file
2. git rev-list --all --remotes --pretty=oneline -- src/views/trade/other.vue
get the file commit log in all history.
3. git config --system -l
to check system check. Then git config --system --unset credential.helper
to forget the credential . git config --global credential.helper store
enable credentials storage git config --global core.ignorecase true
.
4. git ls-files -z | xargs -0 -n1 -I{} -- git log -1 --format="%ai {}" {} | sort
retrieve the last date of all files.
5. git diff origin/master > patch
,git apply --check xxx.patch
,git apply --status xxx.patch
, git apply --revers patch
to update branch.
6. git reset --hard HEAD^
or git reset --soft HEAD^
to undo a local commit .git revert HEAD
then git push origin
for remote update.
7. git config credential.helper cache
for temporary cache your account infor git config --system --unset credential.helper
.
8. git diff ..origin/dev|git apply
apply the diff between remote dev to local current head in stage
9. git log --all --decorate --simplify-by-decoration --graph --all --date=relative
try to figure the relationship between branch
10. git branch --contains --all $branchName
show all branch(include remote) which contain current branch
11. git config --global core.fileMode false
ignore.
12. git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
.
13. git log origin/release..HEAD --graph --decorate --oneline
show the different commit between branch.
14. gitk --all file
will show the all history of the file git checkout -p
give you a change to checkout each hun individually
15. unable to access 'https://github.com/xxxx/xxx.git': Failed to connect to 127.0.0.1 port 8087: Connection refused
may related to system http proxy env|grep -i proxy
.
16. git show-ref --abbrev=7 --tags
show tag commit id.
17. cat .git/refs/tags/*
show git tag.
18. npm outdated -g
npm ls --depth=1
npm la
npm show package version
npm search
npm completion >> ~/.bashrc
19. use git patch
cherry pick only one file git diff <branch>..<other-branch> --<fileName> |git apply
20. git show branch:file
git merge branch --no-commit --no-ff
to ignore no-diff merge .
21. git ignore case default.
22. git apply --3way patchFile.patch
Typical fail case applies as much of the patch as it can, and leaves you with conflicts to work out in git however you normally do so.
23. git push --follow-tags
only push tag created by git tag -a <tagname> -m '<message>'
,git push origin tagname
push the specified tag.
24. git diff --name-only release-1.1.19..release-1.1.31 -- '*.tsx' -- '*.ts' -- '*.less'
show the different between two commit.
25. git fetch --prune --prune-tags origin
synchron remote tag with local
26. git push origin branchA:branchB
push the nickname.
27. git checkout master
and git merge <commit hash>
.
28. git log head..origin/master --name-only --no-merges
.
29. git merge --no-comit --no-ff
branch & git merge --abort
to test the merge status.
30. git stash push --keep-index -u
stash un-staged,untracked. git stash save --patch
.
31. fast-forward.
32. git reset
move back the history, git revert
add a commit.
33. git add --interactive
.
34. git log -u -L <upperLimit>,<lowerLimit>:<path_to_filename>
specific the line number
35. git log --all --diff-filter=D --sumary
. show the deleted file. git checkout <SHA>^ -- /path/to/file
. restore te file
36. git branch --sort=-committerdate
descend, git brand --sort=committerdate
asecend. git branch -vv
.
37. git rebase -i --ignore-date
update the date to current time.
38. git config --global core.editor "vim"
39. git log --pretty=format:"%h%x09%an%x09%ad%x09%s" --graph --all --decorate --date=relative --abbrev-commit %h
:hash, %x09
:tab,%an
:author_name,%ad
:author_date,%s
:subject
40. git merge --no-commit --no-ff $BRANCH
test before merge than git merge --continue
VSC:
1. ctrl+D
add current selection to match . Ctrl+Shift+D
+ add all selection .
2. ctrl+shirft+O
show symbols (quick variable,method quick goto).
3. ctrl+option+P
show next problem.
VIM:
1. ma
set mark a
, 'a
,`a
jump to mark a
. :marks
show the mark list.
2. ctr+z to put vim background, bring it back by fg
mis:
http auth
containsbasic auth
,digest auth
.return401
when auth fail.- simple http get request
GET / HTTP/1.1/r/nHost: www.baidu.com/r/n/r/n
,blog - tcp allows for retransimmsion of lst packets gitbook
- get script error when cors fundebug
- image error do not trigger window.onerror, you have to listen for them specifically mdn
- Triggering built-in events
- Synchronous JavaScript pauses parsing of the DOM delay the fired of DOMContentLoaded mdn
this
is different when use in onClick and addEventListener('click') mdn- use
db.things.find( { ln : { $exists : true } } );
to select by the given key nedb - use
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
to get weixin apiaccess_token
blog - 30-seconds-of-code了解下git
- Greedy
/.+/
match as many as possible and lazy/.+?/
as few as possible tutorial encodeURIComponent
will encode=
,so encodevalue
notkey=value
when encode path- server return
304
when requestIf-Modified-Since
<= responseLast-Modified
and requestIf-None-Match
==
responseETag
Promise.reject(1).then(console.log).catch(console.error).then(3=>console.info(3))
- X-Forwarded-For, IP Transparency with nginx
- [os x locale is not set UTF-8]
locale
export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8
or add~/.bash_profile
thensource ~/.bash_profile
w !sudo tee %
:w #write a file
!sudo #call shell sudo command
tee # the output of vi/vim
% #trigger the use of current fielname
- set up a clean utf8 linux
- override
pushState
and listener for onPopState can watch the url history change. url echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all
for temp allow or appendnet.ipv4.icmp_echo_ignore_all=1
to/etc/sysctl.conf
for save to disk- Data URLS, URLs prefixed with the
data:
scheme,allow content creators to embed small files inline in documents. mdn require
,the path is relative to that source file(NOT root directory),fs
,the pat is relative toprocess.cwd()
(NOT that source file) .You should usepath.resolve(__dirname,'../other/module.js')
- If the request method is
GET
orHEAD
,XMLHttpRequest
will ignore request body . require
vsimport
link204 No Content
is meant to say there is no body to returncache:http://www.baidu.com
to see the website cached by google in chrome- babel-plugin-component to require on demand for optimizing code size.
Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
// Multiple types, weighted with the quality value syntax:- The old-style backquotes ` ` do treat backslashes and nesting a bit different. The new-style $() interprets everything in between ( ) as a command.
python -m SimpleHTTPServer <port_number>
python3 -m http.server
rsync -av --delete source_folder destination_folder
git fetch --prune --prune-tags
,git log --oneline --name-status --grep='Searched phrase'
git log commit-id-before commit-id --stat
show the lines added/changed/deleted. (git diff --numstat HEAD~
).SELECT db_name()
get current database name.curl -k -O -L https://npmjs.org/install.sh
sh install.sh
install nodejs.^x.y.z
stands for version betweenx.y.z
and next major .~x.y.z
means betweenx.y.z
and next minor.kill $(lsof -ti:3000,3001)
kill ports in mac.time nmap -p 22 portquiz.net
test specified port.time nmap portquiz.net
popular port.time nmap -p- portquiz.net | grep -i open
all outgoing port.(Very slow).rectangle
,alttab
,Xnip
,keyCastr
tool in mac.- mute the soud of
tab
in window terminal - remote send c when double click.
- (fix dock always cover the bottom of application)[https://appuals.com/how-to-fix-mac-dock-getting-stuck/] just
killall Dock
. open -e ~/.bashrc
mac.npx kill-port 8080
kill portArray.from(Array(2), () => new Array(4))
create multi dimension arraypm2 startup
to setup auto restart strategy.'ThisIsASlug'.replace(/(\w)(?=[/A-Z])/g,'$1 ')
split camelCase.sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
clean mac DNS cache.-scheme:chrome-extension -scheme:data
orscheme:https
to filter out extension request in chronium based browser-scheme:chrome-extension -scheme:data
orscheme:https
to filter noise request in chrome network tabgit commit --fixup=HEAD
andGIT_SEQUENCE_EDITOR=true git rebase -i --autosquash HEAD~2
aftergit add
to quick fixup the commit.lpstat -s
show mac printer IP- Route different traffic through different network interfaces in windows
route add 10.183.148.0 mask 255.255.255.0 10.57.175.79
kube:
kubectl logs -l app=elasticsearch -n namespace
get all pods log from namspacedocker kill $(docker ps -q)
stop all docker containers.docker exec -ti container_name /bin/bash
ordocker exec -ti container_name sh
docker container ls|grep "yarn start"|awk '{print $1}'|xargs docker container stop
kubectl get pods -n $namespace
show all running pod under namespace.kubectl exec --stdin --tty $podname -n $namespace -- /bin/bash
run the shell environment.helm search repo $name
,helm list -n $namespace
docker container ls -a |grep docker-entry|awk '{print $1}'|xargs docker container rm
docker rmi $(docker images --filter "dangling=true" -q --no-trunc
kubectl describe ingress $container
,kubectl describe configmap $container
kubectl exec --stdin --tty $pod -n $namespace -- /bin/sh
kubectl logs pod
kubectl config get-contexts
,kubectl config use-context $context
,kubectl config set-context --current --namespace=$namespace
kubectl port-forward pod 80:127.0.0.1:8888