0

Until I logged in today, as usual- my bash prompt was the standard "username@currpath # ". But today, for me, it's just "# ". If I login as root, it is normal. bashrc seems fine (as compared to other machines". "echo $PS1" gives me, just "#". What happened, and how do I fix this?

I also noted that "ifconfig" has gone missing. It works for root, yet my $PATH looks normal.

ANOTHER THING (added hours after posting): The up and down arrows used to scroll through the command history. Now they give output like this "^[[A^[[B" (up-then-down), yet my locale and keyboard seem to be set properly. I am not sure if this is related to the prompt issue, but it changed at the same time.

1
  • can you elaborate on ifconfig gone missing? Maybe you logged into different session than you did previously?
    – psukys
    Jul 24, 2014 at 6:36

6 Answers 6

1

I'm guessing there is a problem with your user's .bashrc file.

Try copying the default .bashrc file into your home directory:

cp /etc/skel/.bashrc ~/.bashrc

After copying the file, restart your computer.

1
  • ifconfig is working now, but the prompt is still just "#"
    – lunix
    Jul 24, 2014 at 6:30
1

Seems to be you have messed up with PS1.

http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x157.html

1
  • Yes, it is messed up. But why? How do I get it to stop messing up each boot?
    – lunix
    Jul 24, 2014 at 6:33
0

Perhaps you have changed your user shell from /bin/bash to something else. While logged in under your normal account, run

chsh

And select /bin/bash when prompted.

1
  • You've taught me something- but the correct shell is (was) selected.
    – lunix
    Jul 24, 2014 at 6:31
0

Although I cannot tell you why did this happen (PS1 becoming #), you can simply set up with these special chars:

  • \a : an ASCII bell character (07)
  • \d : the date in "Weekday Month Date" format (e.g., "Tue May 26")
  • \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required.
  • \e : an ASCII escape character (033)
  • \h : the hostname up to the first '.'
  • \H : the hostname
  • \j : the number of jobs currently managed by the shell
  • \l : the basename of the shell’s terminal device name
  • \n : newline
  • \r : carriage return
  • \s : the name of the shell, the basename of $0 (the portion following the final slash)
  • \t : the current time in 24-hour HH:MM:SS format
  • \T : the current time in 12-hour HH:MM:SS format
  • \@ : the current time in 12-hour am/pm format
  • \A : the current time in 24-hour HH:MM format
  • \u : the username of the current user
  • \v : the version of bash (e.g., 2.00)
  • \V : the release of bash, version + patch level (e.g., 2.00.0)
  • \w : the current working directory, with $HOME abbreviated with a tilde
  • \W : the basename of the current working directory, with $HOME abbreviated with a tilde
  • \! : the history number of this command
  • \# : the command number of this command
  • \$ : if the effective UID is 0, a #, otherwise a $
  • \nnn : the character corresponding to the octal number nnn
  • \\ : a backslash
  • \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
  • \] : end a sequence of non-printing characters

Source

4
  • It seems to be setting correctly then being overwritten. But I can't find what is overwriting it.
    – lunix
    Jul 24, 2014 at 6:39
  • does it get overwritten instantly? If so, you might want to check your processes or even try auditing software to check who edits your file.
    – psukys
    Jul 24, 2014 at 6:42
  • Yes, as soon as I can login and start konsole, it's like that (for this user only). Can you recommend some auditing software?
    – lunix
    Jul 24, 2014 at 7:12
  • I'm sorry, I haven't tried any.
    – psukys
    Aug 25, 2014 at 12:26
0

Execution sequence for .bash_profile, .bashrc, .bash_login, .profile and .bash_logout is as follows,

      execute /etc/profile
      IF ~/.bash_profile exists THEN
         execute ~/.bash_profile
      ELSE
        IF ~/.bash_login exist THEN
          execute ~/.bash_login
        ELSE
          IF ~/.profile exist THEN
          execute ~/.profile
          END IF
        END IF
      END IF

To be on the safer side you assign PS1 in all these files. That should certainly solve the issue.

Visit http://www.thegeekstuff.com/2008/10/execution-sequence-for-bash_profile-bashrc-bash_login-profile-and-bash_logout/ for more infomation on this

0

I typed "/bin/bash" and- VIOLA- normalcy. Now- where is the bash (or any) shell invoked at user login? I edited the "passwd" file, that fixed it. I must've modified users in a GUI that deleted the shell setting for a couple of users.

Thanks to all for pointing me in the right direction!

5
  • chsh should've changed your default shell, no?
    – psukys
    Jul 24, 2014 at 12:14
  • That's what I thought, but no. Even though it showed bash as the default, and I later typed in the path when I ran it- it left the passwd file unchanged. That could be because I was running it as a regular user (can't remember now). I don't think I used sudo though. Not sure if it would've mattered. In any case, it's a good thing I looked in passwd, because another user was affected.
    – lunix
    Jul 25, 2014 at 0:16
  • Did you write chsh command only? If so, you needed to specify a user too
    – psukys
    Jul 25, 2014 at 4:25
  • You're right. I didn’t specify a LOGIN (assumed it was for current user). Should have used --help first. Your solution would've worked fine for the user I knew about had I done it right. Seriously, I am appalled by my ignorance!
    – lunix
    Jul 25, 2014 at 14:47
  • Suppoee we have to double check with whoami :D
    – psukys
    Jul 25, 2014 at 15:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .