Hostname

General support questions
User avatar
ultracentos
Posts: 15
Joined: 2017/03/20 20:55:21

Hostname

Post by ultracentos » 2020/01/22 06:11:42

What caused it I don't know!

Hostname suddenly appeared with the directory "Documents" appended at the end. --> [Delano@Gateway-Centos-6.10 Documents]$

I've checked all the host files where hostname is managed, and the hostname reads is as it should read: [Delano@Gateway-Centos-6.10]$

I've tried to get rid of the intruder "Documents" with no success. Are there any ideas out there on how to rid of this intruder ;)

[Moderator: moved post from CentOS 8 forum and deleted duplicate in this one]

User avatar
TrevorH
Forum Moderator
Posts: 27727
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Hostname

Post by TrevorH » 2020/01/22 08:06:07

That looks normal to me. The standard command prompt is set up to display the following:

Code: Select all

[trevor@c6test ~]$ echo $PS1
[\u@\h \W]\$
That's \u = user, \h = hostname, \W = current working directory.

so if you cd then it will put your current working directory back to your home dir and the "Documents" on the end of the command prompt will change to "~".
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
ultracentos
Posts: 15
Joined: 2017/03/20 20:55:21

Re: Hostname

Post by ultracentos » 2020/01/22 17:57:39

I don't believe it's normal, and here is the reason why:

Hoastname -->> [Delano@Gateway-centOS-6]$ Now before a change in the hostname occurs I must cd and pick a directory such as: Documents then
the hostname changes to [Delano@Gateway-centOS-6 Documents]$ now if I cd the hostname returns to [Delano@Gateway-centOS-6]$
There is no reason why Documents or any other directory should appear within the hostname until cd is applied and an directory is chosen. Yes I've used the cd to drop Documents from the hostname i.e.
[hostname Documents]$ cd -->> [hostname]

I'm very curious as to why this happened. Several wierd things occur off and on with this OS, however, I'm greatly satisfied with the distro and do not intend to move from it.

cheers
Just happy to be here :D

cheers


Gateway-centOS-6.10-i686

User avatar
TrevorH
Forum Moderator
Posts: 27727
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Hostname

Post by TrevorH » 2020/01/22 19:15:34

Run echo $PS1 and see if you get the same output as I showed you. If you do then what you are seeing is perfectly normal and in fact is standard on an unmodifed CentOS install. The \W bit of the PS1 sets the latter portion of the command prompt to the last bit of the current working directory (i.e the one you just cd'ed into).

So if you cd ~/Documents then you will see Documents there. If you cd /etc then it will show "etc" then if you cd skel it will show you "skel" and your current working directory will be /etc/skel which is the location of the standard .bash* files that get copied to each user's home directory when the user is created.

The PS1 variable is set from the file /etc/bashrc which is executed when each bash shell starts up.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
ultracentos
Posts: 15
Joined: 2017/03/20 20:55:21

Re: Hostname

Post by ultracentos » 2020/01/22 21:16:46

Below - Documents included with hostname:

[Delano@Gateway-centOS-6 Documents]$ echo $ps1

[Delano@Gateway-centOS-6 Documents]$

///////////////////////////////////////////////////////////////////////////////////////////////////////

Below - Documents removed from hostname:


[Delano@Gateway-centOS-6 Documents]$ cd

[Delano@Gateway-centOS-6 ~]$ echo $ps1

[Delano@Gateway-centOS-6 ~]$

I'm I doing this correctly??
Just happy to be here :D

cheers


Gateway-centOS-6.10-i686

User avatar
TrevorH
Forum Moderator
Posts: 27727
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Hostname

Post by TrevorH » 2020/01/22 22:02:31

It's $PS1 not $ps1. Everything is case sensitive in linux.
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

User avatar
ultracentos
Posts: 15
Joined: 2017/03/20 20:55:21

Re: Hostname

Post by ultracentos » 2020/01/22 22:57:35

[Delano@Gateway-centOS-6 Documents]$ echo $PS1
[\u@\h \W]\$
[Delano@Gateway-centOS-6 Documents]$ cd
[Delano@Gateway-centOS-6 ~]$ echo $PS1
[\u@\h \W]\$

I wonder what that's telling me :-)
Just happy to be here :D

cheers


Gateway-centOS-6.10-i686

Whoever
Posts: 1096
Joined: 2013/09/06 03:12:10

Re: Hostname

Post by Whoever » 2020/01/23 03:48:48

ultracentos wrote:
2020/01/22 22:57:35
[Delano@Gateway-centOS-6 Documents]$ echo $PS1
[\u@\h \W]\$
[Delano@Gateway-centOS-6 Documents]$ cd
[Delano@Gateway-centOS-6 ~]$ echo $PS1
[\u@\h \W]\$

I wonder what that's telling me :-)
What you are missing is the "~" in:

Code: Select all

[Delano@Gateway-centOS-6 ~]$
This tells you that you have set the cd to your home directory. So it is just the same as the example for Documents.

User avatar
ultracentos
Posts: 15
Joined: 2017/03/20 20:55:21

Re: Hostname

Post by ultracentos » 2020/01/23 04:44:33

Whoever wrote:
2020/01/23 03:48:48
ultracentos wrote:
2020/01/22 22:57:35
[Delano@Gateway-centOS-6 Documents]$ echo $PS1
[\u@\h \W]\$
[Delano@Gateway-centOS-6 Documents]$ cd
[Delano@Gateway-centOS-6 ~]$ echo $PS1
[\u@\h \W]\$

I wonder what that's telling me :-)
What you are missing is the "~" in:

Code: Select all

[Delano@Gateway-centOS-6 ~]$
This tells you that you have set the cd to your home directory. So it is just the same as the example for Documents.
Maybe I'm beginning to get-it, but why does "Documents" show in the host name, and not some other Directory such as "Downloads."
Just happy to be here :D

cheers


Gateway-centOS-6.10-i686

User avatar
TrevorH
Forum Moderator
Posts: 27727
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Hostname

Post by TrevorH » 2020/01/23 08:43:31

why does "Documents" show in the host name, and not some other Directory such as "Downloads."
Because you haven't cd'ed to ~/Downloads. If you had then it would.

I think you're missing the point about $PS1 too. It won't change just because you cd to a different directory. The contents of $PS1 tell bash how to format the command prompt. It says [\u@\h \W]\$ which means set the command prompt to a square bracket followed by the username (\u) then an @ sign, followed by the hostname (\h) and a space then the current working directory (\W) and lastly, close off the square brackets and follow it with a dollar sign.

So if you are logged on as user "joe" on host linux101.example.com and you cd /etc then the prompt in your bash screen will say

[joe@linux101 etc]$
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply

Return to “CentOS 6 - General Support”