Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the "$" symbol in linux mean?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What does the "$" symbol in linux mean? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

The $in linux, that is, the "command prompt", is where you can enter a command. The command prompt may prompt the current user for some information. Under linux, the user will be prompted for the current directory and the current user.

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

[username@host working directory

In fact, we can customize our own personalized command line prompt, the Linux system prompt is defined by the system variable PS1, as long as we modify the value of the PS1 system variable according to the rules to modify the command line prompt at will.

Use the command echo $PS1 to view the value of PS1, that is, PS1= "[\ u@\ h:\ w\ t]\ $". After changing the value of PS1, the value of PS1 will change back to the default value after rebooting the system or logging back in. 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 command prompt defaults to $PS1. Note: "pmae S" is uppercase.

[root@centos6 ~] # echo $PS1 [\ u @\ h\ W]\ $

In addition to the above default symbols, there are the following special symbols that represent the meaning

\ d: # represents the date in weekday month date format, for example: "Mon Aug 1"\ H: # full host name\ h: # only take the first name of the host\ t: # display time is in 24-hour format For example: HH:MM:SS\ T: # display time in 12-hour format\ A: # display time in 24-hour format: HH:MM\ u: # current user's account name\ v: # BASH version information\ w: # full working directory name\ W: # using basename to get the working directory name, so only the last directory #: # issued a few commands $: # prompt character, if it is root The prompt is: #, while the average user is: $

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

Note: set the color format of the character sequence in PS1 as follows: [\ e [FX Bm "] where" F "is the font color, numbered 30-37, and" B "is the background color, numbered 40-47.

This is the answer to the question about what the "$" symbol in linux means. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report