LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-16-2006, 04:54 AM   #1
simopal6
Member
 
Registered: Jun 2006
Location: Italy
Distribution: Slackware 13.1
Posts: 230

Rep: Reputation: 30
Colored ls doesn't work with "su"


Hi!
I want ls to color the files it lists even when i run ls as root, AFTER "su".
I've found out that:
- if I login as "user", ls works fine;
- if I login as "root", ls works fine;
- if I login as "user", and then run "su", ls doesn't color anything.

I think I've understood why this happens: when I log in as "user" or "root", /etc/profile is executed and ls colours the list; if i run "su", it isn't the same as logging in as "root", and maybe /etc/profile isn't called, so dircolors isn't called as well... Is this correct?

Anyway, does anybody know how to solve this problem, i.e. how to have colored ls work after executing "su"?
Thank you!
 
Old 12-16-2006, 05:13 AM   #2
timdsmith
Member
 
Registered: Nov 2003
Location: The Colony, TX
Distribution: Slackware, Debian Etch, FreeBSD, MicroSh*t free.
Posts: 209

Rep: Reputation: 30
When you su try
Code:
su -
That's su space dash. See if that helps.
 
Old 12-16-2006, 05:37 AM   #3
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,045

Rep: Reputation: 54
Edit your /root/.bashrc file and add an line as follows:

Code:
alias ls="ls --color=auto"
Save file, exit termnial and see if it works
 
Old 12-16-2006, 08:16 AM   #4
simopal6
Member
 
Registered: Jun 2006
Location: Italy
Distribution: Slackware 13.1
Posts: 230

Original Poster
Rep: Reputation: 30
Thank you!!
Both ways work, but i prefer the .bashrc file (so i don't have to type " -" )..

By the way, what's the difference between "su" and "su -" ?
Thank you!
 
Old 12-16-2006, 08:21 AM   #5
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
It tells you in the su manual page:
Quote:
Originally Posted by su man page
The optional argument - may be used to provide an environment similar to what the user would expect had the user logged in directly.
 
Old 12-16-2006, 08:27 AM   #6
simopal6
Member
 
Registered: Jun 2006
Location: Italy
Distribution: Slackware 13.1
Posts: 230

Original Poster
Rep: Reputation: 30
Ok..Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM
chrooted user: "write" and "talk" don't work. ldp Linux - Software 2 04-12-2005 02:05 AM
"depmod" and "modprobe" commands don't work The1PatO Fedora 7 06-10-2004 12:10 PM
"<" ">" Keyboard keys on Toshiba Satellite 1005-s157 dont work RodCas Linux - Laptop and Netbook 1 05-08-2004 04:22 PM
<input type="button" disabled="true" > does not work in ns4.7 or 4.9 cybercop12us Programming 2 11-29-2002 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:30 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration