Home  >  Q&A  >  body text

centos - linux 如何修改 这个机器名 root@localhost

linux(centos6.4) 如何将 root@35dalu 修改 成 root@localhost

[root@35dalu /]# hostname
35dalu.com
[root@35dalu /]#
黄舟黄舟2742 days ago742

reply all(5)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 11:58:59

    The environment variable PS1 under Linux is simply to set the content displayed by the command prompt, as follows:

    root@10.1.1.200:~# 
    

    The meanings of the prompts in the PS1 variable:
    d: represents the date, the format is weekday month date, for example: "Mon Aug 1"
    H: Full host name. For example: My machine name is: fc4.linux, then the name is fc4.linux
    h: Only take the first name of the host, as in the above example, it is fc4, .linux is omitted
    t: Display time in 24-hour format, such as: HH:MM:SS
    T: Display time in 12-hour format
    A: The display time is in 24-hour format: HH:MM
    u: Current user’s account name
    v: BASH version information
    w: The complete working directory name. The home directory will be replaced by ~
    W: Use basename to obtain the working directory name, so only the last directory will be listed
    $: Prompt character. If you are root, the prompt is: #, for ordinary users: $

    vi ~/.bashrc
        export PS1="[\u@localhost \w]$"
    #如果希望立即生效的话
    source ~/.bashrc
    

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:58:59

    Why do you all change the command prompt?
    I usually change it directly /etc/hosts

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:58:59

    /etc/hostnameChange it inside

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:58:59

    PS1='[\u@localhost \W]\$'

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:58:59

    Directly

    hostname localhost
    

    or modify /etc/hostname

    Just log in again after making changes

    reply
    0
  • Cancelreply