ping 192.168.1.1 -t //如果加上-t 的话表示一直ping

linux tar 命令 解压文件到指定目录
tar -zxvf ./text.tar.gz -C /home/app/test/

解压压缩包中的某一文件到指定目录
压缩包 指定目录 压缩包中的特定文件
tar -zxvf test.tar.gz -C test_dir test_tar2.c
/必须要加-C选项/

解包:tar xvf FileName.tar
打包:tar cvf FileName.tar DirName

(注:tar是打包,不是压缩!)

.gz
解压1:gunzip FileName.gz
解压2:gzip -d FileName.gz
压缩:gzip FileName

.tar.gz 和 .tgz
解压:tar zxvf FileName.tar.gz
压缩:tar zcvf FileName.tar.gz DirName

//在windos操作系统下编辑脚本文件放到linux下无法执行,用该命令转换一下格式
//-bash: ./test_dos2unix.sh: /bin/bash^M: bad interpreter: 没有那个文件或目录
dos2unix filename

scp指令
//用该命令提起源主机上的文件,源机的ip=10.43.40.37,
//路径包含到要取的文件命令/wangquan/shell_learning/sbcd2
//sbcd2 文件名
scp 10.43.40.37:/wangquan/shell_learning/sbcd2 .

scp root@[ipv6]:/wangquan/shell_learning/sbcd2 .

scp [ipv6]:/wangquan/shell_learning/*.c .

//查看磁盘空间并提取关键字所在行显示对应行末的倒数第几个数值
df |grep /$ |awk ‘{print $(NF-2)}’
df |grep sbc |awk ‘{print $(NF-2)}’

杀死进程命令
kill -9 xxxxx //xxx表示进程号

top -i
top 查看各CPU的信息,按 1 显示全部

perf用法
perf top -C // 查看指定CPU核号的perf性能热点
perf top -g -t // 查看指定线程的cpu热点,-g输出调用栈

perf record xxx //记录当前cpu占用信息
perf record -g -t tid //记录线程tid的cpu占用信息,-g表示可以进行堆栈回溯
记录完成后在当前路径下生成perf.data文件
用perf report命令可以直接打开perf.data或者通过 -i filename打开其它文件
perf report -i perf.data.old

perf stat -e L1-dcache-load-misses ./a.out //追踪a.out执行过程的cache miss
perf stat -e L1-dcache-load-misses -p //追踪 pid 进程的cache miss
perf stat -e L1-dcache-load-misses -t <task_id> //追踪 task_id 线程的cache miss

objdump -T bgw | grep do_patch //查看可执行文件是否包含do_patch函数

想要查找一个宏定义在哪个文件中,可以使用下面的方法:
[sproat@ test]# find /usr/include/ -name *.h | xargs grep ‘ORIG_EAX’

修改linux系统时间:
通过hwclock –systohc将系统时间同步到硬件时间
所有可以通过date -s “YYYY-MM-DD hh:mm:ss” &&hwclock –systohc来修改系统时间
注意:对于虚拟机可能重启后,系统时间仍然后变成主机时间
例:
[root@localhost ~]# date -R
Wed, 06 Sep 2017 01:47:29 +0800
[root@localhost ~]# date -s “20180123 09:56:30” &&hwclock –systohc
Tue Jan 23 09:56:30 CST 2018
[root@localhost ~]# date
Tue Jan 23 09:56:38 CST 2018

查看进程pid,进程组,父进程pid,进程名
各属性用“,”隔开
ps ax -o pid,pgid,ppid,comm | grep fork

查看运行的进程处于哪个核上
[root@localhost tmp]# ps -eLo pid,ppid,lwp,psr,fname,policy,command | grep bgw
CPU_X
4767 1 4767 1 bgw_cpu1 TS ./bgw_cpu1_SD1 1 4
4767 1 4832 1 tVxworkE FF ./bgw_cpu1_SD1 1 4
4767 1 4839 1 MonitorS FF ./bgw_cpu1_SD1 1 4
4767 1 5129 1 ealIntrT FF ./bgw_cpu1_SD1 1 4
4767 1 5148 1 ProtFifo FF ./bgw_cpu1_SD1 1 4
4767 1 5149 1 ProtFifo FF ./bgw_cpu1_SD1 1 4

查看指定CPU核上各运行进程(线程)的信息
ps -eLo pid,ppid,lwp,psr,fname,policy,command,pri | awk '{if($41) print$3,$5,$6,$7,$8}’
if($4
1) 1 表示1核

查看linux目录下的占磁盘大小:du -sh *

top -H -p xxxx //看xxx进程下的线程CPU占用率

perf top -C1 // 看具体函数的CPU占用率

绑定进程到CPU核上:taskset -cp cpu_id pid
查看进程位于哪个cpu核上:taskset -p pid

例如:
[root@localhost some_func]# taskset -cp 3 3978
pid 3978’s current affinity list: 0
pid 3978’s new affinity list: 3
[root@localhost some_func]# taskset -p 3978
pid 3978’s current affinity mask: 8

查看linux驱动模块相关命令:
[root@localhost ~]# lsmod
Module Size Used by
igb_uio 5169 6

ipv6 322646 55 bonding
register_ipmc_reboot 3101 0

e1000e 264035 0

[root@localhost ~]# modinfo e1000e
filename: /lib/modules/2.6.32-220.el6.x86_64/extra/e1000e/e1000e.ko
version: 3.3.1-NAPI
license: GPL
description: Intel® PRO/1000 Network Driver
author: Intel Corporation, linux.nics@intel.com
srcversion: 5DA640BEF28EA793EB25638
alias: pci:v00008086d000015B9svsdbcsci*
alias: pci:v00008086d000015B8svsdbcsci*

//e1000e.ko,ko文件是由驱动代码编译成的可被内核加载的模块,可以由内核加载启动/也可通过insmod命令进行加载

网卡信息查询(包括驱动信息)
[root@localhost ~]# ethtool -i eth22
driver: e1000e
version: 3.3.1-NAPI
firmware-version: 5.10-7
bus-info: 0000:03:00.1

网卡混杂模式:
ifconfig eth0 看是否有“PROMISC”标志
ifconfig eth0 promisc #设置混杂模式
ifconfig eth0 -promisc #取消混杂模式

进程内存使用情况查看命令:pamp

[root@localhost mmap_learn]# pmap -x 19363
19363:   ./mmap_func
Address           Kbytes     RSS   Dirty Mode   Mapping
0000000000400000       4       4       4 r-x--  mmap_func
0000000000600000       4       4       4 rw---  mmap_func
00000031ce400000     128     104       0 r-x--  ld-2.12.so
00000031ce61f000       4       4       4 r----  ld-2.12.so
00000031ce620000       4       4       4 rw---  ld-2.12.so
00000031ce621000       4       4       4 rw---    [ anon ]
00000031ce800000    1576     152       0 r-x--  libc-2.12.so
00000031ce98a000    2048       0       0 -----  libc-2.12.so
00000031ceb8a000      16       8       8 r----  libc-2.12.so
00000031ceb8e000       4       4       4 rw---  libc-2.12.so
00000031ceb8f000      20      12      12 rw---    [ anon ]
00007f6e90bba000      12      12      12 rw---    [ anon ]
00007f6e90bdb000       4       4       4 rw---    [ anon ]
00007fff230e6000      84      28      28 rw---    [ stack ]
00007fff23180000       4       4       0 r-x--    [ anon ]
ffffffffff600000       4       0       0 r-x--    [ anon ]
----------------  ------  ------  ------
total kB            3920     348      88

以上列表项的含义如下:
Address: 内存分配地址
Kbytes: 实际分配的内存大小
RSS: 程序实际占用的内存大小
Mapping: 分配该内存的模块的名称```

进程运行时间查看命令time

[root@localhost ~]# time ls
anaconda-ks.cfg  install.log  install.log.syslog  satools  text
real    0m0.009s
user    0m0.002s
sys     0m0.007s**加粗样式**

输出的信息分别显示了该命令所花费的real时间、user时间和sys时间。
real:是指挂钟时间,也就是命令开始执行到结束的时间。这个短时间包括其他进程所占用的时间片,和进程被阻塞时所花费的时间。
user:是指进程花费在用户模式中的CPU时间,这是唯一真正用于执行进程所花费的时间,其他进程和花费阻塞状态中的时间没有计算在内。
sys:是指花费在内核模式中的CPU时间,代表在内核中执系统调用所花费的时间,这也是真正由进程使用的CPU时间。

替换文件当行的内容:sed -i ‘s/old/new/g’ test

[root@Node_A wq]# cat test
yyyyy
xxxxx
zzzzz
[root@Node_A wq]# sed -i 's/xxxxx/qqqqq/g' test
[root@Node_A wq]# cat test
yyyyy
qqqqq
zzzzz

查看连接你服务器 top10 用户端的 IP 地址:
netstat -nat | awk ‘{print $5}’ | awk -F ‘:’ ‘{print $1}’ | sort | uniq -c | sort -rn | head -n 10

[root@Node_A wq]# netstat -nat | awk '{print $5}' | awk -F ':' '{print $1}' | sort | uniq -c | sort -rn | head -n 1053 0.0.0.046 127.0.0.144 127.0.0.2342 127.0.0.2240 127.0.0.2138 127.0.0.2036 127.0.0.1934 127.0.0.1832 127.0.0.1730 127.0.0.16

查看一下你最常用的10个命令:
cat .bash_history | sort | uniq -c | sort -rn | head -n 10 (or cat .zhistory | sort | uniq -c | sort -rn | head -n 10)

[root@localhost ~]# cat .bash_history | sort | uniq -c | sort -rn | head109 ll52 ls49 chmod 777 zxss10b100-bgmu.*48 rm -rf zxss10b100-bgmu.*45 ifconfig22 scp 10.43.85.162:/sbc/code/git_sbc/service/splat_pt/img/etcb/REL/* ./21 cd ..19  scp 10.43.85.162:/sbc/code/git_sbc/service/splat_pt/img/etcb/REL/* ./16 ssh 80.80.80.15413 ssh 80.80.80.151

每一个用户的根路径下都有一个隐藏文件.bash_history

在linux下配置/删除 ip 地址
v4 : ifconfig eth0:1 192.168.0.1 netmask 255.255.255.0
v4 : ifconfig eth0:1 192.168.0.1/24
v4 : ip addr del 192.168.0.1 dev eth0

v6 : ifconfig eth7 inet6 add 5000::159/96
v6 : ifconfig eth0 inet6 del 5000::159/96
在linux下删除 ip 地址

重启网卡生效:
1、添加配置到文件中 /etc/rc.local( 有时不稳定 )
2、直接修改或新增:/etc/sysconfig/network-scripts/ifcfg-ethX
修改配置后重启网络服务service network restart

v4 添加路由/删除信息:
route // 显示路由信息。
route add -host 192.168.1.110 dev eth0 // 给网卡eth0的路由表中加入新地址192.168.1.110。
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1 // 给子网192.168.1.0添加路由和网关,新增加的路由和网关地址为192.168.1.1。
route add default gw 192.168.0.1 // 给路由表中添加默认网关地址192.168.0.1
route del -host 192.168.1.110 dev eth0 // 删除网卡eth0路由表中的地址192.168.1.110。
route del -net 192.168.1.0 netmask 255.255.255.0 // 在路由表中删除子网192.168.1.0的路由信息。
route change 192.168.1.0 mask 255.255.255.0 192.168.10.100 // 将子网 192.168.1.0 的下一跃点地址设置为 192.168.10.100。
需要注意的是,网段路由目的地址和掩码必须是有效的网段,否则配置失败:
route add -net 100.200.200.1 netmask 255.255.255.0 dev eth0
错误信息:route: netmask doesn’t match route address
改成:route add -net 100.200.200.0 netmask 255.255.255.0 dev eth0

v6 添加路由/删除信息:
添加默认路由
ip -6 route add / via
ip -6 route add default via 2001:0db8:0:f101::1
route -A inet6 add / gw
route -A inet6 add default gw 2001:0db8:0:f101::1
查看路由
ip -6 route show
route -A ‘inet6’
route -6
windows查看路由表
route print
查看邻居缓存
ip -6 neighbor show
windows查看邻居缓存
netsh interface ipv6 show neighbors