linux第十三天课程总结

                                                linux系统优化

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@oldboyedu59 ~]# uname -r
3.10.0-957.el7.x86_64

2.6.32 CentOS 6.x

[root@oldboyedu59 ~]# uname -m
x86_64

32位
i386 i686

[root@oldboyedu59 ~]# echo 123456|passwd --stdin oldboy
Changing password for user oldboy.
passwd: all authentication tokens updated successfully.

环境变量:
1.系统设置 创建 显示或配置系统特性
2.名字大写
3.可以在linux下面随处使用 一般含义一样

常见的环境变量
UID 当前用户uid信息
PATH 存放的是命令的位置/路径
[root@oldboyedu59 ~]# echo $PATH
/usr/local/sbin:/usr/local/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

PS1 控制命令行格式

老男孩教育出品-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

关闭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@oldboyedu59 ~]# 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 ~]#
[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 ~]#
[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

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

[root@oldboyedu59 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    repo id repo name status
    base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019
    extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 385
    updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,511
    repolist: 11,915

配置完成epel源之后完整 常用的软件包
yum install -y tree vim nc nmap lrzsz wget bash-completion* cowsay sl htop iotop iftop

bash-completion (base)
bash-completion-extras (epel)

你可能感兴趣的:(linux第十三天课程总结)