美文网首页
命令行基础一

命令行基础一

作者: 科举 | 来源:发表于2017-03-02 22:00 被阅读62次

命令行视图

|命令行视图|权限|
|::|::|
|用户视图|查看运行状态或其他参数|
|系统视图|配置设备的系统参数等|
|接口视图|配置接口参数|
|协议视图|配置路由协议|

这些视图模式存在包含关系,必须由上一层视图转换到下一层视图。

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]

退出视图

使用 quit 命令可以退回上一层视图

[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]

也可以使用 return 直接回到用户视图

[Huawei-GigabitEthernet0/0/0]return
<Huawei>

或使用 [ctrl + z] 快捷键退回用户视图

[Huawei-GigabitEthernet0/0/0]
<Huawei>

修改主机名称

<huawei>sysname Router1
<Router1>

命令行快捷键

|快捷键|功能|
|::|::|
|Ctrl+A|把光标移动到当前命令行的最前端|
|Ctrl+E|把光标移动到当前命令行的最后端|
|Ctrl+C|停止当前命令的运行|
|Ctrl+Z|回到用户视图,等同 return 命令|
|Ctrl+]|终止当前连接或切换连接|
|TAB|命令补全|

这些快捷键的命令我们可以通过命令来查看

<Huawei>display hotkey
----------------- HOTKEY -----------------
 
            =Defined hotkeys=
Hotkeys    Command
CTRL_G    display current-configuration
CTRL_L    undo idle-timeout
CTRL_O    undo debugging all
 
           =Undefined hotkeys=
Hotkeys    Command
CTRL_U    NULL
 
            =System hotkeys=
Hotkeys    Function
CTRL_A    Move the cursor to the beginning of the first line
CTRL_B    Move the cursor one character left
CTRL_C    Stop current command function
CTRL_D    Erase current character
CTRL_E    Move the cursor to the end of the Last line
CTRL_F    Move the cursor one character right
CTRL_H    Erase the character left of the cursor
CTRL_N    Display the next command from the history buffer
CTRL_P    Display the previous command from the history buffer
CTRL_W    Delete the word left of the cursor
CTRL_X    Delete all characters up to the cursor
CTRL_Y    Delete all characters after the cursor
CTRL_Z    Return to the user view
CTRL_]    Kill incoming connection or redirect connection
ESC_B    Move the cursor one word back
ESC_D    Delete remainder of word
ESC_F    Move the cursor forward one word

配系统时钟

|命令|功能|
|::|::|
|clock timezone|设置所在时区|
|clock datetime|设置当前时间和日期|

<Router1>clock timezone CST add 08:00:00
<Router1>clock datetime 15:47:00 2017-03-02
<Router1>display clock
2017-03-02 15:47:08
Thursday
Time Zone(CST) : UTC+08:00

配置标题信息

|命令|功能|
|::|::|
|header login|配置在用户登录前显示的标题信息|
|hrader shell|配置在用户登录后显示的标题信息|

[Router1]header login information #
Info: Input banner text, and quit with the character '#'.----------
Warning!
----------
#
[Router1]header shell information #
Info: Input banner text, and quit with the character '#'.----------
Welcome!
----------
#

命令等级

|用户等级|命令等级|名称|
|::|::|::|
|0|0|访问级|
|1|0 and 1|监控级|
|2|0,1 and 3|配置级|
|3-15|0,1,2 and 3|管理级|

<Router1>system-view
[Router1]command-privilege level 3 view user save

用户界面

|用户界面类型|编号|
|::|::|
|Console|0|
|VTY|0-4|

<Router1>system-view
[Router1]user-interface vty ?
  INTEGER<0-4,16-20>  The first user terminal interface to be configured
[Router1]user-interface vty 1 4
[Router1-ui-vty1-4]
  • 默认VTY是 0-5,但是修改后 VTY 最大可配置范围为 0-15
[Router1]user-interface maximum-vty ?
  INTEGER<0-15>  The maximum number of VTY users, the default value is 5

配置登录权限

|命令|功能|
|::|::|
|user privilege|配置指定用户界面下的用户级别|
|set authentication password|配置本地认证密码|

[Router1-ui-console0]authentication-mode password
Please configure the login password (maximum length 16):123456

或者使用另外一种方式

[Router1-ui-console0]set authentication password cipher ?
  STRING<1-16>/<56>  Cipher text password
[Router1-ui-vty0]set authentication password cipher 123456

当我们使用 display current-configuration 命令去查看配置文件,能看到下面的内容

user-interface con 0
authentication-mode password
set authentication password cipher %$%$f;)7"{s`6~#o}m=$LiX9,~W#zlGs8@8se$A:YvQ0
M=>T~W&,%$%$

设置的密码已经使用MD5加密

配置VTY telnet的连接,和console的配置基本上是一致的。但是我们需要指定一个 用户级别 给telnet连接,否则用户使用 telnet 进入系统视图后,很多命令不能执行。

[Router1]user-interface vty 1 4
[Router1-ui-vty1-4]authentication-mode password
Please configure the login password (maximum length 16):123456
[Router1-ui-vty1-4]user privilege level 3

配置用户界面命令

|命令|功能|
|::|::|
|idle-timeout|设置超时时间|
|screen-length|设置指定终端屏幕的临时显示行数|
|history-command max-size|设置历史命令缓冲区的大小|

[Router1-ui-vty1-4]screen-length ?
  INTEGER<0-512>  Display the number of lines on a screen (the value 0 indicates
                  none split screen, and the default value is 24)
[Router1-ui-vty1-4]history-command max-size ?
  INTEGER<0-256>  The size of a history buffer, the default value is 10
[Router1-ui-vty1-4]idle-timeout ?
  INTEGER<0-35791>  Set the number of minutes before a terminal user times out

配置接口IP地址

<Router1>system-view
Enter system view, return user view with Ctrl+Z.
[Router1]interface GigabitEthernet 0/0/0
[Router1-GigabitEthernet0/0/0]undo shutdown
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[Router1-GigabitEthernet0/0/0]ip add 10.1.1.1 24

IP 的子网掩码也可以使用 255.255.255.0 的方式来配置。

配置回环网卡

[Router1]interface LoopBack ?
  <0-1023>  LoopBack interface number
[Router1]interface LoopBack 1
[Router1-LoopBack1]ip address 1.1.1.1 8
[Router1-LoopBack1]quit

查看IP地址

[Router1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 3
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 3
 
Interface                         IP Address/Mask      Physical   Protocol 
GigabitEthernet0/0/0              10.1.1.1/24          down       down     
GigabitEthernet0/0/1              unassigned           down       down     
GigabitEthernet0/0/2              unassigned           down       down     
LoopBack1                         1.1.1.1/8            up         up(s)    
NULL0                             unassigned           up         up(s)

相关文章

  • Ruby基础知识-基础解释

    Ruby基础知识-基础解释 ruby相关的命令行ruby命令行

  • 命令行基础

    命令行基础 命令行是什么? 命令行界面(command-line interface), 缩写CLI, 是在图形用...

  • linux基础命令

    命令行基础 一些名词 「图形界面」 「命令行」 「终端」 「shell」 「bash」 安装使用 Windws: ...

  • Windows相关

    Windows 命令行基础 Windows 的键盘快捷键 wind 命令行工具banbun powershell ...

  • 命令行基础一

    命令行视图 |命令行视图|权限||::|::||用户视图|查看运行状态或其他参数||系统视图|配置设备的系统参数等...

  • 命令行作业

    命令行的基础 常用命令行 图示1.ls 显示文件目录列表

  • linux命令行基础

    linux命令行基础 作为一个前端工程师会基本的命令行是必备的要求 名词 [图形界面] [命令行] [终端] [s...

  • 《AWS 云计算实战》笔记(三)——编写基础架构

    编写基础架构:命令行、SDK 和 CloudFormation 一、基础架构即代码 思想:使用高级编程语言来控制 ...

  • git命令行基础

    命令行基础 图像界面 图形界面 命令行 终端 shell bash 安装使用 windows:安装git,打开gi...

  • VSCode开发Android版本React Native

    基础设备 1. 依赖包 1.1 React Native命令行工具 1.2 SDK 命令行安装 1.3 配置环境变...

网友评论

      本文标题:命令行基础一

      本文链接:https://www.haomeiwen.com/subject/lenkgttx.html