rhel7的基本操作(查看IP配置,关闭防火墙,临时或永久关闭selinux,常用命令操作)

* rhel7的基本操作*

1、查看IP配置
[[email protected] ~]# ls /etc/sysconfig/network-scripts/ifcfg-enp0s25
/etc/sysconfig/network-scripts/ifcfg-enp0s25
查看DNS配置
[[email protected] ~]# cat /etc/resolv.conf

Generated by NetworkManager

nameserver 114.114.114.114
查看IP和主机绑定信息
[[email protected] ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
查看主机名
[[email protected] ~]# cat /etc/hostname
admin203

2、关闭防火墙,设置开机不启动
查看状态
[[email protected] ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2018-09-11 09:47:40 CST; 1 day 5h ago
Main PID: 698 (firewalld)
CGroup: /system.slice/firewalld.service
└─698 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Sep 11 09:47:40 admin203 systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 11 09:47:40 admin203 systemd[1]: Started firewalld - dynamic firewall daemon.
关闭防火墙
[[email protected] ~]# systemctl stop firewalld
开启防火墙
[[email protected] ~]# systemctl start firewalld
开机自动启动防火墙
[[email protected] ~]# systemctl enable firewalld
开机自动关闭防火墙
[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

3、临时和永久关闭selinux
查看selinux运行状态
[[email protected] ~]# getenforce
Enforcing
临时关闭selinux,并查看运行状态
[[email protected] ~]# setenforce 0
[[email protected] ~]# getenforce
Permissive
临时开启selinux,并查看运行状态
[[email protected] ~]# setenforce 1
[[email protected] ~]# getenforce
Enforcing
永久关闭selinux,将enforcing改成disabled,保存重启即可
[[email protected] ~]# vim /etc/selinux/config

This file controls the state of SELinux on the system.

SELINUX= can take one of these three values:

enforcing - SELinux security policy is enforced.

permissive - SELinux prints warnings instead of enforcing.

disabled - No SELinux policy is loaded.

SELINUX=disabled

SELINUXTYPE= can take one of three two values:

targeted - Targeted processes are protected,

minimum - Modification of targeted policy. Only selected processes are protected.

mls - Multi Level Security protection.

SELINUXTYPE=targeted

4、基本命令操作
用tty查看当前所属虚拟终端
[[email protected] ~]# tty
/dev/pts/0
用type区分内外命令,语法:type 要检测的命令
[[email protected] ~]# type cat
cat is hashed (/usr/bin/cat)
[[email protected] ~]# type pwd
pwd is a shell builtin
查看所有shell类型
[[email protected] ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
查看一下/etc/passwd的每一行的最后一个字符
[[email protected] ~]# head -1 /etc/passwd
root:x:0:0:root:/root:/bin/bash
查看当前目录下有哪些文件
[[email protected] ~]# ls
anaconda-ks.cfg mima
[[email protected] ~]# ls /etc/passwd
/etc/passwd
查看文件的详细信息,如创建时间,创建者,文件的读写权限
[[email protected] ~]# ls -l /etc/passwd
-rw-r--r--. 1 root root 1118 Sep 11 22:24 /etc/passwd
Linux下快捷键总结
清屏:ctrl+L
退出: ctrl+D
搜素历史命令:ctr+R

查看硬件时间
[[email protected] ~]# hwclock
Wed 12 Sep 2018 04:20:15 PM CST -0.875517 seconds
查看系统时间
[[email protected] ~]# date
Wed Sep 12 16:20:44 CST 2018
修改时间
[[email protected] ~]# date -s "2018-9-12 15:22:30"
Wed Sep 12 15:22:30 CST 2018
查看完整日期
[[email protected] ~]# date "+%F"
2018-09-12
查看年份最后两位
[[email protected] ~]# date "+%y"
18
查看时分秒
[[email protected] ~]# date "+%M"
26
[[email protected] ~]# date "+%H"
15
[[email protected] ~]# date "+%S"
51
查看年月日
[[email protected] ~]# date "+%Y-%m-%d"
2018-09-12
用time测量一个命令运行的时间
[[email protected] ~]# time ls
anaconda-ks.cfg mima

real 0m0.002s
user 0m0.001s
sys 0m0.001s
帮助命令man,查看手册页或命令描述
语法:man 命令
[[email protected] ~]# man cp
查看当前默认的运行级别
[[email protected] ~]# systemctl get-default
multi-user.target
设置默认为第三启动级别
[[email protected] ~]# systemctl set-default multi-user.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
设置默认为第五启动级别
[[email protected] ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

原文地址:http://blog.51cto.com/11293100/2174289

时间: 2024-10-06 21:14:39

rhel7的基本操作(查看IP配置,关闭防火墙,临时或永久关闭selinux,常用命令操作)的相关文章

centos 7 临时和永久关闭Selinux

1. 临时和永久关闭Selinux [[email protected] ~]# getenforceEnforcing [[email protected] ~]# setenforce 0[[email protected] ~]# getenforcePermissive 永久关闭: [[email protected] ~]# vim /etc/sysconfig/selinux SELINUX=enforcing 改为 SELINUX=disabled 重启服务reboot 原文地址:

临时和永久关闭Selinux

临时关闭: [[email protected] ~]# getenforceEnforcing [[email protected] ~]# setenforce 0[[email protected] ~]# getenforcePermissive 永久关闭: [[email protected] ~]# vim /etc/sysconfig/selinux SELINUX=enforcing 改为 SELINUX=disabled 重启服务reboot 原文地址:https://www.

高性能Web服务器Nginx的配置与部署研究(4)Nginx常用命令

1. 启动 Nginx [email protected]:sudo ./sbin/nginx 2. 停止 Nginx [email protected]:sudo ./sbin/nginx -s stop [email protected]:sudo ./sbin/nginx -s quit -s都是采用向 Nginx 发送信号的方式. 3. Nginx 重载配置 [email protected]:sudo ./sbin/nginx -s reload 上述是采用向 Nginx 发送信号的方

CloudEngine 6800基础配置-02_常用命令操作

查看未提交配置 system-view ftp server enable display configuration candidate 删除未提交的配置 clear configuration candidate 配置回退 display configuration commit changes rollback configuration to commit-id 1000000009 查看历史操作记录 display history-command display history-com

Linux系统的相关知识、常用命令及centos 7网卡配置

(本文仅为平时学习记录,若有错误请大佬指出,如果本文能帮到你那我也是很开心啦) 一.Linux系统的相关知识 1.Linux中根目录下所有文件夹的含义和用途(括号内为举例存放的文件) /  根目录 cd /  切换到根目录 / bin  存放可执行文件 /dev  存放设备文件  (网卡 CPU) /media  存放可移除设备文件   (U盘 CD/DVD  VMTools) /opt  存放第三方软件的默认位置 /tmp  存放临时文件  (日志文件) /root  root用户的家目录,主

CentOS 7和CentOS 6如何关闭防火墙

CentOS6.5查看防火墙的状态: $service iptable status显示结果:[[email protected] ~]$service iptable statusRedirecting to /bin/systemctl status  iptable.service● iptable.service   Loaded: not-found (Reason: No such file or directory)   Active: inactive (dead)  --表示防

cetos7的网卡重启及DNS配置,防火墙设置

centos  6   的网卡重启办法   service network reload centos  7 的网卡重启办法    systemctl restart /stop/start network 2.   DNS配置文件:  cat  /etc/resolv.conf 设置主机和IP绑定信息   :cat  /etc/hosts 设置主机名: cat   /etc/hostname 4 防火墙 防火墙1 :iptables   第三方的 防火墙2 : selinux    系统自带的

解决克隆centos虚拟机后ip配置失败的问题

第一步:切换到root用户 #su - 第二步:修改hosts文件 #vi  /etc/hosts 192.168.1.63  datanode63 --多余的内容删除 第三步:修改主机名: #vi  /etc/sysconfig/network 将HOSTNAME修改为:datanode63 NETWORKING=yes HOSTNAME=datanode63 第四步:修改网卡配置  保最后一条网站并网站名称(NAME="eth0")修改为:eth0,其它信息删除 将ATTR(add

centOS 6.5关闭防火墙步骤

关闭命令:  service iptables stop         永久关闭防火墙:chkconfig iptables off 两个命令同时运行,运行完成后查看防火墙关闭状态         service iptables status