In Linux, it is necessary to know some basic information before setting the command prompt. 1. environment variable: PS1 (number 1). different Linux versions have different bash values. you can use manbash to find the following information. Www.2cto.com at this time, we should know some basic information before setting command prompt operations in... Linux. 1. environment variable: PS1 (number 1). different Linux versions have different bash values. you can find the following information in man bash. Www.2cto.com now we know that the corresponding statement should be added to that file. As shown in the content in the slice, to make all users take effect, add the following configuration in the last line of the/etc/profile File. if it is for a user, taking my environment as an example, we need to find the directory under the user's home directory. configure the bash_profile file. (the configuration files vary depending on bash. profile, so that the file exists according to your operating system ). If both configurations are configured and the user's personal configuration is used, the public configuration will be overwritten. Www.2cto.com usually has three settings (add the following statement at the end of the/etc/profile file for all users): (1) the command line prompt displays the complete working directory name export PS1 = '[\ u @ \ h $ PWD] \ $' (2) the command line prompt only lists the last Directory export PS1 = '[\ u @ \ h \ W] \ $' (3) the command line prompt displays the complete working directory, the current user directory will ~ Replace export PS1 = '[\ u @ \ h \ w] \ $' and run: source/etc/profile or. /etc/profile (. there is a space behind it). both of them can make the configuration take effect. Command syntax: \ u show current user account \ h show current host name \ W only show current path last directory \ w show current absolute path (current user directory will be ~ Instead) $ PWD: display the current full path \ $ Display the command line '$' or '#' symbol \ #: number of commands issued \ d: represents the date, the format is weekday month date. for example, "Mon Aug 1" \ t: The display time is in the 24-hour format, for example, HH: MM: SS \ T: the display time is in the 12-hour format \ A: The display time is in the 24-hour format: HH: MM \ v: BASH version information. sometimes, in order to know the commands you are currently running, you can also add \ #, for example, export PS1 = '[\ u @ \ h \ w \ #] \ $'. In fact, the above can be freely combined, for example, I like to prompt the day of the week, the number of months, and the bash version number before executing a command, you can add export PS1 = '[\ u @ \ h \ w \ # \ v \ d \ t]' at the end of the/etc/profile file to save the current time and other information. then make it take effect.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.