The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Customizing Shell Prompt, HOW?

Discussion in 'General Discussion' started by nitromax, Oct 29, 2003.

  1. nitromax

    nitromax Well-Known Member

    Joined:
    Feb 12, 2002
    Messages:
    189
    Likes Received:
    0
    Trophy Points:
    16
    I know there is a way to customize the shell prompt, and I think it's tweaked in the .bash_profile file? I have tried setting up a .bash_profile file in the /home/user directory but I can't seem to get it to work.

    When I SSH in as root it nicely displays the path like this:

    root@saturn [/home/easyhost]#

    I have several trusted SSH users that would like to customize this. Can anyone give me a pointer that will work? I mainly want to know how change the way the path displays. When a user logs in it just shows this:

    bash-2.05a$

    Any ideas?
     
  2. Phiber_Optick

    Phiber_Optick Member

    Joined:
    Jun 17, 2003
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Florida
    The file you are looking for is .bashrc. It is the shell startup file for bash. (Which appears to be the shell you are using). This file can be configured on a per user basis. It needs to be located in their home dir to set individual settings.

    Depending on your system you may be able to do a "man bashrc" or "info bashrc" to get more info on syntax etc. If not, you may get some info out of "man bash" or "info bash", but a lot of it pertains to shell scripting and not the configs. If you can't find it, I would do a search on google for ".bashrc" and maybe "settings" or something like that. You will turn up the info you are looking for.

    -Ronan
     
  3. nitromax

    nitromax Well-Known Member

    Joined:
    Feb 12, 2002
    Messages:
    189
    Likes Received:
    0
    Trophy Points:
    16
    Thanks for the .bashrc file tip. That was the answer. Here is what I did to get this working so that it would display the full path for any given user.

    Create a .bashrc file in the /home/user directory. Here is what is in mine:

    PATH="/bin:/usr/bin:."
    export PATH
    # Make sure '.' is in PATH

    if [ "`echo $PATH | /bin/grep -E '^\.:|^\.$|:\.:|:\.$'`" ]; then
    PATH="$HOME/bin:$PATH"
    else
    PATH="$HOME/bin:$PATH:."
    fi

    # New files get 640 permissions
    umask 0026

    # Setup terminal if we are on one
    if [ "`/usr/bin/tty`" != 'not a tty' ]; then
    /bin/stty -istrip
    /bin/stty erase ^H
    fi

    # Setup shell variables
    if [ "$SHELL" = '/usr/local/bin/bash' ]; then
    PS1='\u:\w\$ '
    else
    PS1='[$PWD]$ '
    fi
    EDITOR=vi; export EDITOR

    # Aliases
    alias ps='/usr/bin/ps'
    export PATH


    The part that displays the full path at the prompt is the following line:

    PS1='[$PWD]$ '
     
  4. pagedeveloping

    pagedeveloping Well-Known Member

    Joined:
    Jun 11, 2003
    Messages:
    219
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    New York
    It looks like you are using jailshell for this, am I correct?

    For security purposes you can edit the bashrc inside the virtfs folder in home directory.
    home/virtfs/user/etc

    giving some one there own bashrc inside their own directory could encourage them. If you know what I mean..

    better safe than sorry..

    regards,
     
  5. nitromax

    nitromax Well-Known Member

    Joined:
    Feb 12, 2002
    Messages:
    189
    Likes Received:
    0
    Trophy Points:
    16
    Actually I was not using jailshell. But thanks for the nice tip. I'll check that out.
     
Loading...

Share This Page