Solved

Shell prompt Not displaying properly

Posted on 2004-09-14
10
333 Views
Last Modified: 2013-12-06
Hi,
  I am having a slight problem , the shell prompt when i log in does not show the user name or the dir i am presently in , it only show me
 

  bash-2.05b$

Thank you,
Bibin

 
0
Comment
Question by:bibinbhanu
  • 4
  • 3
10 Comments
 
LVL 11

Expert Comment

by:avizit
Comment Utility
you can change the prompts by setting the

PS1 variable
you can put

export PS1="\w> "

in your .bash_profile to have the current working directory on the prompt

similarly
\u for username etc


0
 
LVL 11

Accepted Solution

by:
avizit earned 50 total points
Comment Utility
from ftp://ftp.cwru.edu/pub/bash/FAQ

G5) How do I get the current directory into my prompt?

Bash provides a number of backslash-escape sequences which are expanded
when the prompt string (PS1 or PS2) is displayed.  The full list is in
the manual page.

The \w expansion gives the full pathname of the current directory, with
a tilde (`~') substituted for the current value of $HOME.  The \W
expansion gives the basename of the current directory.  To put the full
pathname of the current directory into the path without any tilde
subsitution, use $PWD.  Here are some examples:

      PS1='\w$ '      # current directory with tilde
      PS1='\W$ '      # basename of current directory
      PS1='$PWD$ '      # full pathname of current directory

The single quotes are important in the final example to prevent $PWD from
being expanded when the assignment to PS1 is performed.

0
 

Author Comment

by:bibinbhanu
Comment Utility
I am not able to find my .bash_profile
0
 
LVL 11

Expert Comment

by:avizit
Comment Utility
try

ls -la  

if you dont have > .bash_profile

then you can create one

vi or emacs .bash_profile    

( in you home directory btw )

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:bibinbhanu
Comment Utility
could anybody send me a sample bash_profile , I am using Red hat 9
0
 
LVL 11

Expert Comment

by:avizit
Comment Utility
there is a sample .bash_profile at

http://www.ccl.net/cca/software/UNIX/oracle/RH6.2-CDPACK/files/bash_profile.shtml
http://www.hccfl.edu/pollock/AUnix1/BashProfile.htm


you need not have such bigones.. just set the values which are necessary to you

0
 
LVL 10

Expert Comment

by:Luxana
Comment Utility
have a look like root to /etc/passwd

what is your deafault shell you should have there somethhing like this:
root:x:0:0:root:/root:/bin/bash
or check your user account last field separated witn ':' is your default shell

also have a look here:
-------------------

/etc/profile
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"

if [ "$BASH" ]; then
  PS1='\u@\h:\w\$ '
else
  if [ "`id -u`" -eq 0 ]; then
    PS1='# '
  else
    PS1='$ '
  fi
fi

export PATH PS1

umask 022
for mor info have a look to man page:

# man bash
---------------------------

luxana

0
 

Author Comment

by:bibinbhanu
Comment Utility
Thanks for all the help ,
  I figured out that I had tried to install a pdf as root which probably was a spy ware or something and ehich may ahve deleted the profile.
  I created a new account and copied all the necessary file to my dir.
  .bashrc
  .bash_profile
      etc...

  :)

Thank you
Bibin
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
This article will explain how to establish a SSH connection to Ubuntu through the firewall and using a different port other then 22. I have set up a Ubuntu virtual machine in Virtualbox and I am running a Windows 7 workstation. From the Ubuntu vi…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now