-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathshell.txt
More file actions
128 lines (91 loc) · 3.85 KB
/
Copy pathshell.txt
File metadata and controls
128 lines (91 loc) · 3.85 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Q: How do I put an already running process under nohup?
A: Using the Job Control of bash to send the process into the background:
1. Ctrl+Z
to stop (pause) the program and get back to the shell.
2. bg
to run it in the background.
3. disown -h [job-spec]
where [job-spec] is the job number (like %1 for the first running job; find about your number with the jobs command) so that the job isn't killed when the terminal closes.
Q:修改密码
非root:
passwd ,提示输入旧密码,新密码
root:
sudo passwd username,直接输入新密码
Q:查看磁盘情况
df -h
查看一个库文件是32位还是64位的
file libnss_files-2.17.so
od -h -N 10 libnss_files-2.17.so
查看当前文件夹和其中子文件夹占用磁盘空间大小
du -h --max-depth=1 ./
du -hs ./
该命令将深入子目录内部并列出其文件
ls -lR | grep “^-” |wc -l
-R代表递归
wc -l 统计行数
sort 排序
uniq 把相连在一起的内容合并为一行
cut 分割
windows中的which:
C:\Users\Jason>for %x in (powershell.exe) do @echo %~$PATH:x
nl /etc/passwd | sed -n '/root/{s/bash/blueshell/;p}'
查找有 root 的那一行, 执行{}中的内容
s/bash/replacement/;p 表示把bash替换成replacement,p表示显示相关行
如果想只执行一次就退出,用 sed -n '/root/{s/bash/blueshell/;p;q}'
-n 表示只显示相关行,其余没有匹配的不显示,和p配合
sed 's/要被取代的字串/新的字串/g'
ifconfig | sed -n 's/inet/ip/gp'
把inet替换为ip,并只展示相关行
nl /etc/passwd | sed -n '/root/d'
查找有root的行,删除(d)
nl /etc/passwd | sed -n '/root/a hello'
在有root行后面添加一行hello, (append)
i代表在前一行添加内容,c表示替换
'2,5i hello': 在2-5行每行前面插入一行hello
'2,5c hello': 把2-5行替换为一行hello
sed -i 's/\.$/\!/g' regular_express.txt
-i代表直接输出到文件,而不是标准输出
kill -STOP 相当于向进程发送了SIGSTOP信号,
这时使用ps 查看进程时发现进程状态为"T"状态。
kill -CONT 进程编号
相当于向进程发送了SIGCONT信号,使暂停的进程恢复到运行状态。
vim多行删除
:1,10d
vim多行替换
:1,$s/from/to/g
从第一行到最后一行替换所有from为to;
g表示global,不只是每一行第一次出现的from;
s表示substitute;
$表示最后一行,如果想表示当前行,用"."表示。这是可选项;
查看僵尸进程
ps -A -ostat,ppid,pid,cmd | grep -e '^[Zz]'
使用tcpdump (客户端为50开头的)
tcpdump -n -i eth0 host 50.62.213.12 and 61.147.82.76
tcpdump -n -i venet0 host 50.117.7.122 and 61.147.82.76
tcpdump -nvvv -i any -c 1 -XX 'port 80 and host 61.147.82.76'
curl仅仅打印返回头
curl -s -D - http://dd.99kk.com -o /dev/null
curl post文件
curl -F "userid=1" -F "image=@/root/test.txt" www.samaterials.com
curl 打印请求详细内容
curl www.samaterials.com -d "image=@/home/jason/test.txt" --trace-ascii /dev/stdout
curl multipart上传
curl -v -F key1=value1 -F upload=@/home/jason/test.txt www.samaterials.com
strace查看系统底层操作:
strace -ttT executable -o strace.log
-tt with usecs
-T print time spent in each syscall
-o 表示输出到文件而不是stderr
修改时间:
tzselect 修改时区
date -s 15:40:00 修改时间
date -s 06/18/14 2014年6月18日
wget的提示文件名太长无法创建问题:
-O filename
测试磁盘写入速度
dd if=/dev/zero of="/tmp/test" bs=100MB count=2
### Run script in string
use `script`, for instance, echo "`pwd`/filename"
### 替换多个文件中的文字
grep -rl matchstring somedir/ | xargs sed -i '' 's/string1/string2/g'
-i 后面的 '' 是为了在mac下的可用,表示备份原文件后缀,例如 '.bak' 会在修改前保存被修改的文件到' original.bak'