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 - or su - root
  • 注销用户:logout or ctrl + 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 firewalld or firewall-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系统设置的更多相关文章

  1. linux系统设置服务开机启动3种方法,Linux开机启动程序详解

    linux系统设置服务开机启动 方法1:.利用ntsysv伪图形进行设置,利用root登陆 终端命令下输入ntsysv 回车:如下图     方法2:利用命令行chkconfig命令进行设置 简要说明 ...

  2. 为虚机Linux系统设置静态IP,ping通外网并解决相关问题

    在虚机中安装完Linux系统后,虚机是ping不通外网的,而默认的动态IP会为之后的Hadoop应用造成不少麻烦,为了减少这些不必要的麻烦,我们把系统的IP设置为静态. 步骤: 修改系统配置文件 命令 ...

  3. Mint(Linux)系统设置优化及其常用软件安装笔记

    LInux /home下中文目录如何修改成英文? 打开终端,在终端中输入命令: export LANG=en_US xdg-user-dirs-gtk-update 跳出对话框询问是否将目录转化为英文 ...

  4. linux系统设置-防火墙

    基础知识 Linux系统内核内建了netfilter防火墙机制.Netfilter(数据包过滤机制),所谓的数据包过滤,就是分析进入主机的网络数据包,将数据包的头部数据提取出来进行分析,以决该连接为放 ...

  5. [国嵌笔记][004][Linux快速体验]

    Linux文件系统 bin目录:可执行的程序 boot目录:与Linux启动相关的文件 dev目录:设备以文件的方式存放 etc目录:配置文件 home目录:用户文件 lib目录:与库相关的文件 ro ...

  6. linux系统设置cpu孤立

    介绍 针对cpu密集型的任务,消耗cpu较高,最好设置cpu亲和度,以提高任务执行效率,避免cpu进行上下文切换,浪费不必要的性能. 特定任务(进程/线程)需要独占一个cpu核心并且不想让其他任务(进 ...

  7. Linux 系统设置sh文件开机自启动

    工作中有一个linux下的服务需要启动,但是机器总是断电,导致需要反复启动,找了一下开机自启动的方法,解决了这个问题.Linux设置开机自启动非常简单,只要找到rc.local文件,将你需要自启动的文 ...

  8. (转)Linux 系统设置 : dmesg 命令详解

    原文:https://blog.csdn.net/yexiangCSDN/article/details/80683246 https://www.cnblogs.com/duanxz/p/34770 ...

  9. Linux系统设置及基本操作

    下面是Linux系统的基本的使用以及系统操作命令,目录结构等等! linux系统的操作方式 图形界面:RHEL6默认使用GNOME桌面环境 伪字符终端:  图形桌面环境中的伪字符终端 对应程序: gn ...

  10. Linux系统设置开机自动启动ORACLE数据库服务

    具体方法如下: 1. 修改oratab (root用户执行) /etc/oratab的配置格式如下: $ORACLE_SID:$ORACLE_HOME:Y 2. 测试dbstart, dbstop(o ...

随机推荐

  1. 安装字体或直接调用非注册字体 z

    1.安装字体//程序直接将字体文件安装的系统中.函数声明:[DllImport("kernel32.dll", SetLastError = true)] static exter ...

  2. ORACLE不使用工具的情况下获取对象DDL

    set line 200set pagesize 0set long 99999set feedback offset echo off获得表.索引.视图.存储过程.函数的DDL:select dbm ...

  3. March 3 2017 Week 9 Friday

    Each time you love, love as deeply as if it were forever. 如果爱,请深爱,就像能到地老天荒. If we can only encounter ...

  4. OC 成员变量 ( -> 使用 )

    @interface Student : NSObject { // @public // @protected // @private // 默认的作用域是@protected int age; @ ...

  5. POJ-1759 Garland---二分+数学

    题目链接: https://cn.vjudge.net/problem/POJ-1759 题目大意: N个灯泡离地H_i,满足H1 = A ,Hi = (Hi-1 + Hi+1)/2 – 1,HN = ...

  6. Ajax系列之三:UpdatePanel

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/zhanghongjie0302/article/details/35609691           ...

  7. linux shell——zsh的安装与使用

    Shell是在程序员与服务器间建立一个桥梁,它对外提供一系列命令,让我们得以控制服务器.常用的Bash就是Shell的一种,也是Linux下默认Shell程序.这里介绍一种更强大的.更人性化的Shel ...

  8. Going deeper with convolutions(GoogLeNet、Inception)

    从LeNet-5开始,cnn就有了标准的结构:stacked convolutional layers are followed by one or more fully-connected laye ...

  9. node学习笔记(连载)

    这段时间玩了小程序.浏览器插件.koa建站,本来想写几篇文章总结一下的.迫于工作上有新需求要跟进,所以先写写读书笔记吧.公司九点上班,不过弹性工作时间,大家基本上九点半之前到.而我作为渣渣,八点半就到 ...

  10. 使用百度新闻RSS

    function getbaidu() { $result=""; //RSS源地址列表数组 $rssfeed = array("http://news.baidu.co ...