← 返回标准版

「Linux」Centos7 基本命令操作

2020年02月02日 07:24

1-3-Linux基本命令操作

本节所讲内容如下:


第1章 Linux终端介绍

1.1 基本概念

crtl+alt+fn ---->n为数字

虚拟终端切换方法

ctrl+shift+t 新建伪终端

Alt + 数字键 终端切换

Alt + F4 关闭终端(可以设置)

crtl+ 等号上面的那个加号 放大字体 crtl+- 是缩小字体

通过网络连接

实际生产中截图如下

通过SHELL,我们可以对LINUX实现哪些操作或管理:

例如:

  1. 对文件的管理(创建、删除、复制、修改)
  2. 对用户的管理(添加、删除)
  3. 相关权限的管理(授权用户对相关文件的管理,比如增删改查)
  4. 对磁盘的管理(分区、raid、lvm)
  5. 对软件的管理
  6. 对网络的管理

2.1 提示符“#”号与“$”号的区别

[root@panda ~]# ---表示是root用户登录,管理员账号登陆

[miao@panda ~]$ ---表示普通用户登录

上面各颜色对应的内容代表的意思如下:

用户名---主机名---当前所在目录(~表示当前用户的家目录)---(# root/$普通用户)

$这个符号后面跟上一个环境变量,可以改变当前环境

2.2 认识Bash Shell

查看所有的SHELL类型

[root@panda ~]# cat /etc/shells

[root@panda ~]# chsh –l

命令格式如下:

命令 【选项】 【参数】


第3章 基本命令操作

3.1 基本命令之--ls

作用:查看当前目录下有哪些文件(list)

语法:ls 目录/文件 ,如果不加目录查看当前目录

常用选项:

上面显示的内容中,

为什么有的目录文件有不同的颜色呢?

linux系统中不同的颜色代表了不同的文件类型


颜 色

代表内容

举 例

蓝色

目录

/etc

黑色

文件

/etc/passwd

浅蓝色

链接

/etc/grub2.cfg

红色

压缩包

boot.tar.gz

绿色

可执行文件

/etc/init.d/network

黑底黄字

设备文件

/dev/sda


3.1.1 别名的使用

定义一个别名:

[root@panda ~]# ls -l /opt

total 912

drwxr-xr-x. 9 1001 1001 4096 May 15 22:21 nginx-1.11.2

-rw-r--r--. 1 root root 924979 May 11 11:21 nginx-1.11.2.tar.gz

drwxr-xr-x. 2 root root 6 Mar 9 2015 rh

drwx------. 3 user4 user2 4096 May 21 08:46 user2

[root@panda ~]# xuegod

bash: xuegod: command not found...

[root@panda ~]# alias xuegod='ls -l /opt'

[root@panda ~]# xuegod

total 912

drwxr-xr-x. 9 1001 1001 4096 May 15 22:21 nginx-1.11.2

-rw-r--r--. 1 root root 924979 May 11 11:21 nginx-1.11.2.tar.gz

drwxr-xr-x. 2 root root 6 Mar 9 2015 rh

drwx------. 3 user4 user2 4096 May 21 08:46 user2

删除别名:

[root@panda ~]# unalias xuegod

[root@panda ~]# xuegod

bash: xuegod: command not found...

设置别名永久生效

--》当前用户

[miao@panda ~]$ echo "alias xuegod='ls -l /mnt'" >> .bashrc

[miao@panda ~]$ . ./.bashrc

[miao@panda ~]$ echo "alias xuegod1='ls -l /mnt'" >> .bashrc

[miao@panda ~]$ . ./.bashrc

[miao@panda ~]$ xuegod1

total 0

drwxr-xr-x 3 root root 30 May 26 21:24 test1

--》全局使用

[root@panda ~]# echo "alias xuegod-1705='ls -ld /opt'" >> /etc/bashrc

[root@panda ~]# source /etc/bashrc

[root@panda ~]# xuegod-1705

drwxr-xr-x. 5 root root 72 May 21 08:31 /opt

[root@panda ~]# su - miao

Last login: Thu Jun 8 21:50:24 CST 2017 on pts/1

[miao@panda ~]$ xuegod-1705

drwxr-xr-x. 5 root root 72 May 21 08:31 /opt


3.2 基本命令之--pwd

作用:打印当前用户所在的当前目录位置(print working directory)

语法:直接输入pwd

[root@panda ~]# man date

适用内部命令


第6章 关机命令

常用的几个关机命令

6.1 关机命令之--shutdown

作用:关机,重启,定时关机

语法:shutdown [选项]

参数:

[root@panda ~]# shutdown -h +10

10分钟之后关机

[root@panda ~]# shutdown -h 23:30

指定具体的时间点进行关机

[root@panda ~]# shutdown -h now

立即关机

[root@panda ~]#shutdown -r 22:22

22:22 以后重启

6.1.1 关机命令之--init 命令

作用:切换系统运行级别

语法:init 0-6

Linux 7个启动级别:

[root@panda ~]# init 0 init 6 init 3 init 5


第7章 定时开机

BIOS

进入bios,一般是在开机后出现主板画面是按Delete这个键,部分品牌机可能按F2或者F1

Power Management Setup,就进入电源管理设置了