-
-
Save gladiopeace/560ce291bd06a32e5670f5f7890e9c1c to your computer and use it in GitHub Desktop.
linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[watch] | |
watch -n 1 docker ps | |
[script] | |
-d 파일이 디렉토리인지 체크 | |
-e 파일이 존재하는지 체크 | |
-f 파일이 일반적인 파일인지 체크 | |
-g 파일이 SGID 퍼미션을 가졌는지 체크 | |
-r 파일이 읽기 가능인지 체크 | |
-s 파일의 크기가 0이 아닌지 체크 | |
-u 파일이 SUID 퍼미션을 가졌는지 체크 | |
-w 파일이 쓰기 가능인지 체크 | |
-x 파일이 실행 가능인지 체크 | |
str='h1-eth0' | |
echo ${str%%-*} | |
echo ${str##*-} | |
str2='fopnp/base' | |
echo ${str2%%/*} | |
echo ${str2##*/} | |
[net] | |
# check tcp & udp | |
telnet host 24224 | |
nmap -p 24224 -sU host | |
[upstart] | |
initctl reload-configuration | |
tail -200f /var/log/syslog | |
initctl list | grep myservice | |
sudo start myservice | |
[grep] | |
grep 409 text.log | grep -v -E "(mobilehub|festival|place|play|view)" | |
grep -A10 -B10 409 test.log | |
[sh] | |
servers=(slave1.example.com slave2.example.com slave3.example.com); for s in "${servers[@]}"; do ssh -l ubuntu $s 'sudo apt-get -y install ruby2.0 && sudo gem install bundler' ; don | |
[linux] | |
mv access-14102[1-6].log /data1/accesslog2/tzt.app.net/ | |
ln -s /data1/accesslog2/tzt.app.net/* . | |
find -mtime +6 -type d -exec rmdir {} + # rmdir more older 6 days | |
find . -name '*.py' | xargs wc -l | |
ls -1 . | egrep "*result*" | xargs rm | |
rsync -avz -e ssh user1@host1:/tmp/dump_copies/platform-pool2/* /tmp/dump_copies/platform-pool2 | |
[vi] | |
echo ":set nocp | |
:set backspace=indent,eol,start" > ~/.vimrc | |
[curl] | |
response time | |
curl -o /dev/null -s -w %{time_total}\\n http://www.google.com | |
[awk] | |
awk '$9 == 500' access.log | awk '{print $19}' | |
awk '$9 == 500' access.log | awk '{print $20}' | |
awk '{print $20}' access.log | |
awk '{print $20}' access.log | sort | uniq -c | |
ll 141006* | awk '{ print; total += $5 }; END { print "total size: ",total }' | |
# SUM | |
awk 'FS="," {s+=$2} END {print s}' upload.csv | |
# 따옴표로 자르기 | |
awk 'FS="\"" {print $9}' 59.access.log | awk '{print $1}' | |
[process] | |
ctrl + Z (suspend) | |
bg (벡그라운드로 보냄) | |
jobs | |
fg (fore그라운드로 보냄) | |
from http://se.uzoogom.com/77 | |
[git] | |
# add branch to remote repo | |
git push origin oauth2 | |
# add tag to remote repo | |
git push --tags # push tags | |
# migration git repo | |
git remote add new-origin [email protected]:cloudtech/foobar.git | |
git push --all new-origin | |
git push --tags new-origin | |
#get remote branch | |
git checkout -t origin/nginx | |
git checkout --track origin/ansible | |
# old commit을 가지고 새로운 branch를 만든다 | |
git branch flash_back 16d28ad | |
# 삭제, commit, 아직 push전인데 rollback하기 | |
git checkout HEAD^ script/batch-insert-drive-infos.groovy | |
# generate a deploy key | |
ssh-keygen -t rsa -b 4096 | |
[iptables] | |
iptables -A INPUT -s 172.16.0.1 -p tcp --dport 80 -j DROP | |
iptables -D INPUT -s 172.16.0.1 -p tcp --dport 80 -j DROP | |
iptables -D INPUT 1 | |
iptables -L | |
iptables -L -t nat | |
iptables -I PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 1080 | |
while iptables -D PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 2080; do :; done | |
iptables -L -n -v -x | |
-L lists all the rules. | |
-n does not resolve the ip addresses. | |
-v lists the packet and byte count. | |
-x displays the byte count (otherwise it gets abbreviated to 200K, 3M, etc). | |
[postgres app config] | |
cd /Users/YOURUSERNAME/Library/Containers/com.heroku.postgres/Data/Library/Application\ Support/Postgres/var | |
pg_hba.conf | |
host all all 0.0.0.0/0 trust | |
postgresql.conf | |
listen_addresses = * | |
[limit] | |
ulimit -n 30000 | |
ulimit -Hn | |
ulimit -Sn | |
lsof | wc -l # current open file count | |
sysctl -w net.netfilter.nf_conntrack_max=262144 | |
sysctl net.netfilter.nf_conntrack_count | |
[xargs] | |
ll -al | grep 14B | awk '{print $9}' | xargs rm | |
[nginx deny] | |
location / { | |
#deny 192.168.174.97; | |
proxy_pass http://apihub_upstream; | |
#proxy_set_header X-Daum-IP $remote_addr; #for apihub-dev1 which doesn't have a LB | |
proxy_set_header Host $http_host; | |
proxy_hide_header X-Call-Info; | |
} | |
[tcpdump] | |
tcpdump -s 1514 -X dst api.logentries.com | |
tcpdump -n not src host 10.0.2.2 | |
HTTP Req/Res | |
------------ | |
IP 13.34010 > 11.80: Flags [S], seq 558033846, win 29200, length 0 | |
IP 11.80 > 13.34010: Flags [S.], seq 389103889, ack 558033847, win 28960, length 0 | |
IP 13.34010 > 11.80: Flags [.], ack 1, win 229, length 0 | |
IP 13.34010 > 11.80: Flags [P.], seq 1:76, ack 1, win 229, length 75 | |
IP 11.80 > 13.34010: Flags [.], ack 76, win 227, length 0 | |
IP 11.80 > 13.34010: Flags [P.], seq 1:18, ack 76, win 227, length 17 | |
IP 13.34010 > 11.80: Flags [.], ack 18, win 229, length 0 | |
IP 11.80 > 13.34010: Flags [FP.], seq 18:595, ack 76, win 227, length 577 | |
IP 13.34010 > 11.80: Flags [.], ack 596, win 238, length 0 | |
IP 13.34010 > 11.80: Flags [F.], seq 76, ack 596, win 238, length 0 | |
IP 11.80 > 13.34010: Flags [.], ack 77, win 227, length 0 | |
[mongodb] | |
mongodump --host 10.16.64.138 --port 27017 --db meerkat --out tmp | |
mongorestore --host db3.fortress.9rum.cc --port 4447 --username meerkat --password kEM4hIsrPZ2wI9RoMDRIck6K --db meerkat tmp/meerkat/ | |
mongoexport --host 10.16.64.138 --port 27017 --db meerkat --collection watch --out watch.json | |
use meerkat | |
db.dropDatabase(); | |
[mount] | |
grep vdb /proc/partitions | |
mkfs -t ext4 -L testvol /dev/vdb | |
mount -L testvol /mnt | |
umount /mnt | |
[openssl] | |
openssl rsa -in server.key -out server.key # 암호제거 | |
openssl x509 -enddate -noout -in file.pem # 만료날자 확인 | |
Linux Directory | |
- /bin : mostly serves as a standard location for key programs like /bin/sh | |
- /usr/bin : is for distribution-managed normal user programs. | |
- /usr/local/bin : is for normal user programs not managed by the distribution package manager, e.g. locally compiled packages. | |
[Pipe] | |
2>&1 : stdout, stderr를 모두 한 파일로 | |
[ansible] | |
ansible apiserver -i production -m shell -a 'ls /' | |
[apt-get install & key install] | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 | |
(Alternative) | |
cat 10gen-gpg-key.asc | sudo apt-key add - | |
---------------- | |
postgresql | |
dbname=> select pg_size_pretty(pg_relation_size('table_name')); | |
---------------- | |
#!/bin/bash | |
#msg=`tail -2 /home/deploy/taxi-tracking/log/error.out` | |
pid=`cat /home/deploy/taxi-tracking/tmp/vertx.pid` | |
msg=`top -n 1 -b -p $pid | grep java` | |
echo $msg | |
curl -X POST --data "to=curt.kim&msg=$msg" http://api.noti.io/send | |
---------------- | |
socat TCP-LISTEN:5432,fork TCP:pg-server-ip:5432 | |
---------------- | |
base64 /dev/urandom | head -c 10000000 > file.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment