strace 查看程序 系统调用
strace -d -T -r -c -p 62511
抓包
tcpdump -i bond0 'src host 192.168.2.130' -s 0 -w SuccessC2Server. pcap
sort
sort命令是帮我们依据不同的数据类型进行排序,其语法及常用参数格式:
sort [-bcfMnrtk][源文件][-o 输出文件]
补充说明:sort可针对文本文件的内容,以行为单位来排序。
参 数:
-b 忽略每行前面开始出的空格字符。
-c 检查文件是否已经按照顺序排序。
-f 排序时,忽略大小写字母。
-M 将前面3 个字母依照月份的缩写进行排序。
-n 依照数值的大小排序。
-o<输出文件> 将排序后的结果存入指定的文件。
-r 以相反的顺序来排序。
-t<分隔字符> 指定排序时所用的栏位分隔字符。
-k 选择以哪个区间进行排序。
eth0 找不到
[root@server1 ~]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0 : 设备 eth0 似乎不存在, 初始化操作将被延迟。 [失败]
清空70 -persistent-net.rules,重启系统,让系统自己重新生成这个文件
[root@server1 ~]
[root@server1 ~]
[root@server1 ~]
关闭环回接口: [确定]
弹出环回接口: [确定]
弹出界面 eth0 : 活跃连接状态:激活的
linux 资源查看
uptime dmesg | tail vmstat 1 mpstat -P ALL 1 pidstat 1 iostat -xz 1 free -m sar -n DEV 1 sar -n TCP,ETCP 1 top
删除大量文件
time rsync -a –delete test/ retransmission/ 分别删除 创建7天前、修改7天前、访问7天前的文件。前2个用的较多。
find . -type f -ctime + 7 -delete
find . -type f -mtime + 7 -delete
find . -type f -atime + 7 -delete
如何查找可执行文件
查看端口
netstat -apn |grep LISTEN |grep “:”
查找文件
查找大文件
find . -type f -size +800M 查找大目录
echo "------------------------------------------------------------"
#ls -h -ltr | grep -f .. /a. txt | tail - 35
#find . -type f -mmin - 600 -exec ls -h -ltr {} \ ; | grep -f .. /a. txt
#find . -type f -mmin - 600 -exec ls {} \ ; | grep -f .. /a. txt | wc -ll
#ls -h -l | grep -f .. /a. txt | wc -ll
#find . -type f -newer .. /mj. start
find . -type f -newer .. /mj. start | xargs ls -hltr | grep -f .. /a. txt
find . -type f -newer .. /mj. start | xargs ls -ltr | grep -f .. /a. txt | wc -ll
echo ""
sleep 5
#ls -l | grep "" | wc -ll
查看 centos 版本
时间设置
hwclock –set –date=”11/14/2016 09:13:10” 设置硬件时间 hwclock –hctosys 硬件时间 同步到 系统时间
时间戳日期转换
date +%s date -d @1490992200
gdb
Format letters are o(octal) , x(hex) , d(decimal) , u(unsigned decimal) ,
t(binary) , f(float) , a(address) , i(instruction) , c(char) and s(string) .
Size letters are b(byte) , h(halfword) , w(word) , g(giant, 8 bytes)
举例 x/3uh buf
表示从内存地址buf读取内容, h表示以双字节为一个单位, 3表示三个单位, u表示按十进制显示
目录跳转
文件属性 lsattr/chattr
chattr命令的用法:chattr [ -RVf ] [ -v version ] [ mode ] files… 最关键的是在[mode]部分,[mode]部分是由+-=和[ASacDdIijsTtu]这些字符组合的,这部分是用来控制文件的属性。
+ :在原有参数设定基础上,追加参数。
- :在原有参数设定基础上,移除参数。
A:文件或目录的 atime (access time)不可被修改(modified), 可以有效预防例如手提电脑磁盘I/O错误的发生。
S:硬盘I/O同步选项,功能类似sync。
a:即append,设定该参数后,只能向文件中添加数据,而不能删除,多用于服务器日志文件安全,只有root才能设定这个属性。
c:即compresse,设定文件是否经压缩后再存储。读取时需要经过自动解压操作。
d:即no dump,设定文件不能成为dump程序的备份目标。
i:设定文件不能被删除、改名、设定链接关系,同时不能写入或新增内容。i参数对于文件 系统的安全设置有很大帮助。
j:即journal,设定此参数使得当通过mount参数:data=ordered 或者 data=writeback 挂 载的文件系统,文件在写入时会先被记录(在journal中)。如果filesystem被设定参数为 data=journal,则该参数自动失效。
s:保密性地删除文件或目录,即硬盘空间被全部收回。
u:与s相反,当设定为u时,数据内容其实还存在磁盘中,可以用于undeletion。
各参数选项中常用到的是a和i。a选项强制只可添加不可删除,多用于日志系统的安全设定。而i是更为严格的安全设定,只有superuser (root) 或具有CAP_LINUX_ IMMUTABLE处理能力(标识)的进程能够施加该选项。
例如、用chattr命令防止系统中某个关键文件被修改:
# chattr +i /etc/resolv.conf
编译缓存 ccache
[root@localhost ccache]
[root@localhost ccache]
[root@localhost ccache]
[root@localhost ccache]
[root@localhost ccache]
[root@localhost sms]
export PATH =/usr/lib 64/ccache: $PATH
[root@localhost sms]
Linux关闭防火墙命令
chkconfig iptables on
chkconfig iptables off
service iptables start
service iptables stop
rpm -qa 失效
[root@BGP-SM-g-3 gI sbin]# rpm -qa sms
rpmdb: Lock table is out of available locks
error : cannot open Packages index using db3 - Cannot allocate memory (12 )
error : cannot open Packages database in /var/lib /rpm
#解决
[root@BGP-SM-g-3 gI sbin]# cd /var/lib/
[root@BGP-SM-g-3 gI lib ]# tar -cvf rpm.tar rpm
[root@BGP-SM-g-3 gI lib ]# rm -rf rpm/__db.00*
__db.000 __db.001 __db.002 __db.003
[root@BGP-SM-g-3 gI lib ]# rm -rf rpm/__db.00*
[root@BGP-SM-g-3 gI lib ]# rpm --rebuilddb
[root@BGP-SM-g-3 gI lib ]# rpm -qa sms
sms-2.2 .136 -2
linux时间同步
ntpdate time .nist.gov
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
service ntpd restart
mysql
/etc/rc.d /init.d /mysqld start
启动 http://www.myhack 58.com /Article/48 /66 /2014 /44759. htm
使用 service 启动:service mysqld start
使用 mysqld 脚本启动:/etc/inint.d /mysqld start
使用 safe_mysqld 启动:safe_mysqld&
停止
使用 service 启动:service mysqld stop
使用 mysqld 脚本启动:/etc/inint.d /mysqld stop
mysqladmin shutdown
重启
使用 service 启动:service mysqld restart
使用 mysqld 脚本启动:/etc/inint.d /mysqld restart
[root@localhost ~]
mysql> use mysql
mysql> update user set password=passworD("wmjwmj" ) where user='root' ;
mysql> flush privileges;
mysql> exit ;
[root@localhost ~]
ERROR: mysql error old pre-4.1 authentication protocol not supported
vim /etc/my.cnf
#old _passwords=1
[root@localhost ~]# Mysql -u user=root
mysql> SET PASSWORD FOR 'root' @'localhost' = PASSWORD('wmjwmj' );
vimrc
syntax on
syntax enable
set number
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set cindent
filetype plugin on
linux内核 时钟中断频率
cat /proc/interrupts|grep timer && sleep 1 && cat /proc/interrupts|grep timer
cat /boot/config-`uname -r` | grep ' ^CONFIG_HZ='
vim hz.c
main ()
{
clock_t ct0 , ct1;
struct tms tms0 , tms1;
int i;
if ((ct0 = times (&tms0 )) == -1 )
perror ("times" );
printf ("_SC_CLK_TCK = %ld \n" , sysconf (_SC_CLK_TCK));
printf ("HZ= %ld \n" , HZ);
for (i = 0 ; i < 10000000 ; i++)
;
if ((ct1 = times (&tms1)) == -1 )
perror ("times" );
printf ("ct0 = %ld , times: %ld %ld %ld %ld \n" , ct0 , tms0 .tms_utime,
tms0 .tms_cutime, tms0 .tms_stime, tms0 .tms_cstime);
printf ("ct1 = %ld , times: %ld %ld %ld %ld \n" , ct1, tms1.tms_utime,
tms1.tms_cutime, tms1.tms_stime, tms1.tms_cstime);
printf ("ct1 - ct0 = %ld \n" , ct1 - ct0 );
}