Creating new user, inconsistent bash prompt

7,270

It looks like kitty's shell is /bin/sh. This is a shell that's intended for scripting, it doesn't support fancy prompts, completion, command line edition and other interactive features. Change kitty's shell to /bin/bash:

chsh -s /bin/bash kitty
Share:
7,270

Related videos on Youtube

denuviel
Author by

denuviel

Updated on September 18, 2022

Comments

  • denuviel
    denuviel over 1 year

    I've created a new user profile with:

        useradd kitty
        passwd kitty
        mkdir kitty
        chmod 0700 kitty
        chown -R kitty:kitty
        adduser kitty sudo
    
        #when I did it I initially didn't notice I'm using two different commands,
        #hence the inconsequence, but as I've read up there are interchangeable anyway,
        #just listing it in case it actually makes any difference
    

    I've also created a .bashrc file in kitty's home folder, with the contents of:

       export PS1='[\u@\h \w] '
    

    Initially tab completion didn't work, and the prompt for kitty was a standard $ sign, and altough I've tampered with /etc/profile /etc/bash.bashrc /etc/bash_completion and created .bashrc in the home directory for both my main user and kitty, I've ended up reversing all the changes, and only leaving the .bashrc file in the kitty's home directory. So I guess it was the restart that resolved these isssues (sic.).

    The problem now is: when I log in as kitty in the terminal window on my main profile, the prompt appears such as my main profile's, with all the formatting (color/boldness), but when I log in as kitty her native bash prompts have standard formatting. Why?

    EDIT: as I've noticed there is also a slight difference in the content of prompt, the one on my main profile being followed by a $ sign and kitty's lacking the $ sign and being enclosed in square brackets.

    I switch between profiles using sudo login and exit in the terminal window. When I log in as kitty at the start of the system, in the terminal it switches between the colored (logged as my main user) and standard (kitty's) one. If at the start of the system I log in as my main user it colors both (kitty's and main user's) in the same manner.

    • geirha
      geirha over 10 years
      In the future, use adduser kitty rather than useradd kitty. adduser will create the homedir with proper ownership and permissions and all that; based on the config in /etc/adduser.conf.
    • h3.
      h3. over 10 years
      Given your latest edit, this is how I understand your question: you log in with your usual account and open a terminal window. You run the command sudo login and log in as kitty. You then get a shell with a colored prompt, which is surprising since nothing in kitty's profile says that the prompt should be colored. Is this correct?
    • h3.
      h3. over 10 years
      Have you changed /etc/bash.bashrc? Post the output of the following commands after sudo login as kitty: whoami; echo ~; echo "$PS1"; echo "$PROMPT_COMMAND"; cat ~/.bashrc
    • denuviel
      denuviel over 10 years
      I've checked for both cases, whoami returns kitty, echo ~ /home/kitty, $PROMPT_COMMAND comes back empty, cat ~/.bashrc returns export PS1='[\u@\h \w] '. The only difference is when I log in with kitty's account: [kitty@denuviel-Satellite-L650 ~] echo "$PS1" [\u@\h \w] and when I log in with denuviel's account kitty@denuviel-Satellite-L650 ~ $ echo "$PS1" ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033‌​[01;34m\] \w \$\[\033[00m\] So why does it assume different values of $PS1?
  • denuviel
    denuviel over 10 years
    I did change it, it indeed was /bin/sh initially, but it didn't make any difference, I've checked it is actually /bin/bash now by printing out the $SHELL
  • h3.
    h3. over 10 years
    @denuviel Depending on how you change to the kitty account, the value of $SHELL may be carried over from your session. What does getent passwd kitty say?
  • denuviel
    denuviel over 10 years
    kitty:x:1001:1001::/home/kitty:/bin/bash
  • h3.
    h3. over 10 years
    @denuviel Ok then. Please edit your question to explain how you log in as kitty (in the GUI login screen? over SSH?), how you start a shell, and copy-paste a prompt.
  • denuviel
    denuviel over 10 years
    edit:transferred the comment to the main question
  • denuviel
    denuviel over 10 years
    right, but then why doesn't it make use of it when on my main profile? And displays a colored one instead? It's this inconsistency I don't get.
  • h3.
    h3. over 10 years
    @denuviel What do you mean by “when on my main profile”? Describe exactly what you do to obtain this different result. Copy-paste what you typed (did you use su or sudo at some point? Copy-paste that command, and everything else you did) and what you saw (prompts, messages, etc.).
  • denuviel
    denuviel over 10 years
    I've included everything in my question. At login screen I log in either as denuviel (my main profile) or kitty (my test profile), after that I use 'sudo login' and 'exit' to switch between profiles in the terminal window, and depending on who am I generally logged in as, I obtain different results afterwards (no differentiation between prompts on denuviel's profile, and employing .bashrc on kitty's one)
  • denuviel
    denuviel over 10 years
    I've learnt a lot and there is an answer to my badly specified question (why does the prompt not get colors) so I'm marking this as solved. Thank you for your patience.