Centos7(三)之基本的操作命令

基本的操作命令
1、centos终端
通过 tty 命令看到当前所属的虚拟终端

[root@localhost ~]# tty
/dev/pts/0
[root@localhost ~]# cd /dev/pts
[root@localhost pts]# ls
0 1 2 3 4 ptmx

不同虚拟终端之间通讯

echo nihao > /dev/pts/1

广播,所有终端 都能收到

wall “the system will be shutdown in 10 minutes”

2、认识shell
Shell 俗称壳,它提供了用户与内核进行交互操作的一种接口,它接收用户输入的命令并把它送入内核去执行 Shell 实际上是一个命令解释器,它通过解释用户输入的命令并把它传输给系统内核去执行。
区分内外部命令

[root@localhost /]# type cat
cat 是 /usr/bin/cat
[root@localhost /]# type pwd
pwd 是 shell 内嵌

查看所有shells的类型

[root@localhost /]# cat etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash

3、基本的操作命令

pwd //查看所在的目录

[root@localhost /]# ls -l a.txt
-rw-r–r--. 1 root root 0 12月 13 23:40 a.txt
[root@localhost /]# ll a.txt
-rw-r–r--. 1 root root 0 12月 13 23:40 a.txt

在这里插入图片描述
第一个字符表示的是文件类型:
d:目录文件、 l:链接文件、 b:块设备文件 、c:字符设备文件、 p:管道文件、 -: 表示普通文件
查看隐藏文件

ls -a

只查看目录

ls -d /etc
ls -ld /etc

-S 以文件的大小进行排序

ls -lS /etc

在这里插入图片描述
4、别名的使用(alias)

alias vimens33=‘vi /etc/sysconfig/network-scripts/ifcfg-ens33’
vimens33

产出别名

unalias vimens33

设置永久别名
(只针对root)

vi /root/.bashrc //隐藏文件
alias vimenss33=“vi /etc/sysconfig/network-scripts/ifcfg-ens33” //插入
source /root/.bashrc

在这里插入图片描述
在这里插入图片描述
(全局使用)

vi /etc/bashrc
同理

5、history的使用
ctrl+r >>输入某条命令的关键字>>找出来对应的命令,按右光标键
history>>!数字 //执行历史命令中第 N 条命令

6、快捷键
ctrl + L 清屏
ctrl + R 搜索历史命令
!$ 引用上一个命令的最后一个参数

7、系统时间管理
两种时间

[root@localhost /]# hwclock
2019年12月14日 星期六 00时05分54秒 -10.010855 秒
[root@localhost /]# date
2019年 12月 14日 星期六 00:07:43 CST

-s 把时间设为字符串所描述的时间

[root@localhost /]# date -s “2018-11-2 22:30”
2018年 11月 02日 星期五 22:30:00 CST

[root@localhost /]# date “+%Y%m%d”
20181102

[root@localhost /]# date “+%Y-%m-%d %H:%M:%S”
2018-11-02 22:32:55

time 作用:一般用来测量一个命令的运行时间

[root@localhost /]# time ls -l /etc/
real 0m0.056s
user 0m0.016s
sys 0m0.040s
说明: real:实际使用时间 user:用户状态使用的时间 sys:内核状态使用的时间

8、关机命令(shutdown)

[root@localhost /]#shutdown -h +10 //10 分钟之后关机
[root@localhost /]#shutdown -h 23:30 //指定具体的时间点进行关机
[root@localhost /]#shutdown -r 22:22 #22:22 以后重启
[root@localhost /]#shutdown -c #撤销关机命令

9、启动级别
语法:init 0-6
0 系统停机模式,系统默认运行级别不能设置为 0,否则不能正常启动,机器关的
1 单用户模式,root 权限,用于系统维护,禁止远程登陆,就像 Windows 下的安全模式登录
2 多用户模式,没有 NFS 和网络支持
3 完整的多用户文本模式,有 NFS 和网络,登陆后进入控制台命令行模式
4 系统未使用
5 图形化模式,登陆后进入图形 GUI 模式,X Window 系
6 重启模式,默认运行级别不能设为 6,否则不能正常启动。运行 init 6 机器就会重启

init 0 //关机
init 3 //进入3级别字符界面

设置默认的运行界别
第 3 运行级用 multi-user.target 替代
第 5 运行级用 graphical.target 替代

设置默认第三启动级别

[root@localhost /]# 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.

设置默认第五启动级别

[root@localhost /]# systemctl set-default graphical.target

查看当前级别

runlevel
systemctl get-default

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值