LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-16-2009, 05:09 AM   #1
fluxism
LQ Newbie
 
Registered: Jun 2009
Posts: 4

Rep: Reputation: 0
bashrc and root


I have a simple couple of alias` set up on my user account.

alias ls='ls -l --color'
alias .='cd ..'
alias ..='cd ../..'

All well and good!

When I su to root, and ls, I get the normal output shown, and not my desired output long-form with colour.

So I should change the roots .bashrc too right? I tried this too my changing /root/.bashrc and the alias` aren't used.

So which file should I be editing to enable my alias commands for root? I could change the /etc/bashrc file(!?) and it would be changed system wide, but this isnt exactly what I am trying to do!

Any ideas?
 
Old 06-16-2009, 05:10 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 70
/root/.bashrc
 
Old 06-16-2009, 05:20 AM   #3
fluxism
LQ Newbie
 
Registered: Jun 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jamescondron View Post
/root/.bashrc
Indeed, this is what I would of thought too! But is not adding my alias to the ls command, here's my current /root/.bashrc file

Code:
# .bashrc

# User specific aliases and functions

alias ls='ls -l --color'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
I'm running CentOS by the way. ls will just give me the normal output, not the desired one.
 
Old 06-16-2009, 05:24 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
Changes should appear but you will need to log out and login back for changes to take effect.
 
Old 06-16-2009, 05:25 AM   #5
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 70
Well that section in mine looks like:
Code:
if [ -x /usr/bin/dircolors ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    #alias grep='grep --color=auto'
    #alias fgrep='fgrep --color=auto'
    #alias egrep='egrep --color=auto'
fi
(Thats /root/.bashrc)
 
Old 06-16-2009, 05:36 AM   #6
fluxism
LQ Newbie
 
Registered: Jun 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Yep, I tried logging out of root, then back in, and even tried rebooting (windows behavior! ahem). Still no joy though, editing the /root/.bashrc file doesn't add the colour and long form I am after.
 
Old 06-16-2009, 05:42 AM   #7
noctilucent
Member
 
Registered: Jun 2009
Distribution: slackware
Posts: 123

Rep: Reputation: 34
Code:
su -
 
Old 06-16-2009, 06:10 AM   #8
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Yes You have to do su - as to make this bashrc execute while logging
 
Old 06-16-2009, 06:33 AM   #9
fluxism
LQ Newbie
 
Registered: Jun 2009
Posts: 4

Original Poster
Rep: Reputation: 0
Ahh a pesky little -

Thank you all for the help!

 
Old 06-16-2009, 09:11 AM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

I like to setup properly with a '.bash_profile' and a '.bashrc'.

Quote:
~# cat .bash_profile
# .bash_profile
#08-30-06 12:21

# Source .bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

Quote:
~# cat .bashrc
#.bashrc
#08-30-06 12:20

# Add bin to path
export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#08-29-06 11:40 gws

if [ `id -un` = root ]; then
PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
else
PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi
#
# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
# trap 0 rm -f ~$LOGNAME/.bash_history
Yes, once you create the 'bash' files you will have to log out for that user and log back in to have the effects. I would suggest that you add your alias to the above or something along those lines . My reasoning is that you should have good entry and exit for the 'BASH'. Things will be cleaner!

I like to have a colored prompt to differentiate the root from a normal user since I will be using multiple consoles.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Modify .bashrc as root Ukuntu Linux - General 2 04-07-2009 09:58 AM
Problem with root file .bashrc doraimom Debian 2 11-23-2008 08:43 AM
gpm-root can't be run from bashrc? atom Linux - Software 3 08-22-2005 03:27 PM
need root .bashrc .bash_profile darkRoom Slackware 5 04-30-2005 03:24 AM
.bashrc or .profile for root in SuSE jimsee Linux - General 3 11-15-2003 02:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration