You are not logged in.

#1 2024-01-21 01:19:08

Mantoba
Member
Registered: 2024-01-21
Posts: 17

My '$HOME' variable is being set with a trailing slash.

I recently switched over to arch and I'm loving how quick it is. but I have started noticing a problem that is a little bothersome.

When I log in, my '$HOME' variable get set to '/home/me/' instead of '/home/me'.

This has the undesirable effect of listing my full working directory in my prompt when I'm in my home directory.  When you first log in, it displays my working directory as '~/', but just typing 'cd' makes the prompt list the full home directory '/home/me'. 

Logging in and echoing '$HOME' shows the trailing '/'.  A simple test was to manually change the $HOME variable to my home directory without a trailing '/', and the prompt started to behave.

What sets the '$HOME' variable?  Can I fix this without re-defining my '$HOME' variable in my '.profile'?

For some reason, when I log into root and echo '$HOME' it isn't listed with a trailing slash.

Offline

#2 2024-01-21 01:33:41

Mantoba
Member
Registered: 2024-01-21
Posts: 17

Re: My '$HOME' variable is being set with a trailing slash.

Ok, after more searching, it looks like '$HOME' is set from the '/etc/passwd' file.  Which means the entries were populated by the program 'useradd'.

Simple fix was to just edit the '/etc/passwd' file.

Thanks anyway.

Offline

#3 2024-01-21 01:40:28

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,642

Re: My '$HOME' variable is being set with a trailing slash.

Mantoba wrote:

Simple fix was to just edit the '/etc/passwd' file.

Really?  Simple is not the adjective I'd choose.  Dangerous or Ballsy, perhaps.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#4 2024-01-21 01:57:50

andyturfer
Member
Registered: 2021-01-08
Posts: 106

Re: My '$HOME' variable is being set with a trailing slash.

Strange. My $HOME doesn't have the trailing slash:

[andy:l7] ~ $ echo $HOME
/home/andy

Offline

#5 2024-01-21 10:57:43

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: My '$HOME' variable is being set with a trailing slash.

Always remember to use pwck(8) after editing /etc/passwd. You shouldn't ever have to edit that file manually but I presume an incorrect option was entered for useradd(8) when creating the new user.

I thought the perhaps pwck(8) would fix a mistake like that but it doesn't so in this case a manual edit was needed.


Jin, Jîyan, Azadî

Offline

#6 2024-01-23 21:47:10

Mantoba
Member
Registered: 2024-01-21
Posts: 17

Re: My '$HOME' variable is being set with a trailing slash.

Head_on_a_Stick wrote:

Always remember to use pwck(8) after editing /etc/passwd. You shouldn't ever have to edit that file manually but I presume an incorrect option was entered for useradd(8) when creating the new user.

I thought the perhaps pwck(8) would fix a mistake like that but it doesn't so in this case a manual edit was needed.


You're right.  I was able to track down where it originated.  It was me using the '-d' option of 'useradd' with tab completion.  It didn't remove the trailing slash before adding it to the passwd file.

And for the record, I'm smart enough to always make a copy of the file I'm editing, before editing. wink  But I do see the need to let others know not to directly edit the '/etc/passwd' file.

Was not aware of 'pwck', ty.

Offline

Board footer

Powered by FluxBB