Linux运维常用维护命令记录

2020-01-30 16:44:42于海丽

(1)让程序在用户退出后仍然在运行

1 ctrl+z暂停程序

2 bg让程序在后台运行

3 退出用户登录即可

(2)用Find命令查找指定的文件,并且执行Rm操作

[root@tiejiang ~]# find ./ -name "*****" -exec rm -f {} ;

(3)递归搜索含有某个关键字的文件目录。

[root@tiejiang ~]# grep -iHR "****" ./*

 -i 对要搜索的字符忽略大小写

 -H 同时打印包括搜索字符串的文件名

 -R 递归搜索,当指定的搜索路径是一个目录时,加了-R的搜索会执行递归搜索

(4)Linux 硬件时间查看Hkclock --Show

硬件时间修改:

[root@tiejiang ~]# hwclock --set --date='10/11/2016 17:07:00'

系统时间与硬件时间同步:

[root@tiejiang ~]# hwclock --hctosys

(5)Scp拷贝文件,Key的方式

[root@tiejiang ~]# /usr/bin/ssh -x -oForwardAgent no -oPermitLocalCommand no -oClearAllForwardings yes -i/root/.ssh/iptvcp 10.0.51.198 scp -r -d -t /letv/...

(6)查看组播情况

[root@tiejiang ~]# netstat -ng

(7)Smarttools可以获取硬盘重要参数

(8)Grep 精确查找

[root@tiejiang ~]# grep -w 'north' install.log

(9)Expr模式匹配

expr也有模式匹配功能。可以使用expr通过指定冒号选项计算字符串中字符数。.*意即任何字符重复0次或多次。expr $a : '[a-zA-Z]*'

(10)Vim 行左对齐

:1,$ left

(11)倒序字符串,倒序下文件中字符串内容

[root@tiejiang ~]# rev +文件名

(12)Sed将"/File/File1"替换为"/File/File1"

[root@tiejiang ~]# sed -e 's/////g'

[root@tiejiang ~]# sed -E -e "s:/:/:g"(写入shell文件中)

(13)Modprobe -V -R 模块名

移出模块

(14)Modprobe -V 模块名

加载模块

(15)Lsmod|Grep 模块名

查看相关依赖关系的模块

(16)Modinfo 查看模块的信息,及相关的配置参数

modinfo 模块名

(17)Ssh登录较慢

去除dns反解析

[root@tiejiang ~]# UseDNS no

(18)Ssh 连接开机详细输出

[root@tiejiang ~]# ssh -v

(19)Pkill命令使用方法

pkill 加命令名称 可以杀死命令

(20)Ntpdate 同步Server地址

128.138.140.44

(21)Date 命令设置时间

[root@tiejiang ~]# date -s 20161115

[root@tiejiang ~]# date -s 08:45:00

(22)Linux Ntpd配置

ntpstat 查看自身服务器与上一级服务器之间的连接状态

如果出现:synchronised to local net at stratum

则需要检查#server 127.127.1.0 # local clock

[root@tiejiang ~]# fudge 127.127.1.0 stratum 10 是否已经备注

(23)可用内存数

[root@tiejiang ~]# total-free-cache-buffer

(24)Ps -Auxww 按相关使用量排序

由于ps的输出是一PID号的顺序显示的,若要实现按照某一项使用量排序,需要把某项放入最前面。