🔥初识shell

一:shell

1.什么是xshell?

  • shell中文的意思是贝壳,寓意类似内核对的壳,shell是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核的服务,简而言之就是只要能够操作应用程序的接扣都能称为SHELL。狭义的shell指的是命令行方面的的软件,广义的SHELL则包括图形界面。

 

  • shell是一个用C语言编写的程序,它是用户使用linux的桥梁。shell即使一种命令语言,又是一种程序设计语言。

所以说,shell可以指代两层意思:

python语言<==============>shell命令

python解释器<============>shell解释器

操作系统<===============>操作系统

计算机硬件<==============>计算机硬件

        

          2.shell脚本

        

 3.GNU bash

 posix:

        

 二、shell交互式环境

登录用户后进入解释器bash的交互环境,可以敲命令,交互式的命令如下

 三、shell命令语法

三部分组成

  • 命令:要执行的操作(必选)
  • 选项:如何具体执行操作,通常以-,--,+开头(可选)
  • 参数:具体操作的对象(可选)

        例1

ls
ls /root/
ls -l /root

  例2

[root@localhost ~]# date
2020年 08月 12日 星期三 16:13:08 CST
[root@localhost ~]# date +%F
2020-08-12
[root@localhost ~]# date -s 16:14:00
2020年 08月 12日 星期三 16:14:00 CST
[root@localhost ~]# date -s "2022-11-11 11:11:11"
2022年 11月 11日 星期三 11:11:11 CST

  例3

[root@123 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core) [root@123 ~]# uname -r
3.10.0-1127.13.1.el7.x86_64
[root@123 ~]# uname -m
x86_64
[root@123~]# uname -a
Linux 123.xxx.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38
UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@123~]#

四、bash解释器特性

      1.命令和文件自动补全 注意:Tab只能补全命令和文件

[root@localhost ~]# ls /etc/sysconfig/network-scripts/ifcfg-ens33

  2.快捷键

Ctrl+c    终止前台运行的程序
Ctrl+d 退出==exit
Ctrl+l 清屏
Ctrl+a 光标移动到命令行的最前端
ctrl+e 光标移动到命令行的后端
Ctrl+r 搜索历史命令,利用关键词
alt+. 引用上一个命令的最后一个参数

  3.历史命令

 4.别名

 五、命令查找优先级

 六、查看帮助信息

 七、常用命令

设计主机名

[root@123]# hostnamectl set-hostname aliyun // 退出重新进入即可看到

  设置时间

[root@123 ~]# date --help

  

 重启

shutdown -r 10 // 10分钟后重启
shutdown -r 0 // 立即重启
shutdown -r now // 立即重启
init 6 // 立即重启
reboot //立即重启 

  关机

shutdown -h 10 // 10分钟后关机
shutdown -h 0 // 立刻关机
shutdown -h now // 立刻关机
halt // 立刻关机
poweroff // 立刻关机

  取消正在进行的关机或重启

showdown -c

  注销登录账号

exit
logout
ctrl+d

  

原文地址:https://www.cnblogs.com/ChuangShi-HolySpirit/p/13843130.html