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 ...
随机推荐
- PageAdmin Cms V2.0 getshell 0day
黑小子在土司公布了“PageAdmin cms getshell Oday”,并给出了一个漏 洞的利用EXP.经过危险漫步在虚拟机里测试,存在漏洞的是PageAdmin Cms的次最薪版本PageAd ...
- mysql 5.7 laravel json类型数据相关操作
2018年10月16日18:14:21 官方文档中文翻译版 原文:https://dev.mysql.com/doc/refman/5.7/en/json.html 最后有部分实例和一个小总结 11. ...
- SAP中的一些简称及简要介绍
SAP-(System Applications and Products) 基础部分: R/3系统内核.数据库.支持各类平台的接口.ABAP(Advanced Business Applicatio ...
- Confluence实现附件下载权限的控制
背景: 公司为了方便的管理过程文档,搭建了一个Confluence服务器,版本6.9.在使用过程中,需要按照用户对空间中上传的附件进行下载权限控制. 解决过程及处理方案: 一.Confluence中导 ...
- Install Superset from Python3.6
本文安装Superset大致分为以下部分: 在操作系统中安装相关依赖,我所用的操作系统为Centos6.5 安装Python3.6.6 安装Superset 详细步骤如下: 相关依赖的安装 yum i ...
- Windows下Git Bash中VIM打开文件中文乱码
Windows下Git Bash中VIM打开文件中文乱码,解决方法是: 步骤一 admin@DESKTOP-O99620V MINGW64 /d/项目GGE/Hard_for_GGE (master) ...
- C++实验三
part2 graph.h #ifndef GRAPH_H#define GRAPH_H// 类Graph的声明 class Graph { public: Graph(char ch, int n) ...
- OI养老专题02:约瑟夫问题求幸存者
如题.人数为n(1<=n<=30000),共k(1<=k<=30000)组数据,所报的数m恒为2,只要求输出幸存者. 如果你还不知道什么是约瑟夫问题...——https://w ...
- com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value '��� mysql-installer-community-8.0.15.0
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> &l ...
- js左右大小变化
点左边左边变大.点右边右边大左边小 <style type="text/css"> *{ margin:0px auto; padding:0px; } #wai{ w ...