004---Linux系统设置
Linux版本相关命令
- 查看系统版本:
cat /etc/redhat-release - 查看系统内核版本以及位数:
uname -r
[root@hostname1 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root@hostname1 ~]# uname -r
3.10.0-957.el7.x86_64
PS1
变量名,系统变量一般都是大写。
[root@hostname1 ~]# echo $PS1
[\u@\h \W]\$
[root@hostname1 ~]# # \u-->当前用户名:whoami
[root@hostname1 ~]# # \h-->当前主机名:hostname
[root@hostname1 ~]# # \W-->当前目录:pwd
[root@hostname1 ~]# whoami
root
[root@hostname1 ~]# hostname
hostname1
[root@hostname1 ~]# pwd
/root
修改PS1:加时间
[root@hostname1 ~]# PS1='[\u@\h \W \t]\$'
[root@hostname1 ~ 20:34:51]#
linux系统优化
用户
- 添加用户:
useradd JiangZiYa - 查看用户:
id JiangZiYa - 修改密码:
passwd JiangZiYa - 查看当前用户:
whoami - 切换用户:
su - JiangZiYa - 切换root用户:
su -orsu - root - 注销用户:
logoutorctrl + D
[root@hostname1 ~]# useradd JiangZiYa
[root@hostname1 ~]# id JiangZiYa
uid=1000(JiangZiYa) gid=1000(JiangZiYa) groups=1000(JiangZiYa)
[root@hostname1 ~]# id user
id: user: no such user
[root@hostname1 ~]# passwd JiangZiYa
Changing password for user JiangZiYa.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@hostname1 ~]# whoami
root
[root@hostname1 ~]# su - JiangZiYa
Last login: Mon Feb 4 21:11:38 CST 2019 on pts/0
[JiangZiYa@hostname1 ~]$ whoami
JiangZiYa
[JiangZiYa@hostname1 ~]$ su -
Password:
Last login: Mon Feb 4 21:11:24 CST 2019 on pts/0
[root@hostname1 ~]# logout
[JiangZiYa@hostname1 ~]$
关闭SELinux
- 查询状态:
getenforce- Enforcing:正在执行
- Permissive:临时关闭,还是提示警告
- Disabled :彻底关闭
[JiangZiYa@hostname1 ~]$ getenforce
Enforcing
[root@hostname1 ~]# getenforce
Permissive
[root@hostname1 ~]# getenforce
Disabled
- 临时关闭:
setenforce 0
[root@hostname1 ~]# setenforce 0
- 永久关闭:
vim /etc/sysconfig/selinux
SELINUX=disabled
重启生效
关闭防火墙
- 查看防火墙状态:
systemctl status firewalldorfirewall-cmd --state
[root@hostname1 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2019-02-04 21:43:15 CST; 1min 50s ago
Docs: man:firewalld(1)
Main PID: 6308 (firewalld)
CGroup: /system.slice/firewalld.service
└─6308 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Feb 04 21:43:13 hostname1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Feb 04 21:43:15 hostname1 systemd[1]: Started firewalld - dynamic firewall daemon.
[root@hostname1 ~]# firewall-cmd --state
running
- 临时关闭防火墙:
systemctl stop firewalld
[root@hostname1 ~]# systemctl stop firewalld
[root@hostname1 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Mon 2019-02-04 21:45:58 CST; 1s ago
Docs: man:firewalld(1)
Process: 6308 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 6308 (code=exited, status=0/SUCCESS)
Feb 04 21:43:13 hostname1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Feb 04 21:43:15 hostname1 systemd[1]: Started firewalld - dynamic firewall daemon.
Feb 04 21:45:57 hostname1 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Feb 04 21:45:58 hostname1 systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@hostname1 ~]#
- 永久关闭防火墙:
systemctl disable firewalld
[root@hostname1 ~]# systemctl disable firewalld
[root@hostname1 ~]# reboot
Connecting to 10.0.0.128:22...
Could not connect to '10.0.0.128' (port 22): Connection failed.
Type `help' to learn how to use Xshell prompt.
[c:\~]$
Connecting to 10.0.0.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Last login: Mon Feb 4 21:52:23 2019 from 10.0.0.1
[root@hostname1 ~]# 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)
[root@hostname1 ~]# firewall-cmd --state
not running
- 重启防火墙:
systemctl restart firewalld
004---Linux系统设置的更多相关文章
- linux系统设置服务开机启动3种方法,Linux开机启动程序详解
linux系统设置服务开机启动 方法1:.利用ntsysv伪图形进行设置,利用root登陆 终端命令下输入ntsysv 回车:如下图 方法2:利用命令行chkconfig命令进行设置 简要说明 ...
- 为虚机Linux系统设置静态IP,ping通外网并解决相关问题
在虚机中安装完Linux系统后,虚机是ping不通外网的,而默认的动态IP会为之后的Hadoop应用造成不少麻烦,为了减少这些不必要的麻烦,我们把系统的IP设置为静态. 步骤: 修改系统配置文件 命令 ...
- Mint(Linux)系统设置优化及其常用软件安装笔记
LInux /home下中文目录如何修改成英文? 打开终端,在终端中输入命令: export LANG=en_US xdg-user-dirs-gtk-update 跳出对话框询问是否将目录转化为英文 ...
- linux系统设置-防火墙
基础知识 Linux系统内核内建了netfilter防火墙机制.Netfilter(数据包过滤机制),所谓的数据包过滤,就是分析进入主机的网络数据包,将数据包的头部数据提取出来进行分析,以决该连接为放 ...
- [国嵌笔记][004][Linux快速体验]
Linux文件系统 bin目录:可执行的程序 boot目录:与Linux启动相关的文件 dev目录:设备以文件的方式存放 etc目录:配置文件 home目录:用户文件 lib目录:与库相关的文件 ro ...
- linux系统设置cpu孤立
介绍 针对cpu密集型的任务,消耗cpu较高,最好设置cpu亲和度,以提高任务执行效率,避免cpu进行上下文切换,浪费不必要的性能. 特定任务(进程/线程)需要独占一个cpu核心并且不想让其他任务(进 ...
- Linux 系统设置sh文件开机自启动
工作中有一个linux下的服务需要启动,但是机器总是断电,导致需要反复启动,找了一下开机自启动的方法,解决了这个问题.Linux设置开机自启动非常简单,只要找到rc.local文件,将你需要自启动的文 ...
- (转)Linux 系统设置 : dmesg 命令详解
原文:https://blog.csdn.net/yexiangCSDN/article/details/80683246 https://www.cnblogs.com/duanxz/p/34770 ...
- Linux系统设置及基本操作
下面是Linux系统的基本的使用以及系统操作命令,目录结构等等! linux系统的操作方式 图形界面:RHEL6默认使用GNOME桌面环境 伪字符终端: 图形桌面环境中的伪字符终端 对应程序: gn ...
- Linux系统设置开机自动启动ORACLE数据库服务
具体方法如下: 1. 修改oratab (root用户执行) /etc/oratab的配置格式如下: $ORACLE_SID:$ORACLE_HOME:Y 2. 测试dbstart, dbstop(o ...
随机推荐
- 服务器ipmi远程管理
DELL iDRAC (Integrated Dell™ Remote Access Controller )是 Dell PowerEdge 系列服务器上的远程管理方案, 11代 12代服务器已经集 ...
- 利用SQL Server Management Studio(SSMS)复制数据库
利用SQL Server Management Studio(SSMS)复制数据库 标签(空格分隔): SQLServer 前言 今天由于客户购买的软件版本确认了,而之前进行开发的本地数据库版本较低, ...
- Selenium2学习(十)-- iframe定位
前言 有很多小伙伴在拿163作为登录案例的时候,发现不管怎么定位都无法定位到,到底是什么鬼呢,本篇详细介绍iframe相关的切换 以http://mail.163.com/登录页面10为案例,详细介绍 ...
- Quartus II管脚批量分配文件(.tcl)格式
package require ::quartus::project set_location_assignment PIN_E1 -to clk set_location_assignment PI ...
- 浏览器下出现net::ERR_BLOCKED_BY_CLIENT的解决办法
转发网址:https://www.cnblogs.com/wenzheshen/p/7724065.html 当我们在做开发时,调试页面图片会出现部分图片无法正常显示,并且确认图片的地址正确: 按F1 ...
- bootstrap table 怎么实现前两列固定冻结?
$("#Table").bootstrapTable('destroy').bootstrapTable({ pagination: true,//分页 minimumCountC ...
- Ajax综合应用大全(全面解析)
AJAX即“Asynchronous Javascript And XML”(异步JavaScript和XML),是指一种创建交互式网页应用的网页开发技术. AJAX = 异步 JavaScrip ...
- Cesium.js学习第二天(立方体)
var viewer = new Cesium.Viewer('cs'); viewer.entities.add({//图标 position: Cesium.Cartesian3.fromDegr ...
- Android学习笔记_71_Android 多个项目之间如何引用 项目怎样打jar包
一.将整个项目作为资源文件 1.需要将被应用的项目设置为库项目. 2.将该项目的配置文件中的四大组件清空,例如下面代码: <?xml version="1.0" encodi ...
- 转载:C/C++ typedef用法
原文链接:http://www.cnblogs.com/ggjucheng/archive/2011/12/27/2303238.html 引言 typedef 声明,简称 typedef,为现有类型 ...