Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Why the home directory is not ~ anymore in Debian 9

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
zhiyizhi
Posts: 25
Joined: 2008-09-07 07:45

Why the home directory is not ~ anymore in Debian 9

#1 Post by zhiyizhi »

In Debian 8, the tilde ~ denotes the home directory. But in 9, it seems that the home directory is just itself. So, how can I configure such that the home directory is denoted by ~, just as in Debian 8? Below is part of my ~/.bashrc file:

Code: Select all

if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
	 PS1="[\$(date +%m/%d/%Y),\t@\w]\$ "
else
    #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
	 PS1="[\$(date +%m/%d/%Y),\t@\w]\$ "
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    #PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    PS1="[\$(date +%m/%d/%Y),\t@\W]\$ "

User avatar
orythem27
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

#2 Post by orythem27 »

Please post the output of the following commands.

Code: Select all

/bin/ps u -p $$
echo $HOME
cd ~; pwd
zhiyizhi wrote:But in 9, it seems that the home directory is just itself.
Please supply an example.

zhiyizhi
Posts: 25
Joined: 2008-09-07 07:45

Re: Why the home directory is not ~ anymore in Debian 9

#3 Post by zhiyizhi »

The output is below:

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
xxxyyy 9349 0.0 0.0 26996 3420 pts/5 Ss+ 16:10 0:00 bash
/home/lovelinux/
/home/lovelinux

Can you tell me what the function of these commands is?

User avatar
orythem27
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

#4 Post by orythem27 »

zhiyizhi wrote:USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
xxxyyy 9349 0.0 0.0 26996 3420 pts/5 Ss+ 16:10 0:00 bash
So you are indeed using bash, not other shells, which means you should get tilde expansion on ~.
I assume that "xxxyyy" is the same string as "lovelinux", which is your actual username.
zhiyizhi wrote:/home/lovelinux/
/home/lovelinux
So when you execute `cd ~`, it indeed goes to your home folder. So the bash tilde expansion is working. Can you provide an example that makes you think "the home directory is not ~ anymore"?

wertz
Posts: 6
Joined: 2017-06-25 21:16

Re: Why the home directory is not ~ anymore in Debian 9

#5 Post by wertz »

on KDE, ~ goes to home folder,, but on MATE and Xfce ~ just stays on the same directory(or somewhere else but not home)

zhiyizhi
Posts: 25
Joined: 2008-09-07 07:45

Re: Why the home directory is not ~ anymore in Debian 9

#6 Post by zhiyizhi »

In Debian 9, the appearance of Mate-terminal is like this:

Code: Select all

[06/26/2017,21:43:41@/home/lovelinux]$ cd Desktop/
[06/26/2017,21:43:49@/home/lovelinux/Desktop]$ cd /
[06/26/2017,21:43:53@/]$ pwd
/
[06/26/2017,21:43:55@/]$ cd ~/Desktop/
[06/26/2017,21:44:00@/home/lovelinux/Desktop]$ 
But I want it to be as this:

Code: Select all

20:45:02@~ $ pwd
/home/lovemint
20:45:06@~ $ cd Desktop/
20:45:09@~/Desktop $ ls
20:45:14@~/Desktop $ pwd
/home/lovemint/Desktop
20:45:15@~/Desktop $ cd /
20:45:37@/ $ pwd
/
20:45:37@/ $ 
That is to say, I want terminal not to replace the tilde to $HOME. How can I set ~/.bashrc in Debian 9, so that it is really what I want.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Why the home directory is not ~ anymore in Debian 9

#7 Post by dasein »

First you say:
zhiyizhi wrote:So, how can I configure such that the home directory is denoted by ~
But then you turn around and say:
zhiyizhi wrote:I want terminal not to replace the tilde to $HOME.
So, your two goals are mutually exclusive. It's not surprising that everyone's confused.

Good luck.

User avatar
orythem27
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

#8 Post by orythem27 »

zhiyizhi wrote:In Debian 9, the appearance of Mate-terminal is like this:
[06/26/2017,21:43:41@/home/lovelinux]$ cd Desktop/

But I want it to be as this:
20:45:02@~ $ pwd

That is to say, I want terminal not to replace the tilde to $HOME
Arghhh, it took me ~5 minutes to get your point. So you would like to see "~" instead of "/home/lovelinux" in your bash prompt, which should be the normal behaviour according to the documentation. Is this correct?

If this is the case, there are numerous possibilities that could cause the tilde abbreviation to fail in PS1. One of them is that you have a erratic HOME variable. A quick search reveals several cases:
http://gnu-bash.2382.n7.nabble.com/bug- ... td680.html
https://unix.stackexchange.com/question ... 1-variable
https://bugs.debian.org/cgi-bin/bugrepo ... bug=859384

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Why the home directory is not ~ anymore in Debian 9

#9 Post by dasein »

orythem27 wrote:Arghhh, it took me ~5 minutes to get your point. So you would like to see "~" instead of "/home/lovelinux" in your bash prompt...
(1) Kudos to you, orythem27, for figuring it out at all.

(2) @OP -> All this drama and effort... for a bash prompt? Seriously? You need better hobbies.

User avatar
orythem27
Posts: 252
Joined: 2017-05-11 07:59
Location: P.R. China

Re: Why the home directory is not ~ anymore in Debian 9

#10 Post by orythem27 »

zhiyizhi wrote:The output is below:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
xxxyyy 9349 0.0 0.0 26996 3420 pts/5 Ss+ 16:10 0:00 bash
/home/lovelinux/
/home/lovelinux
According to the links above, the problem is that you have an extra trailing slash in your HOME variable, which could be wrongly set in /etc/passwd or bashrc.
dasein wrote:(1) Kudos to you, orythem27, for figuring it out at all.
Thanks. :) I guess OP has been giving the forum members a hard time by not emphasizing "PS1" or "prompt", but I totally overlooked that OP had already mentioned setting PS1 in the opening post. :roll:

zhiyizhi
Posts: 25
Joined: 2008-09-07 07:45

Re: Why the home directory is not ~ anymore in Debian 9

#11 Post by zhiyizhi »

I have solved the problem, by using the method suggested in the thread https://unix.stackexchange.com/question ... 1-variable. I have deleted the redundant slash after the Home directory in /etc/passwd. Of curiosity is that why there is not such a problem in Debian 8, while it is in Debian 9?

Post Reply