Results 1 to 4 of 4

Thread: terminal users are green, root is red

  1. #1
    Join Date
    Feb 2009
    Beans
    154
    Distro
    Ubuntu Development Release

    terminal users are green, root is red

    if you have not noticed, this is my ubuntu master thesis....
    http://ubuntuforums.org/showthread.php?t=1836890
    check it out and share it with your friends =)

    idea (and a good majority of the code) stolen from linux from scratch


    alt + f2
    run
    "gnome-terminal"

    Code:
    cat >> $HOME/.bashrc << "EOF"
    # linux from scratch terminal colors
    NORMAL="\[\e[0m\]"
    RED="\[\e[1;31m\]"
    GREEN="\[\e[1;32m\]"
    if [[ $EUID == 0 ]] ; then
      PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
    else
      PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
    fi
    #end of linux from scratch color modifications
    EOF
    your going to need to run this as your users if you have any besides the main user.

    Code:
    sudo su
    enter password

    then again drop this block of code.

    Code:
    cat >> $HOME/.bashrc << "EOF"
    # linux from scratch terminal colors
    NORMAL="\[\e[0m\]"
    RED="\[\e[1;31m\]"
    GREEN="\[\e[1;32m\]"
    if [[ $EUID == 0 ]] ; then
      PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
    else
      PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
    fi
    #end of linux from scratch color modifications
    EOF
    then drop this script to make all future users green / red mode to constantly remind you to log out of root

    Code:
    cat >> /etc/skel/.bashrc << "EOF"
    # linux from scratch terminal colors
    NORMAL="\[\e[0m\]"
    RED="\[\e[1;31m\]"
    GREEN="\[\e[1;32m\]"
    if [[ $EUID == 0 ]] ; then
      PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
    else
      PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
    fi
    #end of linux from scratch color modifications
    EOF
    exit
    press enter to exit root mode and then restart your terminals or run

    Code:
    source $HOME/.bashrc
    http://www.linuxfromscratch.org/blfs...s/profile.html
    source the code was stolen and modified from.

    Last edited by boblizar; October 21st, 2011 at 08:43 AM.

  2. #2
    Join Date
    Jan 2009
    Location
    Flanders
    Beans
    Hidden!

    Re: terminal users are green, root is red

    in what format are the colors? I would like a darker green since I use a white background. But I don't see what kind of encoding is used for the colors.

    btw: linux mint uses this too.

  3. #3
    Join Date
    Apr 2006
    Location
    Montana
    Beans
    Hidden!
    Distro
    Kubuntu Development Release

    Re: terminal users are green, root is red

    Thread moved to General Help.

    Not really a security question.

    See also:

    http://www.cyberciti.biz/tips/howto-...up-prompt.html

    https://wiki.archlinux.org/index.php/Color_Bash_Prompt
    There are two mistakes one can make along the road to truth...not going all the way, and not starting.
    --Prince Gautama Siddharta

    #ubuntuforums web interface

  4. #4
    Join Date
    Feb 2009
    Beans
    154
    Distro
    Ubuntu Development Release

    Re: terminal users are green, root is red

    well windows 7 decided changing its partition size would be fun... tested this script as a user = functioning... sudo su then dropped script again, again functioning properly =)

    i also updated from 10.10 to 11.04 (and had to recompile my own emerald from git to get it to work) but other than that 11.04 works....

    you can drop the script, and if you dont like the colors you can remove the script.... its written to .bashrc at the end with ## comments to define the manipulated text.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •