


1. The concept of command
-
Execution process of command
When the system executes an external command for the first time The hash cache table is empty. The system will first search for the command from the PTAH path. After finding it, the path will be added to the Hasa cache. When the command is executed again, it will be executed directly from the hash path. If it exists, it will be executed directly. If it does not exist, it will be executed directly. The search will continue from the path under PATH, and the Hash table can improve the calling rate of the command.
-
Priority of command
alias -------------------------- ----------------Alias
builtin-------------------------------- -Internal command
ˆ ˆhash-------------------------Cache table
ˆ ˆˆˆˆhash-------------------------- ----Executable program or script (external command) -
Internal command and external command
The internal command is the shell’s own
External commands are installed by default when installing the system, and have corresponding paths in the file system -
Check whether the command is an internal command or an external command
type [commnd ]
[root@centos6 ~]# type cat #判断cat命令,外部命令显示文件路径 cat is /bin/cat [root@centos6 ~]# type cd #判断cd命令 cd is a shell builtin
2. Command alias
The named alias is only valid in the current process
If you want it to be permanently valid, it must be defined in the configuration file
Only for the current user: ~/.bashrc
Valid for all users: /etc/bashrc -
View all aliases in the process
alias
[root@centos6 ~]#alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' ......
-
Define alias
alias NAME="VALUE"
[root@centos6 ~]#alias aubin=cat [root@centos6 ~]#aubin test hello world
-
Delete alias
[root@centos6 ~]#unalias aubin [root@centos6 ~]#aubin test -bash: aubin: command not found
-
Define the alias that is permanently effective for the current user
[root@centos6 ~]#vim .bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' alias aubin=cat #
-
Definition The alias that is effective for the specified user
[root@centos6 ~]#cd ~ li [root@centos6 li]#vim .bashrc #编辑用户目录下的.bashrc
-
DefinitionAll usersEffective aliases
[root@centos6 ~]#vim /etc/bashrc alias aubin=cat # <hr><h1 id="Internal-commands">3. Internal commands</h1>
The shell program finds the executable program or code corresponding to the typed command. After analysis by the shell, it is submitted to the kernel to allocate resources and run it.
-
View all internal commands
[root@centos6 ~]#help
[root@centos6 ~]#enable enable . enable : enable [ enable alias enable bg enable bind ......
-
Disable and enable internal commands
enable
[root@centos6 li]#enable -n cd #禁用内部命令 [root@centos6 li]#enable cd #启用内部命令
-
Disable internal commandsInvalid
[root@centos6 li]#enable -n pwd [root@centos6 li]#enable -n #查看禁用的内部命令或如下图用help enable -n pwd
You can also check the disabled commands by
help
【*# before the command ##Represents that the command has been used】
Disables the internal command
enable -n pwdcan still be used
[root@centos6 li]#pwd /home/li
Usewhich
to view the command The executable file
[root@centos6 li]#which pwd /bin/pwd
When the internal command is disabled, continue to search the Hash table and\(PATH. Until the /bin/pwd# is found in \)PATH according to the bash priority. ##'s executable file will run it.
View disabled internal commands -
[root@centos6 li]#enable -n enable -n cd enable -n pwd
Or use the
helpcommand as shown above
is used to display and clear the hash table. When executing the command, the system will first query the hash table.
- View the command cache
- hash
<pre class="brush:php;toolbar:false">[root@centos6 ~]# hash hits command 3 /usr/bin/cal 1 /usr/bin/yum</pre> <pre class="brush:php;toolbar:false">[root@centos6 ~]# 查看详细的Hash表 [root@centos6 ~]#hash -l builtin hash -p /bin/dd dd builtin hash -p /usr/bin/yum yum</pre>
Add content to the Hash table - hash - p path command
<pre class="brush:php;toolbar:false">[root@centos6 ~]#将cat定义一个别名存在hash表 [root@centos6 ~]#hash -p /bin/cat aubin [root@centos6 ~]#aubin test hello world</pre>
Print the path of the command in the Hash table - hash -t command
<pre class="brush:php;toolbar:false">[root@centos6 ~]#hash -t aubin /bin/cat</pre>
Delete Specify the command in the Hash table - hash -d command
<pre class="brush:php;toolbar:false">[root@centos6 ~]#hash -d aubin</pre>
Delete all commands in the Hash table - hash -r
<pre class="brush:php;toolbar:false">[root@centos6 ~]# hash -r</pre>
View the path of the command - which
5. External command<pre class="brush:php;toolbar:false">[root@centos6 ~]# which cat #查看命令的路径,以第一个路径为准 /bin/cat [root@centos6 ~]# which -a cat #查看命令所有路径,一个命令可能有多个路径 /bin/cat /usr/local/bin/cat</pre>
The external command is an executable file. When executed When issuing an external command, the system will execute the corresponding executable file in the file directory. List the path of the command -
[root@centos6 /]#which echo #列出命令的路径 /bin/echo
[root@centos6 /]#which cp #which列出文件路径会显示别名 alias cp='cp -i' /bin/cp [root@centos6 /]#which --skip-alias cp #列出文件路径而不显示别名 /bin/cp
List all the paths of the command. When multiple bash have the same command, the command has Multiple paths. -
[root@centos6 /]#which -a echo /bin/echo
List the paths to commands and help manuals -
[root@centos6 /]#whereis echo echo: /bin/echo /usr/share/man/man1/echo.1.gz /usr/share/man/man1p/echo.1p.gz
The above is the detailed content of Basic command classification of LInux system operation explanation. For more information, please follow other related articles on the PHP Chinese website!

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

手机远程linux工具有:1、JuiceSSH,是一款功能强大的安卓SSH客户端应用,可直接对linux服务进行管理;2、Termius,可以利用手机来连接Linux服务器;3、Termux,一个强大的远程终端工具;4、向日葵远程控制等等。

在linux中,rpc是远程过程调用的意思,是Reomote Procedure Call的缩写,特指一种隐藏了过程调用时实际通信细节的IPC方法;linux中通过RPC可以充分利用非共享内存的多处理器环境,提高系统资源的利用率。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function