-
grep文件内容过滤:显示文件有效信息(去除注释,去除空行)
- 注释信息以#开头
- [root@lifei lv]# grep ^# /etc/default/useradd
# useradd defaults file - 提取非#开头的行
- [root@lifei lv]# grep -v ^# /etc/default/useradd
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes - 匹配空行(^$)
- [root@lifei lv]# grep ^$ /etc/login.defs
- 匹配非空行
- [root@lifei lv]# grep -v ^$ /etc/login.defs
- 结合管道使用匹配非空行,非#开头的行
- [root@lifei lv]# grep -v ^$ /etc/login.defs | grep -v ^#
MAIL_DIR /var/spool/mail
UMASK 022
HOME_MODE 0700
PASS_MAX_DAYS 99999
PASS_MIN_DAYS 0
PASS_MIN_LEN 5
PASS_WARN_AGE 7
UID_MIN 1000
UID_MAX 60000
SYS_UID_MIN 201
SYS_UID_MAX 999
GID_MIN 1000
GID_MAX 60000
SYS_GID_MIN 201
SYS_GID_MAX 999
CREATE_HOME yes
USERGROUPS_ENAB yes
ENCRYPT_METHOD SHA512
-
查找文件
- 根据预设的条件递归查找对应文件
- find 【目录】【条件1】 【-a|-o】【条件2】 # -a表示and, -o表示or
- 常用条件表示:
- -type 类型(f文本文件、d目录、l链接文件、)
-
- [root@lifei lv]# find /boot/ -type d
/boot/
/boot/efi
/boot/efi/EFI
/boot/efi/EFI/centos
/boot/lost+found
/boot/grub2
/boot/grub2/fonts
/boot/grub2/i386-pc
/boot/loader
/boot/loader/entries
[root@lifei lv]# ls -l /boot/efi
- [root@lifei lv]# find /boot/ -type d
- -name ”文档名称“
-
- [root@lifei lv]# find /etc/ -name “passwd”
/etc/pam.d/passwd
/etc/passwd
- [root@lifei lv]# find /etc/ -name “passwd”
- size +|-文件大小(k/M/G) # +表示大于,-表示小于,k是小写,M、G是大写
-
- [root@lifei lv]# find /boot/ -size +10M
/boot/initramfs-4.18.0-193.el8.x86_64kdump.img
/boot/initramfs-4.18.0-305.12.1.el8_4.x86_64.img
/boot/initramfs-4.18.0-193.14.2.el8_2.x86_64.img
/boot/initramfs-0-rescue-465267a122c2dd41a8a89da8ba435f2e.img
/boot/initramfs-4.18.0-193.14.2.el8_2.x86_64kdump.img
/boot/initramfs-4.18.0-305.12.1.el8_4.x86_64kdump.img
- [root@lifei lv]# find /boot/ -size +10M
- user 用户名
- mtime 根据文件修改的时间(比如录像数据要删除90天之前的记录,就可以用这个参数查找)
-
- -mtime +10 :10天之前修改的文档
-
- -mtime -10:10天之内修改的文档
- find的高级使用
- 使用find命令的 --exec 操作
-
- find … … --exec 处理命令 {} ;
-
- 优势: 以{}代替每一个结果,逐个处理 ,遇到;结束
-
- [root@lifei lv]# find /boot/ -size +10M -exec cp {} /opt ;
- 根据预设的条件递归查找对应文件
-
NTP时间同步
- 校对系统时间
- NTP网络时间协议
-
- network time protocol
- *NTP服务器为客户机提供标准时间
-
- NTP客户机需要与NTP服务器保持沟通
-
- 软件包:chrony
-
- 配置文件:/etc/chrony.conf
-
- 系统服务: chronyd
- 配置chronyd校时服务
-
- [root@lifei lv]# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
pool 2.centos.pool.ntp.org iburst
- [root@lifei lv]# cat /etc/chrony.conf
- 测试校时服务
-
- systemctl status chronyd
-
- systemctl start chronyd
- 校对系统时间
-
使用LDAP认证,实现网络用户认证,达到用户的集中管理
- 网络用户:用户信息会放在网络中LDAP服务器
- 本地用户:用户信息会放在/etc/passwd
- 安装sssd软件,与LDAP服务器沟通 # yum -y install sssd
- 安装authconfig-gtk图形工具,进行配置客户端sssd软件 # yum -y install authconfig-gtk
CENTOS几条常用命令
最新推荐文章于 2024-05-18 16:45:30 发布