First introduction to Linux "One"

1. $ symbol

The $ in Linux is the "command prompt" where you can enter commands at the end. The command prompt may prompt some information about the current user. In Linux, the user will be prompted for the current directory and the current user. 

When we use the Linux system, what we come into contact with most is its command line window. Many times we need to enter commands on the command line. There will be a prompt before the entered command. Generally, the default prompt form of the system is:

[username@host 工作目录

In actual development environment, the $ symbol is used as follows: 

2. mkdir 

Permissions under Linux are extremely strict. If it is not in the home directory, you do not have permission to create a directory.


 

 Not finished, to be continued

3. Supplement 

We can customize a personalized command line prompt for ourselves. The Linux system prompt is defined by the system variable PS1. As long as the value of the PS1 system variable is modified according to the rules, the command line prompt can be modified at will.

Check the value of PS1 through the command echo $PS1, that is, PS1=[command return content]. After modifying the value of PS1, restarting the system or logging in again, the value of PS1 will return to the default value. If you want to permanently save the value of PS1 for the user, you can re-import the new value of the system variable PS1 by modifying the user profile .profile:

The default command prompt is $PS1. Note: "P, S" is capitalized

[bypayapp@vpp003-035 ~]$ echo $PS1

[\u@\h \W]\$

In addition to the above default symbols, there are also the meanings represented by the following special symbols:

\d :#代表日期,格式为weekday month date,例如:"Mon Aug 1"
\H :#完整的主机名称
\h :#仅取主机的第一个名字
\t :#显示时间为24小时格式,如:HH:MM:SS
\T :#显示时间为12小时格式
\A :#显示时间为24小时格式:HH:MM
\u :#当前用户的账号名称
\v :#BASH的版本信息
\w :#完整的工作目录名称
\W :#利用basename取得工作目录名称,所以只会列出最后一个目录
#:#下达的第几个命令
$ :#提示字符,如果是root时,提示符为:# ,普通用户则为:$

For example, add a 24-hour format time to the command prompt and add a color to the prompt.

Note: The format for setting character sequence color in PS1 is: [\e[F;Bm"] where "F" is the font color, numbered 30-37, "B" is the background color, numbered 40-47.

Guess you like

Origin blog.csdn.net/weixin_52255395/article/details/130720436