1、将用户权限授权:chown 用户名 文件名
2、ls /dev/ | grep sd 查看磁盘
3、gparted 磁盘分区工具
4、sudo mount -r /dev/sda6 /mnt/window1 挂在磁盘
5、sudo mount -t cifs -o username="Administrator" //192.168.1.102/G /home/sky/person/ 将windows共享后的文件挂在linux目录下,进行文件共享
6、ps aux | grep idea.sh 查看idea.sh进程
7、sudo vi /etc/hosts 配置本机ip
8、全局搜索 find . -name '*.java'|xargs grep default.his
9、vi /etc/rc.local 添加开机启动
10、iconv -f gbk -t utf8 mysql.txt > mysql.txt.utf8 linux显示windows正常文本
11、使用正则表达式查询 find . -name "[a]*.txt"
12、mysql 连接 http://jingyan.baidu.com/article/363872ec3263236e4ba16f07.html
13、设置终端中使用vim :set -o vi
14、sudo mount -t ntfs-3g /dev/sda3 /mnt/ -ro force
15、python -m SimpleHTTPServer 80 开启文件服务
16、查看win详细进程路径:wmic process where caption="java.exe" get caption,commandline /value
17、转换文件编码 iconv -f gb2312 -t utf-8 aaa.txt >bbb.txt 忽略其中无效字符 iconv -c -f gb2312 -t utf8 test.txt
18、杀死对应目录的进程 ps -ef |grep java|grep tp8480 |awk '{print $2}' |xargs kill
19、截取文本文件的部分文件
1)截取1.txt中第20行以后的文件然后再截取30行以后的文件 cat 1.txt | tail -n +20 | head -n 30 >> 2.txt
tail -n 1000:显示最后1000行
tail -n +1000:从1000行开始显示,显示1000行以后的
head -n 1000:显示前面1000行
2)wc -l 1.txt 来统计文件行数
3)sed -n '5,10p' filename 这样你就可以只查看文件的第5行到第10行。 这里的sed表示string edit流编辑器,p表示print打印。
4) awk 参考 http://www.cnblogs.com/ggjucheng/archive/2013/01/13/2858470.html
20、统计某个字段的出现的次数:grep -o ZYQueryPatientInfo.*mobile frontgateway-params.log |wc -l
21、cat localhost_access_log.2017-03-29.txt|head -n 1|grep -o ' '|wc -l 统计第一行空格出现的次数
22、awk ' $10 > 30000 ' localhost_access_log.2017-03-29.txt 显示第十个单词大于30000的行
23、alias 显示配置的环境变量 alias vi='vim' 设置简写
24、系统环境变量相关:
1)/etc/profile 设置path、user、mail;hostname、hitsize、umask
2)/etc/bashrc 规划umask功能 可能不同linux在其他路径
3)/etc/profile.d/*.sh
25、个人环境变量相关:
1)~/.bash_history历史按键命令
2)~/.bashrc 个人环境变量配置
26、sort命令
root@debian:/tmp# cat 1.txt
1 a 11
3 c 33
2 b 22
4 a 22
空格分隔,以第二列字符串排序:
root@debian:/tmp# cat 1.txt |sort -t ' ' -k 2
1 a 11
4 a 22
2 b 22
3 c 33
空格分隔,以第三列整数排序:
root@debian:/tmp# cat 1.txt |sort -t ' ' -k 3 -n
1 a 11
2 b 22
4 a 22
3 c 33
27、find . -type f -exec ls -l {} \; //{} 花括号代表前面find查找出来的文件名。
-type 查找某一类型的文件,诸如:
b - 块设备文件。
d - 目录。
c - 字符设备文件。
p - 管道文件。
l - 符号链接文件。
f - 普通文件。
28、抓包 主机ip:192.168.137.129 服务器ip220.181.100.243 or 220.181.100.241 or 220.181.100.242 or 220.181.100.244 写入文件dump.pcap
tcpdump -n -i eth0 src 192.168.137.129 and 220.181.100.243 or 220.181.100.241 or 220.181.100.242 or 220.181.100.244 and tcp -w dump.pcap
tcpdump -i any port 6404 -w 1.pcap 不指定网卡,抓本机回环包制定lo
29、查看抓包数据:wireshark dump.pcap
30、卸载软件 sudo apt-get autoremove --purge 软件名
31、linux 批量杀进程 ps -ef|grep autoacc|grep -v grep | awk '{print "kill -9 " $2}'|sh
32、chsh -s /bin/zsh zsh作为默认bash
33、unzip frontgateway.jar -d tmp 将jar解压到tmp目录
cd tmp 先切换到tmp目录
tar xvf frontgateway.jar . 当前目录压缩成jar
34 virtualBox 死机 http://blog.sina.com.cn/s/blog_4c451e0e0100smar.html
VBoxManage controlvm win7 savestate 睡眠
35、查看对应PID的程序执行路径:ll /proc/25075 | grep redis
36、查看 bash: cannot create temp file for here-document: No space left on device
文件排序 1)ls -lhS 2)du -h * | sort -n查找最大文件
37、zip file 中的文件内容中含有字符串ABCDEF的文件:
for file in *.zip; do if unzip -p $file | strings | grep "ABCDEF" > /dev/null; then echo $file; fi; done
38、查看压缩文件里面的内容(zip文件)
zgrep “INFO” DPServer*
39、java进程执行时 如果进程有 nohub &,则不能按ctrl + z,执行kill -9会导致僵尸进程。参考:https://www.jianshu.com/p/f0baed94128e
使用此命令杀死所有僵尸进程:ps -e -o ppid,stat | grep Z | cut -d” ” -f2 | xargs kill -9