1、 diff(文本比较)
[root@guosaike ~]# cp /etc/passwd{,.ori}备份
[root@guosaike ~]# diff /etc/passwd{,.ori}
24d23
< lll
[root@guosaike ~]# diff /etc/passwd /etc/passwd.ori
24d23
< lll
2、 Vimdiff
3、RPM
Rpm包管理器
Rpm -I 安装 rpm install
Rpm -v 显示安装过程
Rpm -h 用#显示安装进度条
Rpm -u 升级软件包
Rpm -q 查询
Rpm -a 所有
Rpm -e 卸载
Rpm -nodeps 忽略依赖
Rpm -l 显示软件包中的所有文件列表
Rpm -f 查询文件或命令属于哪个软件包
rpm -qf /sbin/ifconfig
net-tools-2.0-0.25.20131004git.el7.x86_64
4、 yum 安装rpm包自动解决依赖工具
yum install 安装软件包
yum groupinstall 安装组包
yum grouplist 获取组包名称列表
yum grouplist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Environment Groups:
Minimal Install
MATE Desktop
Basic Web Server
yum groupinstall Basic Web Server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00
epel | 4.7 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:02
(2/2): epel/x86_64/primary_db | 6.8 MB 00:07
Warning: group Basic does not exist.
Warning: group Web does not exist.
Warning: group Server does not exist.
Maybe run: yum groups mark install (see man yum)
Error: No packages in any requested group available to install or update
yum list 获取软件包名
yum list install 查已安装软件
yum provides 根据命令或者配置等的路径查属于哪个包
yum provides /etc/my.conf
yum provides /sbin/ifconfig
yum remove 移除软件包名(禁止使用)
yum search 模糊查找软件包名
yum repolist all 列出所以的yum,包括禁用的yum源也列出
5、 linux系统如何安装软件?
(1) rpm安装 简单,解决依赖困难繁琐
(2) yum安装 简单,自动解决依赖,不能选择版本
(3) 编译安装(源码编译)
慢 复杂 可以自定义安装(版本、软件路径)
(4) 将源码制作成rpm,然后放到yum仓库,实现yum自动安装
6、 centos6跟centos7的区别
systemctl restart crond 重启(7)
service crond restart 重启(6)
systemctl reload crond 平滑加载服务(已经在服务的不关闭,没有服务的不再服务)
systemctl status crond查看服务状态(7)
/etc/init.d/crond/status查看服务状态(6)
开机自启动
Systemctl disable/enable crond(7)
Systemctl is-active crond
Systemctl is-enable crond
Chkconfig crond off||on(6)
Chkconfig –-list off|on
Systemctl list-unix-files查看服务开机启动列表
查看服务开机启动列表
Chkconfig - - list
Runlevel
Chkconfig -- list|grep “3:on”
/etc/systemd/system/crond 开机自启动位置(7)
/etc/init.d/rc.d/crond 开机自启动位置(6)
Firewalld(ipatables)默认防火墙(7)
iptables默认防火墙(6)
hostnamectl set-hostname oldboy永久修改主机名(7)
hostname oldboy(6)临时修改
runlevel(查看运行级别) init(运行运行级别)运行级别(6)
MySQL默认数据库(6)
MaiaDB默认数据库(7)
/etc/rc.local放置启动的命令(须授予执行权限)
/Etc/rc.local 放置启动的命令
Netstat -rn 查看路由
7、 chattr 设置文件属性
8、 lsattr 查看文件属性
[root@guosaike ~]# chattr +i /etc/passwd
[root@guosaike ~]# lsattr /etc/passwd
----i----------- /etc/passwd
[root@guosaike ~]# lsattr /etc/hosts
------------ /etc/hosts
给重要文件上锁 chattr +I /etc/passwd
给重要文件去锁 Chattr -I/etc/passwd
Cp /bin/chattr /opt(把重要文件移走)
Cp /bin/cat /bin/chattr(做伪装,把cat命令换成chattr)
Touch guosaike.txt
Chattr +a guosaike.txt
Rm -rf guosaike.txt(删除不了)
Echo > guosaike.txt(不可以删除)
Vim guosaike.txt(不可以用vim)
Echo ddd >> guosaike.txt(可以追加)
Chattr -a guosaike.txt(可以删除了)