Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.