2019-04-15日 课程总结

李导排难解忧系列

01-老男孩教育-李导-Linux解惑系列
Linux应用这么广泛,学起来难不难?
新手面试Linux运维工作至少需要知道哪些知识点?-
https://www.bilibili.com/video/av48981405

02-老男孩教育-李导-Linux解惑系列-自学还是培训?
https://www.bilibili.com/video/av48985870

老男孩教育-李导-手把手带你玩转物理服务器
https://www.bilibili.com/video/av46656120

手把手带你绘图1-亿图专业绘制原理图超详细实战教程(限时免费)
https://edu.51cto.com/course/6173.html

老男孩教育-虚拟机无法上网/连接失败常见原因大集合
https://www.jianshu.com/p/0bc0b596c1a0

今日课程

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

passwd --stdin 用法

[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

PATH

[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 $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@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.

查看防火墙是否临时关闭成功

systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active:active (running)这是重点 since Mon 2019-04-15 15:37:52 CST; 38s ago
     Docs: man:firewalld(1)
 Main PID: 2048 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─2048 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Apr 15 15:37:51 lusanbao systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 15 15:37:52 lusanbao systemd[1]: Started firewalld - dynamic firewall daemon.

永久关闭防火墙

[root@lusanbao ~]# systemctl disable firewalld
[root@lusanbao ~]# 

临时启动防火墙``

[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源

[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)


今日回顾:
课前准备好虚拟机能正常上网。
每日回顾:
程序 进程 守护进程区别
如何查看进程
提升用户体验的方案
raid 0 1特点
什么是磁盘接口 常见的有什么接口
说出你服务器配置
什么是GNU GPL 
上述复习完可以看
文件与目录笔试题
https://www.jianshu.com/p/d333f4f8dec8

你可能感兴趣的:(2019-04-15日 课程总结)