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

Centos 7 modify host name

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

Share

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

Centos 7 modify host name

I. the modification order is as follows

Hostnamectl set-hostname web01 (the last web01 is defined as an individual)

If you feel the color is monotonous after modification, you can do the following

Export PS1=' [\ e [34bot 1m] [\ u@\ h\ W]\ $[\ e [0m]

Use the vim editor to insert this command into the last line in .bahsrc (just modify the current account display)

If you want all local accounts to look like this, you can automatically create a .sh file in / etc/profile.d.

Of course, some great gods will ask, this PS1 has many parameters, what u h w W and so on, what font color 30-37

What is the background color with 40-47?

Then I'll move the parameters.

Common parameters and meanings of PS1:

\ d: represents a date in the format of weekday month date, for example: "Mon Aug 1"

\ h: full host name

\ h: take only the first name in the hostname

\ t: display time in 24-hour format, such as HH:MM:SS

\ t: the display time is in 12-hour format

\ a: display time is 24 hours format: HH:MM

\ U: current user's account name

\ v: version information of BASH

\ w: full working directory name

\ W: use basename to get the working directory name and display only the last directory name

#: the number of orders issued

\ $: prompt character. For root users, the prompt is #, and for ordinary users, $

Color setting the format of the character color set in PS1 is:\ [\ e [FX Bm\].\ [\ e [0m\], where "F" is the font color, numbered 30-37, "B" is the background color, numbered 40-47, and\ [\ e [0m\] is the end of the color setting.

Color comparison table:

F B

30 40 black

31 41 Red

32 42 Green

33 43 yellow

34 44 Blue

35 45 purplish red

36 46 turquoise

37 47 White

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