-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunix
34 lines (27 loc) · 1.72 KB
/
unix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# how to strace a process -- also filters strace's output with grep
# PID is 30713 and max string size to output is 33k
$ sudo strace -p 30713 -f -s 33000 2>&1 | grep 'date range'
# how to figure out which hostname/port a running python process is connected to mysql on
$ ps aux | grep py.test
ubuntu 23668 4.8 12.7 611332 491252 pts/2 S+ 22:26 3:40 /usr/bin/python /usr/local/bin/py.test -s -v -m memcache_test
$ strace -p 23668
write(6, "in_id=5279)) AND NOT (brand_id="..., 34867) = 34867
$ ls -l /proc/23668/fd
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 0 -> /dev/pts/2
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 1 -> /dev/pts/2
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 22:44 2 -> /dev/pts/2
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 3 -> /dev/pts/2
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 4 -> socket:[11322298]
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 5 -> socket:[11322301]
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 6 -> socket:[11322305]
lrwx------ 1 ubuntu ubuntu 64 2013-04-08 23:18 7 -> socket:[11322308]
$ netstat -p -e -e | grep 23668
tcp 0 0 localhost:42373 localhost:3308 ESTABLISHED ubuntu 11322305 23668/python
tcp 0 0 ip-10-202-67-19.e:57630 domU-12-31-38-04-:11211 ESTABLISHED ubuntu 11322308 23668/python
tcp 0 0 localhost:47805 localhost:3307 ESTABLISHED ubuntu 11322298 23668/python
tcp 0 0 ip-10-202-67-19.e:51021 domU-12-31-39-14-:mysql ESTABLISHED ubuntu 11322301 23668/python
# sed examples
sudo sed -i 's/^-l 127.0.0.1$/-l 0.0.0.0/' /etc/memcached.conf
# determine which device/mount-point a file or directory exists on
$ df $FILENAME | awk 'NR==1 {next} {print $6; exit}'
$ df -h