* 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