LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why my terminal starts with bash-4.2$ on fedora 18? (https://www.linuxquestions.org/questions/linux-newbie-8/why-my-terminal-starts-with-bash-4-2%24-on-fedora-18-a-4175485000/)

lmohammeed 11-18-2013 07:59 AM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Dear users
I have got a problem and I need your help.
My terminal starts with bash-4.2$, and I don't know how to restore it back to normal working condition. Please how can I resolve this issue. What should I have done that make the terminal behave in this way? I already visit http://www.linuxquestions.org/questi...me-4175466096/
Your help is highly appreciated.
Regards
Lawal

bigrigdriver 11-18-2013 07:00 PM

Quote:

My terminal starts with bash-4.2$
That appears to be a default bash shell prompt for logged in user (root user prompt would be bash-4.3#).
Quote:

I don't know how to restore it back to normal working condition.
What do you consider to be "normal working condition"?

You can set your prompt be editing your ~/.bashrc file. Look for the PS1 prompt line to edit. To find out what the default PS1 prompt is, as it was when you installed Fedora, look at /etc/bash.bashrc or /etc/skel/.bashrc. Copy the PS1 line and past it into your ~/.bashrc.

For more information on shell prompt, read the Bash Prompt HOWTO.

andrewthomas 11-18-2013 07:39 PM

Quote:

Originally Posted by lmohammeed (Post 5066576)
Dear users
I have got a problem and I need your help.
My terminal starts with bash-4.2$, and I don't know how to restore it back to normal working condition. Please how can I resolve this issue. What should I have done that make the terminal behave in this way? I already visit http://www.linuxquestions.org/questi...me-4175466096/
Your help is highly appreciated.
Regards
Lawal

You probably altered/deleted the .bashrc that shipped with Fedora.

Check in
Code:

/etc/skel/
for .bashrc and .bash_profile and copy them to your home directory.

Code:

lxde@gentoo-asus ~ $ ls -al /etc/skel
total 24
drwxr-xr-x  3 root root 4096 Oct 15 15:55 .
drwxr-xr-x 87 root root 4096 Nov 18 19:21 ..
-rw-r--r--  1 root root  127 Oct 15 15:55 .bash_logout
-rw-r--r--  1 root root  193 Oct 15 15:55 .bash_profile
-rw-r--r--  1 root root  551 Oct 15 15:55 .bashrc
drwx------  2 root root 4096 Dec  8  2011 .ssh


lmohammeed 11-18-2013 10:28 PM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Dear bigrigdriver and andrewthomas,
Thank you for your email.
Quote:

What do you consider to be "normal working condition"?
problem free terminal.
I try to edit /.bashrc using
Code:

vi
but, I got empty "/.bashrc" [New File].
When I run
Code:

cd /etc/skel/
as root user I got
Code:

[root@localhost skel]
, nothing more.
So, now what should I do? Please don't forget I am inexperience.
Waiting for your help.
With kind regards
Lawal

Madhu Desai 11-18-2013 11:04 PM

Quote:

Originally Posted by lmohammeed (Post 5066996)
I try to edit /.bashrc using
Code:

vi
but, I got empty "/.bashrc" [New File].

That's because you are creating new file in root. Try

Code:

vi ~/.bashrc
If its empty, put following lines in
PHP Code:

if [ -/etc/bashrc ]; then
    
. /etc/bashrc
fi 

Also are sure you have not deleted your home directory?

Code:

cd ~
pwd


lmohammeed 11-19-2013 04:01 AM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Dear mddesai,
Thank you for your email.
I try
Code:

vi ~/.bashrc
this only work from root. I got this
Quote:

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

. /opt/intel/bin/compilervars.sh intel64

#------------------------------------------------------------------------
# this is for XCRYSDEN 1.5.21; added by XCRYSDEN installation on
# Tue Apr 17 18:12:32 MYT 2012
#------------------------------------------------------------------------
XCRYSDEN_TOPDIR=/home/mohammed/WIEN2K/XCrySDen-1.5.21-bin-semishared
XCRYSDEN_SCRATCH=/home/mohammed/xcrys_tmp
export XCRYSDEN_TOPDIR XCRYSDEN_SCRATCH
PATH="$XCRYSDEN_TOPDIR:$PATH:$XCRYSDEN_TOPDIR/scripts:$XCRYSDEN_TOPDIR/util"

~
~
~
~
~
~
~
"~/.bashrc" 16L, 591C
What should I do next?
Waiting for respose.

Madhu Desai 11-19-2013 06:32 AM

Quote:

Originally Posted by lmohammeed (Post 5067134)
I try
Code:

vi ~/.bashrc
this only work from root.

This means you have deleted your home directory. As a regular user show your username and /home folder

Code:

$ who am i
$ ls -l /home


lmohammeed 11-19-2013 07:59 AM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Thank you mddesai,
The result of the two command
Code:

bash-4.2$ who am i
mohammed pts/0        2012-01-19 17:08 (:0)
bash-4.2$ ls -1 /home
mohammed
bash-4.2$

Thanks once again in anticipating your responce.
Lawal

Madhu Desai 11-19-2013 08:24 AM

hmmm strange. There is home directory for user 'mohammed', but why you said "vi ~/.bashrc only works from root". besides its not 1(one), but its l(L) in ls -l /home. probably ownership is set wrong. Anyway try again ls -l /home

it show something like this
Code:

drwx------. 64 mohammed mohammed 4096 Nov 19 19:27 /home/mohammed

lmohammeed 11-19-2013 09:21 AM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Thank you mddesai,
Yes, if not from root "vi ~/.bashrc" give "~/.bashrc" [New File]
Sorry for the above mistake.
Code:

bash-4.2$ ls -l /home
total 0
drwx------. 1 mohammed mohammed 1106 Jan 19 18:37 mohammed
bash-4.2$

Thank you so much.
Lawal

Madhu Desai 11-19-2013 09:57 AM

Let me clarify what you are saying...

as root you can open .bashrc, however, as user the .bashrc is NEW file...

In that case, do following...

Code:

su - mohammed
cd /home/mohammed
vi .bashrc

a new empty file will open..

type following:
PHP Code:

if [ -/etc/bashrc ]; then
    
. /etc/bashrc
fi 

then source .bashrc file
Code:

. /home/mohammed/.bashrc
You should get normal prompt.

Note: I assume you know how to enter text in vi editor.

lmohammeed 11-19-2013 10:46 AM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Thank you mddesai,
Quote:

as root you can open .bashrc, however, as user the .bashrc is NEW file...
yes.
I run the codes as you said, typed
PHP Code:

if [ -/etc/bashrc ]; then
                                            
. /etc/bashrc 

                                        fi 

and source .bashrc file in the same terminal. Save and exit using
Code:

:wq!
However, instead of getting normal prompt I got empty prompt. I restart the system, now after several attempt the system would starts and then quickly asked for password again. I have use another computer to reply you.
Thanks once more
Lawal

Madhu Desai 11-20-2013 01:58 AM

Quote:

Originally Posted by lmohammeed (Post 5067329)
and source .bashrc file in the same terminal. Save and exit using
Code:

:wq!

You should save the file first and then source it.

Quote:

Originally Posted by lmohammeed (Post 5067329)
However, instead of getting normal prompt I got empty prompt. I restart the system, now after several attempt the system would starts and then quickly asked for password again. I have use another computer to reply you.

Very strange. The only guess i can do now is that you have seriously messed-up something else. Running /etc/bashrc shouldn't be that dangerous :confused:.

Either replace your /etc/bashrc from the here (post #2) http://fedoraforum.org/forum/showthread.php?t=104297

Or, add following lines to your /home/mohammed/.bashrc file

Code:

export PS1="[\u@\h \W]\$"
export PS2=">"


lmohammeed 11-20-2013 03:04 AM

Why my terminal starts with bash-4.2$ on fedora 18?
 
Thanks you so much mddesai,
Quote:

You should save the file first and then source it.
That really make me a Newbie.
If I get you right, after saving, then I should open the file again using vi editor and then source. Please confirm if I am right, just in case it happens again.
Quote:

Very strange. The only guess i can do now is that you have seriously messed-up something else. Running /etc/bashrc shouldn't be that dangerous .

Either replace your /etc/bashrc from the here (post #2) http://fedoraforum.org/forum/showthread.php?t=104297

Or, add following lines to your /home/mohammed/.bashrc file
I can't remember doing anything unreasonable. Right now my present situation is I got a black screen, with the first line reading
Quote:

[ 1.007510] Problem loading in-kernel X.509 certificate (-129)
and a blinking cursor. If by chance ('cos 'm helpless) the screen comes back I will try your suggestions.
Thanks
Lawal

Madhu Desai 11-20-2013 04:47 AM

Quote:

Originally Posted by lmohammeed (Post 5067719)
If I get you right, after saving, then I should open the file again using vi editor and then source. Please confirm if I am right, just in case it happens again.

No... You got it wrong. Sourcing a script is similar to executing a script on shell. The only difference is that executing a script (with ./ or sh) will execute it in sub-shell, where as sourcing (with . or source) a script will execute it in current shell. So whatever changes you make in .bashrc, and when you source it, the contents of script are executed and are available to you on the same shell you are working on.

To put in simple words...
  1. open vi editor (~/.bashrc)
  2. enter the contents (post #11)
  3. save the file (:wq) (dont open .bashrc again)
  4. And in command prompt just type the following and press <enter>
Code:

$ . ~/.bashrc
Note: Or you can type the following... both are same
Code:

$ source ~/.bashrc
More: What is sourcing a file?


All times are GMT -5. The time now is 01:14 PM.