好久没更新了,把有道云笔记的整理下粘贴下
linux 一些常用的命令
=======用户=======
adduser test 添加用户
passwd test 更改密码
history 查看历史操作
gpasswd -a test dev 添加test用户到用户组 dev
vim /etc/sudoer 添加sudo 权限
xxx ALL=(ALL) NOPASSWD: ALL
ttest ALL=(ALL) ALL
kill -9 21367
unzip -o xxx.zip 覆盖解压
==========防火墙=========
iptables -L 查看防火墙
service iptables -stop 关掉防火墙
service iptables -start 开启防火墙
service iptables status 查看防火墙状态
service iptables start 开启防火墙
service iptables stop 关闭防火墙
service iptables restart 重启防火墙
①文件/etc/sysconfig/iptables
②添加:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
★数字8080代表开放8080端口,也可以改成其他的端口
★
③重启防火墙
指定对应端口号到ip地址
# iptables -I INPUT -p tcp --dport 80 -j DROP
# iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPT
# iptables -I INPUT -s 211.123.16.123/24 -p tcp --dport 80 -j ACCEPT
# iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 80 -j ACCEPT
# iptables -I INPUT -s 211.123.16.123/24 -p tcp --dport 80 -j ACCEPT
=======端口查看==========
netstat -lnp
netstat -anp|grep 9010
kill -9 21367
tcpdump 抓包命令
=============后台执行=======
nohup java -jar xxx.jar &
nohup command > myout.file 2>&1 &
nohup ./runorderLog.sh 20150101 20160101 >/data/www/startsh/log/runorderLog.20150101.20160101.log 2>&1 &
==========================cpu跑高分析=====================================
top 查看可以进程 pid
2 找出消耗资源最高现成
top -H -p 进程id?
或者top -H
strace -p 线程id
++++++++++++++如果是web应用,可以继续打印线程的堆栈信息+++++++++
将需要的线程ID转换为16进制格式:
printf "%x\n" 29679
73ef
最后打印线程的堆栈信息:
jstack 29679|grep 73ef -A 30
将需要的线程ID转换为16进制格式:
printf "%x\n" 29679
73ef
最后打印线程的堆栈信息:
jstack 29679|grep 73ef -A 30
printf "%x\n" 线程id
打印堆栈信息 jstack 线程id | grep 73ef -A 30
===============推送命令================
scp jetty.tar
[email protected]:/data/www/jetty.tar 本地推送
==========linux 环境变量不生效==============
source /etc/profile
==========linux 免密码登录============================
A登录B
A
ssh
-
keygen
-
t rsa
-
P
''
下载 id_rsa.pub
B中没有ssh
cd ~
mkdir .ssh
cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
链接 报错
reverse mapping checking getaddrinfo for bogon [192.168.199.98] failed - POSSIBLE BREAK-IN ATTEMPT!
修改A服务器
vim /etc/ssh/ssh_config
GSSAPIAuthentication no
600
chmod 600 /root/.ssh/ 必须设置成600 问题都是600原因
chmod 600 /root/.ssh/authorized_keys
chmod 600 /root/.ssh
必须设置600 处于安全考虑
==================================================
==================awk================================
grep 'error:清华用户id' qhmail.0946.log | awk '{if($3 != "null"){print "\""$3"\","}}' > end_qh_erro_201606030955.log
====================nohup=================================
nohup /usr/local/jdk1.8.0_65/bin/java -jar gys-dbpatch-1.0.23.3-RELEASE_QHMail.jar >qhmail.0946.log &
======================路由追踪命令============================
linux traceroute -n
www.baidu.com
windows tracert -d [ -h 15]
www.baidu.com
======================cdn 显示=============================
nslookup
==========================================================
shell 中可以使用sleep 单位是毫秒
===========================================================
======================硬盘挂载===============================
插上usb的盘: fdisk -l 查看硬盘文件
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0007c832
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 1953523711 976248832 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-swap: 3892 MB, 3892314112 bytes, 7602176 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-home: 942.0 GB, 942028095488 bytes, 1839898624 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk
/dev/sdb: 4000.8 GB, 4000787029504 bytes, 7814037167 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
格式化
parted /dev/sdb
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Seagate Expansion Desk (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 4001GB 4001GB primary
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext3
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) quit
Information: You may need to update /etc/fstab
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Seagate Expansion Desk (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 4001GB 4001GB primary
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext3
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) quit
Information: You may need to update /etc/fstab
格式化
mkfs -t ext3 /dev/sdc
创建 挂载目录
mkdir -p /mnt/userhd1
挂载 mount /dev/sdb /mnt/userhd1
======================路由追踪命令============================
linux traceroute -n
www.baidu.com
windows tracert -d [ -h 15]
www.baidu.com
======================cdn 显示=============================
nslookup
==========================================================
shell 中可以使用sleep 单位是毫秒
===========================================================
======================硬盘挂载===============================
插上usb的盘: fdisk -l 查看硬盘文件
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0007c832
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 1953523711 976248832 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-swap: 3892 MB, 3892314112 bytes, 7602176 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-home: 942.0 GB, 942028095488 bytes, 1839898624 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk
/dev/sdb: 4000.8 GB, 4000787029504 bytes, 7814037167 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
格式化
parted /dev/sdb
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Seagate Expansion Desk (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 4001GB 4001GB primary
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext3
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) quit
Information: You may need to update /etc/fstab
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Seagate Expansion Desk (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 4001GB 4001GB primary
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext3
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) quit
Information: You may need to update /etc/fstab
格式化
mkfs -t ext3 /dev/sdc
创建 挂载目录
mkdir -p /mnt/userhd1
挂载 mount /dev/sdb /mnt/userhd1
============Linux 进程后台运行=非nohup====================
eg:执行命令
输入远程密码
ctrl+c
jobs 查看运行指令
后台运行
bg
退出
exit
再次进入 ps -ef|grep scp
======================路由追踪命令============================
linux traceroute -n
www.baidu.com
windows tracert -d [ -h 15]
www.baidu.com
======================cdn 显示=============================
nslookup
==========================================================
shell 中可以使用sleep 单位是毫秒
===========================================================
======================硬盘挂载===============================
插上usb的盘: fdisk -l 查看硬盘文件
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x0007c832
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 1953523711 976248832 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-swap: 3892 MB, 3892314112 bytes, 7602176 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-home: 942.0 GB, 942028095488 bytes, 1839898624 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk
/dev/sdb: 4000.8 GB, 4000787029504 bytes, 7814037167 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
格式化
parted /dev/sdb
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Seagate Expansion Desk (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 4001GB 4001GB primary
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext3
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) quit
Information: You may need to update /etc/fstab
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Seagate Expansion Desk (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 4096B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 24.6kB 4001GB 4001GB primary
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No? y
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) mkpart
Partition name? []? primary
File system type? [ext2]? ext3
Start? 0
End? -1
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? i
Error: Partition(s) 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 on /dev/sdc have been
written, but we have been unable to inform the kernel of the change, probably
because it/they are in use. As a result, the old partition(s) will remain in
use. You should reboot now before making further changes.
Ignore/Cancel? i
(parted) quit
Information: You may need to update /etc/fstab
格式化
mkfs -t ext3 /dev/sdc
创建 挂载目录
mkdir -p /mnt/userhd1
挂载 mount /dev/sdb /mnt/userhd1