day15-Linux的优化_linux15个优化(1)

[root@oldboy59 ~]# uname 
Linux
[root@oldboy59 ~]# uname -r
3.10.0-957.10.1.el7.x86_64   \\内核版本
                               \\2.6.32  是CentOS 6.X的内核版本	

3.查看系统位数 uname -m
[root@oldboy59 ~]# uname -m
x86_64
          \\i386 i686  32位的	

二、添加用户 修改密码 查看与删除用户

1.添加用户
  useradd 加用户名

2.查看用户 id
id root

※3.修改密码
1. passwd  oldboy   \\密码简单会提示,再输一次就好了

※2.	--stdin  
  echo 123456|passwd --stdin oldboy
	从标准输入获取密码(从管道获取密码)
	非交互式设置密码

※如果在普通用户下修改密码是不可以的,只有root用户可以使用非交互式设置密码		
  [oldboy@oldboy59 ~]$ echo 199625|passwd --stdin oldboy   \\在普通用户下
  Only root can do that.                         
  \\只有根用户可以这样做。	
※只有root用户运行passwd 后面能加用户名	
  [oldboy@oldboy59 ~]$ passwd oldboy   \\普通用户下
  passwd: Only root can specify a user name.  
  \\只有根用户可以指定一个用户名

root用户下修改oldboy用户密码成功
[✡root@oldboy59 ~]# passwd oldboy \\root用户下
Changing password for user oldboy.
New password: 
passwd: all authentication tokens updated successfully.  \\密码修改成功

三、修改环境变量

.#系统设置 创建 显示或配置系统特性
.#名字大写
.#可以再linux下面随处使用 含义一样

1.常见的环境变量----->PATH

① UID 当前用户uid信息

[root@oldboy59 ~]# id
uid=0(root) gid=0(root) groups=0(root)    \\UID 当前用户uid信息

※② PATH 存放的是命令的位置/路径
[root@oldboy59 ~]# echo $PATH    \\用$符号识别环境变量
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/u
sr/sbin:/usr/bin:/root/bin

/usr/sbin:  ----->/sbin
/usr/bin:   ----->/bin

※关闭PATH的后果 ---->所有命令不能使用(临时)
重启后恢复
[✡root@oldboy59 ~]# PATH= \\等于后面加一个空格
[✡root@oldboy59 ~]# ls
-bash: ls: No such file or directory   \\没有这个目录
[✡root@oldboy59 ~]# find
-bash: find: No such file or directory   \\没有这个目录
[✡root@oldboy59 ~]# touch
-bash: touch: No such file or directory   \\没有这个目录


③我们在输入ls命令回车后发生了什么过程?

1.系统会在PATH里面进行查找
2.存在 运行(命令解释器)
3.不存在 command not found 命令找不到

2. $PS1修改环境变量的过程:

image.png

1.临时
  export PS1='[\u@\h \w]\$'     
  \\小写w是显示完整的目录
2.永久
  vim  /etc/profile添加
  [✡root@oldboy59 ~]# tail -n1 /etc/profile \\查看最后一行添加的变量
  export PS1="[\[\e[36;1m\]✡\u@\[\e[0m\]\[\e[34;1m\]\H\[\e[0m\] \
 [\e[33;1m\]\w\[\e[0m\]]\\$ "
3.检查
   [root@oldboy59 ~]#echo $PS1
   [\u@\h \W]\$
4.生效
[✡root@oldboy59 ~]# source /etc/profile

补充:颜色的变量修改
export PS1="[\[\e[36;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] 
\[\e[35;1m\]\w\[\e[0m\]]\\$ "


四、关闭SElinux

1.先看看SElinux是干什么的?
增强型Linux(安全) 
美国的NSA(安全局)用来限制root和普通用户权限的

2. 如何关闭SELinux

①永久关闭
修改配置文件 vim /etc/selinux/config
修改SELINUX=disabled 为永久关闭

SELinux=右边可以写什么:
SELINUX=enforcing   SELinux 开启
SELINUX=permissive  SELinux 禁用,有警告信息
SELINUX=disabled    SELinux 禁用

[✡root@oldboy59 /tmp]# vim /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# 开启 enforced - SELinux security policy is enforced.
# 宽容模式 permissive - SELinux prints warnings instead of disabled.
# 关闭 disabled - No SELinux policy is loaded.
SELINUX=disabled       //永久关闭
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are
 protected. 
# mls - Multi Level Security protection.
SELINUXTYPE=targeted    \\慎重修改

② 临时关闭

getenforce 查看
setenforce 修改 ,服务器重启后失效

getenforce 查看
[☆root@oldboy59 ~]# getenforce
Disabled

setenforce 修改 (0 )   
[☆root@oldboy59 ~]# setenforce 
usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
[☆root@oldboy59 ~]# setenforce 0
setenforce: SELinux is disabled  \\已经修改过

五、防火墙

firewalld (在CentOS 7中)
iptables (在CentOS 6&7中)

1.作用

根据设置规则 准许/禁止用户进出

2.是否需要开启?

①如果服务器有公网ip地址,则开启防火墙
②如果服务器没有公网ip 局域网或者并发访问量太高,则关闭防火墙

3.如何关闭呢

①防火墙临时关闭 systemctl stop firewalld
※服务器重启后会失效

[☆root@oldboy59 ~]# systemctl stop firewalld \\关闭防火墙
[☆root@oldboy59 ~]# systemctl status firewalld \\查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)    \\如果是active是运行中  如果是inactice则是关闭
     Docs: man:firewalld(1)

Apr 15 11:19:33 oldboy59 systemd[1]: Stopping firewalld - dynamic firewa....
Apr 15 11:19:33 oldboy59 systemd[1]: Stopped firewalld - dynamic firewal....
Hint: Some lines were ellipsized, use -l to show in full.


②防火墙永久关闭 systemctl disable firewalld

[☆root@oldboy59 ~]# systemctl disable firewalld \\ disable 禁用
[☆root@oldboy59 ~]# systemctl status firewalld \\查看防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)     \\以禁用
     Docs: man:firewalld(1)

Apr 15 11:19:33 oldboy59 systemd[1]: Stopping firewalld - dynamic firewa....
Apr 15 11:19:33 oldboy59 systemd[1]: Stopped firewalld - dynamic firewal....
Hint: Some lines were ellipsized, use -l to show in full.


③检查
systemctl status firewalld 查看防火墙状态

防火墙永久开启 enable

最全的Linux教程,Linux从入门到精通

======================

  1. linux从入门到精通(第2版)

  2. Linux系统移植

  3. Linux驱动开发入门与实战

  4. LINUX 系统移植 第2版

  5. Linux开源网络全栈详解 从DPDK到OpenFlow

华为18级工程师呕心沥血撰写3000页Linux学习笔记教程

第一份《Linux从入门到精通》466页

====================

内容简介

====

本书是获得了很多读者好评的Linux经典畅销书**《Linux从入门到精通》的第2版**。本书第1版出版后曾经多次印刷,并被51CTO读书频道评为“最受读者喜爱的原创IT技术图书奖”。本书第﹖版以最新的Ubuntu 12.04为版本,循序渐进地向读者介绍了Linux 的基础应用、系统管理、网络应用、娱乐和办公、程序开发、服务器配置、系统安全等。本书附带1张光盘,内容为本书配套多媒体教学视频。另外,本书还为读者提供了大量的Linux学习资料和Ubuntu安装镜像文件,供读者免费下载。

华为18级工程师呕心沥血撰写3000页Linux学习笔记教程

本书适合广大Linux初中级用户、开源软件爱好者和大专院校的学生阅读,同时也非常适合准备从事Linux平台开发的各类人员。

需要《Linux入门到精通》、《linux系统移植》、《Linux驱动开发入门实战》、《Linux开源网络全栈》电子书籍及教程的工程师朋友们劳烦您转发+评论

  • 13
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值