美文网首页
2019-04-15永久修改密码 SElinuxguanbi 防

2019-04-15永久修改密码 SElinuxguanbi 防

作者: 看见光明才有希望 | 来源:发表于2019-04-15 19:39 被阅读0次

    1.查看系统版本信息

    系统

    [root@oldboyedu59 ~]# cat /etc/redhat-release  /etc/centos-release
    
    CentOS Linux release 7.6.1810 (Core) 
    
    CentOS Linux release 7.6.1810 (Core) 
    
    [root@oldboyedu59 ~]# ll  /etc/redhat-release  /etc/centos-release
    
    -rw-r--r--. 1 root root 38 Nov 23 21:16 /etc/centos-release
    
    lrwxrwxrwx. 1 root root 14 Mar 26 11:38 /etc/redhat-release -> centos-release
    

    查看内核版本

    [root@lidao ~]# uname -r
    
    3.10.0-957.el7.x86_64
    
    [root@lidao ~]# uname -m
    
    x86_64
    
    [root@lidao ~]# 32位
    
    i386  i686 
    

    快速修改密码:root下

    [root@lidao ~]# echo 123456|passwd --stdin oldboy
    
    Changing password for user oldboy.
    

    环境变量:
    1、系统设置 创建 显示 配置系统特性

    2、名字大写

    3、可以在linux下面随处使用

    命令的运行故事

    UID:用户系统唯一标识符

    PATH 存放的是命令的位置/路径

    :(1)字符串加符号,代表字符串变量内容;

    (2)普通用户命令提示符

    [root@lidao ~]# echo $PATH 
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
    
    /usr/local/sbin
    
    /usr/local/bin
    
    /usr/sbin   === /sbin 
    
    /usr/bin    === /bin 
    
    /root/bin
    

    输入ls 回车之后发生了什么?

    1.系统会在PATH里面进行查找

    2.存在 运行(命令解释器)

    3.不存在 提示 command not found

    [root@oldboyedu59 ~]# echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
    
    [root@lidao ~]# echo $PS1
    [\u@\h \W]\$
    

    export PS1='[\u@\h \W]$ '用户名 主机名 所在当前位置 用户身份
    控制命令行格式

    老男孩教育出品-PS1环境变量讲解

    https://www.processon.com/view/link/5a31efdbe4b03a96d02497af

    修改环境变量过程:

    1.临时-重新登录系统失效(修改颜色)

    export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
    

    2.永久-写入文件/etc/profile 与生效

    [root@oldboyedu59 /etc/sysconfig]# tail -1  /etc/profile
    export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
    
    [root@oldboyedu59 /etc/sysconfig]# source  /etc/profile
    

    3.检查

    [root@oldboyedu59 /etc/sysconfig]# echo $PS1
    [\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$
    

    关闭Selinux

    操作前备份 操作后检查
    ```
        cp /etc/selinux/config /etc/selinux/config.bak
    永久
        修改配置文件
    临时
    

    永久
    修改配置文件

    3 # SELINUX= can take one of these three values:

    4 # enforcing - SELinux security policy is enforced.

    5 # permissive - SELinux prints warnings instead of disabled.

    6 # disabled - No SELinux policy is loaded.

    7 SELINUX=enforcing
    ```
    SELINUX=右边可以写什么

    SELINUX=enforcing SELinux开启

    SELINUX=permissive SELinux关闭 还会有警告信息

    SELINUX=disabled SELinux彻底关闭

    [root@oldboyedu59 ~]# grep '=disabled' /etc/selinux/config
    SELINUX=disabled
    

    临时 查看selinux状态

    [root@oldboyedu59 ~]# getenforce 
    Disabled
    
    [root@lidao ~]# getenforce 
    Disabled
    
    [root@oldboyedu59 ~]# setenforce 
    usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
    
    [root@oldboyedu59 ~]# setenforce 0
    setenforce: SELinux is disabled
    

    关闭防火墙

    [root@oldboyedu59 ~]# systemctl stop firewalld 
    
    [root@oldboyedu59 ~]# 
    
    [root@oldboyedu59 ~]# systemctl disable  firewalld 
    
    Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
    
    Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    

    重启防火墙

    [root@wuxin-123 ~]# systemctl restart firewalld.service  
    

    报错

    ** (pkttyagent:103429): WARNING **: 11:29:43.184: Unable to register authentication
    
    agent: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Rejected send message,
    
    1 matched rules; type="method_call", sender=":1.106" (uid=0 pid=103429
    
    comm="/usr/bin/pkttyagent --notify-fd 5 --fallback ")
    
    interface="org.freedesktop.PolicyKit1.Authority"
    
    member="RegisterAuthenticationAgentWithOptions" error name="(unset)"
    
    requested_reply="0" destination=":1.2" (uid=999 pid=6336
    
    comm="/usr/lib/polkit-1/polkitd --no-debug ")
    
    Error registering authentication agent:
    
    GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 1
    
    matched rules; type="method_call", sender=":1.106" (uid=0 pid=103429
    
    comm="/usr/bin/pkttyagent --notify-fd 5 --fallback ")
    
    interface="org.freedesktop.PolicyKit1.Authority"
    
    member="RegisterAuthenticationAgentWithOptions" error name="(unset)"
    
    requested_reply="0" destination=":1.2" (uid=999 pid=6336 comm="/usr/lib/polkit-1/polkitd --no-debug ") (g-dbus-error-quark, 9)
    
    /var/log/messages 报错
    Apr 15 11:34:36 wuxin-123 dbus[6339]: [system] Rejected send message, 1 matched
    
    rules; type="method_call", sender=":1.109" (uid=0 pid=103805 comm="/usr/bin/pkttyagent --notify-fd 5 --fallback ") 
    
    interface="org.freedesktop.PolicyKit1.Authority"
    
    member="RegisterAuthenticationAgentWithOptions" error name="(unset)"
    
    requested_reply="0" destination=":1.2" (uid=999 pid=6336 comm="/usr/lib/polkit-1/polkitd --no-debug ")
    

    解决 发现切换用户会卡主 重启服务报错

    可能与系统用户登录服务有关重启后 解决。

    [root@wuxin-123 ~]# systemctl restart  systemd-logind.service 
    [root@wuxin-123 ~]# 
    [root@wuxin-123 ~]# su - oldboy 
    
    Last login: Mon Apr 15 09:27:22 CST 2019 on pts/1
    
    [oldboy@wuxin-123 ~]$ logout
    
    [root@wuxin-123 ~]# 
    
    [root@wuxin-123 ~]# systemctl restart firewalld 
    

    wget 非交互式网络文件下载工具

    yum install -y wget 
    
    https://www.baidu.com/link?url=9pCIxUQ8LkSTYWUeWeJRLkYP8ui_2uLRE-q9p76vPCfmCPq6AkqnJLbOiSW_eqij&wd=&eqid=ebae4263000089ce000000035cb40510   
    

    配置yum源

    https://opsx.alibaba.com/mirror阿里网站mirrors.aliyun 镜像网址
    https://mirrors.tuna.tsinghua.edu.cn/清华网站
    
    [root@lidao ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    --2019-04-15 17:49:07--  http://mirrors.aliyun.com/repo/Centos-7.repo
    
    [root@lidao ~]# yum repolist 安装
    
    Loaded plugins: fastestmirror
    
    Loading mirror speeds from cached hostfile
    
     * base: ap.stykers.moe
     
     * extras: centos.ustc.edu.cn
     
     * updates: centos.ustc.edu.cn
     
    repo id                 repo name                 status
    
    !base/7/x86_64          CentOS-7 - Base           10,019
    
    !extras/7/x86_64        CentOS-7 - Extras            385
    
    !updates/7/x86_64    
    

    配置完成epel源之后完整 常用的软件包

    yum install -y  tree vim nc nmap lrzsz  wget  bash-completion* cowsay  sl htop
    
    iotop  iftop 
    
    
    
     bash-completion  (base)
     
     bash-completion-extras (epel)
    

    相关文章

      网友评论

          本文标题:2019-04-15永久修改密码 SElinuxguanbi 防

          本文链接:https://www.haomeiwen.com/subject/xmvpwqtx.html