Ubuntu modify the host name and user name display terminal

1, unmodified ago

Format: username @ hostname

such as:

linuxmi@linuxmi

Ubuntu modify the host name and user name display terminal

2, began to modify

Proceed as follows:

a. Modify hostname, the host name to open the file,

linuxmi@linuxmi:~$ sudo vi /etc/hostname

Ubuntu modify the host name and user name display terminal

sudo gedit /etc/hostname

The name changed to linuxmi.com save and exit and re-open a terminal and found the host name has been modified.

b. enter HOME directory

Open: .bashrc file (by modifying the configuration file, you can ensure reboot after the modification is still in force) search string: PS1, find the following snippet: The \ u into \ h, the terminal will display the user name and host name the same:

$ vim ~/.bashrc

Ubuntu modify the host name and user name display terminal

OK, restart the computer.

You can use man bash command to view the bash manual to find the variable supports special characters and these special characters meaning:
  \ d: # represents the date in the format weekday month date, for example: "Mon Aug 1"
  \ H: # Complete the host name.
  \ h: # take only the first host name, in the above example, for the fc4, .linux were omitted
  \ t: # a 24-hour display time format, such as: HH: the MM: the SS
  \ T: Display time # 12-hour format
  \ a: # show time is 24 hour format: HH: MM
  \ U: # current user account name
  \ v: #BASH version information
  \ w: # complete working directory name. Home directory will be replaced by
  \ W: # use basename get working directory name, it lists only the last directory
  \ #: # The first several commands issued
  \ $: # prompt character, if you are root, the prompt is : #, compared with the average user: $

Guess you like

Origin www.linuxidc.com/Linux/2020-01/162067.htm