linux之添加切换用户、系统变量、selinux、防火墙、系统中文乱码的讲解
######linux用户分类
1.root 用户 linux皇帝
2.普通用户 贫民百姓
[root@oldboyedu-01 oldboy]# useradd oldboy
[root@oldboyedu-01 oldboy]# id oldboy
uid=500(oldboy) gid=500(oldboy) groups=500(oldboy)
[root@oldboyedu-01 oldboy]# id lilaoshi
id: lilaoshi: No such user
[root@oldboyedu-01 oldboy]# passwd oldboy
Changing password for user oldboy.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
#切换用户
[root@oldboyedu-01 oldboy]# whoami
root
[root@oldboyedu-01 oldboy]# su - oldboy
[oldboy@oldboyedu-01 ~]$ whoami
oldboy
#切换回root
[oldboy@oldboyedu-01 ~]$ su - root
Password:
#退出当前用户 注销
[oldboy@oldboyedu-01 ~]$ #ctrl + d
[oldboy@oldboyedu-01 ~]$ logout
课后题目:
#su 与su -区别
#面试题:你的系统什么版本的?
[root@oldboyedu-01 ~]# cat /etc/redhat-release ----查看操作系统的版本
CentOS release 6.9 (Final)
[root@oldboyedu-01 ~]# uname -r ----内核版本
2.6.32-696.el6.x86_64
[root@oldboyedu-01 ~]# uname -m ----操作系统的位数
x86_64
[root@oldboy004 /]# uname -a
Linux oldboy004 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
#PS1是什么鬼?
变量名字 -------藏经阁武功秘籍------葵花宝典
echo $PS1 查看变量的内容------- 阅读秘籍------手书
PS1=新的内容向 变量中放入内容----- 写心得体会------书名字=欲练此功,必先自宫;
若不自宫,也能成功.
#PS1 系统环境变量
##一般都是大写的,在系统中任何的地方都可以使用。
[root@oldboyedu-01 ~]# echo $PS1
[\u@\h \W]\$
[root@oldboyedu-01 ~]# #\u=====当前用户名 whoami
[root@oldboyedu-01 ~]# #\h 当前主机名 hostname
[root@oldboyedu-01 ~]# #\W 当前的位置 pwd
[root@oldboyedu-01 ~]# PS1='[\u@\h \W \t]\$'
###SElinux关闭
#####临时关闭-重启服务器失效
[root@oldboyedu-01 ~]# #查询selinux状态
[root@oldboyedu-01 ~]# getenforce
Enforcing
[root@oldboyedu-01 ~]# #enforcing selinux正在运行
[root@oldboyedu-01 ~]# #permissive selinux临时关闭 还是提示警告
[root@oldboyedu-01 ~]# #disabled selinux彻底关闭
[root@oldboyedu-01 ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@oldboyedu-01 ~]# setenforce 0
[root@oldboyedu-01 ~]# getenforce
Permissive
[root@oldboyedu-01 ~]#
#####永久关闭-重启服务器生效
vim /etc/selinux/config
[root@oldboyedu-01 ~]# grep "=disabled" /etc/selinux/config
SELINUX=disabled
[root@oldboyedu-01 ~]# grep "disabled" /etc/selinux/config
# disabled - No SELinux policy is loaded.
SELINUX=disabled
小结:
1.临时关闭-setenforce
2.永久关闭-修改配置文件
##关闭Iptables
什么时候开启防火墙,什么时候关闭防火墙
####服务器对外使用,有外网,开启防火墙
####服务器内网, 关闭
#######关闭防火墙 防火墙可以理解为保安
#####临时关闭
临时关闭,就是当前不再运行,当电脑重新启动的时候会自动开启防火墙
#查询防火墙是否在运行
/etc/init.d/iptables status
建议防火墙关闭两次,因为有时候一次关闭不了
[root@oldboyedu-01 ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@oldboyedu-01 ~]# /etc/init.d/iptables stop
[root@oldboyedu-01 ~]# /etc/init.d/iptables status
iptables: Firewall is not running.
#####永久关闭
开机自动启动
#让iptables在开机的时候 不自动启动
chkconfig
--查看防火墙是否自动运行
[root@oldboyedu-01 ~]# chkconfig |grep ipt
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
表示自动运行中
--关闭防火墙
[root@oldboyedu-01 ~]# chkconfig iptables off
--查看防火墙是否自动运行
[root@oldboyedu-01 ~]# chkconfig |grep ipt
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
小结:
1.临时关闭 xxxx stop
2.永久 chkconfig xx off
##显示中文乱码
####1.什么是字符集?
######表示字符 文字的方法
UTF-8 万国码 系统默认的字符集
GBK GB2312
####2.如何查看系统的字符集
[root@oldboyedu-01 ~]# echo $LANG
en_US.UTF-8
[root@oldboyedu-01 ~]# #语言.字符集
####3.如何修改字符集-临时
[root@oldboyedu-01 ~]# export LANG=zh_CN.UTF-8
[root@oldboyedu-01 ~]# echo $LANG
zh_CN.UTF-8
####4.如何修改字符集-永久
[root@oldboyedu-01 ~]# cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
####5.生效
[root@oldboyedu-01 ~]# source /etc/sysconfig/i18n
[root@oldboyedu-01 ~]# echo $LANG
en_US.UTF-8
#####1.查看中文乱码的原因******
####1)linux使用的字符集
####2)远程连接工具使用的字符集
####1) 与 2) 不同 就会导致乱码
#####2.排查
####1)linux使用的字符集
####2)远程连接工具使用的字符集
#####3.解决
####方法1 修改远程连接工具字符集
####方法2 修改linux系统的字符集
####1.如何修改字符集-临时
####2.如何修改字符集-永久
####3.生效
linux之添加切换用户、系统变量、selinux、防火墙、系统中文乱码的讲解的更多相关文章
- 在linux中添加ftp用户,并设置相应的权限
在linux中添加ftp用户,并设置相应的权限,操作步骤如下: 1.环境:ftp为vsftp.被限制用户名为test.被限制路径为/home/test 2.建用户:在root用户下: useradd ...
- linux中添加ftp用户,并设置相应的权限
在linux中添加ftp用户,并设置相应的权限,操作步骤如下: 1.环境:ftp为vsftp.被限制用户名为test.被限制路径为/home/test 2.建用户:在root用户下: useradd ...
- linux使用su切换用户提示 Authentication failure的解决方法& 复制文件时,报cp: omitting directory `XXX'
linux使用su切换用户提示 Authentication failure的解决方法:这个问题产生的原因是由于ubtun系统默认是没有激活root用户的,需要我们手工进行操作,在命令行界面下,或者在 ...
- Linux——CentOS7添加/删除用户和用户组1
Linux--CentOS7添加/删除用户和用户组 2017.05.02 19:58 23012浏览 前言 今天又重新装了centos7突然有关用户和用户组有关的命令记不清了,所以记一下,也方便你 ...
- SharePoint2013网站添加切换用户登录
不知道大家发现没,sharepoint2013的网站集下面没有了切换用户登陆这个选项卡,这对于我们有时候要做一些权限性的实验是不太方便的,今天我找到了一个办法解决,又实际应用了一下,感觉不错,特地来和 ...
- linux Grant 添加 MySql 用户
Grant 添加 MySql 用户 2009-04-03 14:40 我安装的版本: mysql> select version();+------------+| version() |+ ...
- 给linux虚拟机添加Samba用户
Window系统连上我们的开发机Linux,自然需要在Samba里添加一个新用户. linux-06bq:/usr/local/services/samba/bin # ./smbpasswd -a ...
- Linux 使用 su 切换用户提示 Authentication Failure 的解决方法
Ubuntu v14.04,使用 su 命令切换用户时报验证失败的错误 这个问题产生的原因是由于 ubuntu 系统默认是没有激活 root 用户的,需要我们手工进行操作,在命令行界面下,或者在终端中 ...
- Linux基础命令---切换用户su
su 临时切换身份到另外一个用户,使用su切换用户之后,不会改变当前的工作目录,但是会改变一些环境变量. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUS ...
随机推荐
- Linux服务器tomcat无法通过ip加端口访问
Linux服务器tomcat无法通过ip加端口访问 防火墙开放端口 # Firewall configuration written by system-config-firewall# Manual ...
- yield关键字
1.yield语句有两种形式 (1)yield return <expression>;一次返回一个元素 运行yield return 语句时,会返回一个 值,并记录当前位置及保留该值.下 ...
- ubuntu16.04升级Python3.5到Python3.7
因为python3.5和python3.6之后的版本差异很大,所有需要改变python的版本 简易安装python后得到的3版本的版本号是python3.5. 可以使用下面的命令查看py版本: pyt ...
- MYSQL转换编码的解决方法
MYSQL转换编码的解决方法 一.在utf8的mysql下 得到中文‘游客’的gbk下的16进制编码 mysql> SELECT hex(CONVERT( '游客' USING gbk )); ...
- const成员函数用法
详见博客,该博客讲解得很详细,为节省时间就--
- Oracle 10053
[10053]alter session set events '10053 trace name context forever,level 1'; <Run your SQL here;&g ...
- 【备忘】mybatis的条件判断用<choose>
mybatis并没有if..else,在mybatis的sql mapper文件中,条件判断要用choose..when..otherwise. <choose> <when t ...
- Quill插入html5的video标签
quill的video模块插入的是iframe标签,我们需要的是video标签. 1.定义自己的video模块 declare const require: any; const Quill = re ...
- Ubuntu16.04彻底删除PHP7.2
一.删除php的相关包及配置 apt-get autoremove php7* 二.删除关联 sudo find /etc -name "*php*" |xargs rm -rf ...
- 在绘图的时候import matplotlib.pyplot as plt报错:ImportError: No module named '_tkinter', please install the python-tk package
在绘图的时候import matplotlib.pyplot as plt报错:ImportError: No module named '_tkinter', please install the ...