centos7查看可登陆用户
cat /etc/passwd | grep -v /sbin/nologin | cut -d : -f 1
cat /etc/passwd | grep /bin/bash | cut -d : -f 1
查看登录成功的用户信息
last | less
查看登录失败的用户信息
lastb | less
查看登录日志
tail /var/log/secure
限制IP登录
vim /etc/hosts.deny
#
# hosts.deny This file contains access rules which are used to
# deny connections to network services that either use
# the tcp_wrappers library or that have been
# started through a tcp_wrappers-enabled xinetd.
#
# The rules in this file can also be set up in
# /etc/hosts.allow with a 'deny' option instead.
#
# See 'man 5 hosts_options' and 'man 5 hosts_access'
# for information on rule syntax.
# See 'man tcpd' for information on tcp_wrappers
#
sshd:1.1.1.1:deny
sshd:21.122.198.1:deny
CentOS清除用户登录记录和命令历史方法
清除登陆系统成功的记录
[root@localhost root]# echo > /var/log/wtmp //此文件默认打开时乱码,可查到ip等信息
[root@localhost root]# last //此时即查不到用户登录信息
清除登陆系统失败的记录
[root@localhost root]# echo > /var/log/btmp //此文件默认打开时乱码,可查到登陆失败信息
[root@localhost root]# lastb //查不到登陆失败信息
清除历史执行命令
[root@localhost root]# history -c //清空历史执行命令
[root@localhost root]# echo > ./.bash_history //或清空用户目录下的这个文件即可
导入空历史记录
[root@localhost root]# vi /root/history //新建记录文件
[root@localhost root]# history -c //清除记录
[root@localhost root]# history -r /root/history.txt //导入记录
[root@localhost root]# history //查询导入结果
example
[root@localhost root]# vi /root/history
[root@localhost root]# history -c
[root@localhost root]# history -r /root/history.txt
[root@localhost root]# history
[root@localhost root]# echo > /var/log/wtmp
[root@localhost root]# last
[root@localhost root]# echo > /var/log/btmp
[root@localhost root]# lastb
[root@localhost root]# history -c
[root@localhost root]# echo > ./.bash_history
[root@localhost root]# history
相关知识点
用户相关
centos7中所有用户都在文件/etc/passwd 中保存
管理员UID为0:系统的管理员用户。
系统用户UID为1~999:
Linux系统为了避免因某个服务程序出现漏洞而被黑客提权至整台服务器,默认服务程序会有独立的系统用户负责运行,进而有效控制被破坏范围。
普通用户UID从1000开始:
是由管理员创建的用于日常工作的用户。
命令相关
grep 中-v为反向查找cut 中-d 分割符号 -f为第几列
用户管理
useradd 增加用户usermod 更改用户信息groupadd增加组userdel删除用户
版权属于: 三三世界-百宝箱
本文链接: http://33f.net/linux/centos_login_log.html
本文最后更新于2022年04月20日 ,已超过1455天没有更新,若内容或图片失效,请留言反馈。
本文允许转载,但请在转载时请以超链接或其它形式标明文章出处
@Doug Shume it's ok for me , you can post here.
zh.us.to 有效
kms.03k.org 有效
kms.chinancce.com
kms.shuax.com 有效
kms.dwhd.org 有效
kms.luody.info 有效
kms.digiboy.ir 有效
kms.lotro.cc 有效
www.zgbs.cc 有效
cy2617.jios.org 有效
@ 权限问题,试试sudo 再加命令。
你好提示Permission denied 怎么办啊