LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-08-2006, 11:27 AM   #1
mort_03
LQ Newbie
 
Registered: Feb 2006
Posts: 2

Rep: Reputation: 0
Auto ls code in the .bash_profile


I am working with a linux server coupled with tomcat and apache. I have very little experience with this environment.

My question:

I was instructed to place the following code in my .bash_profile. I did this when i logged onto the linux server and it works. However, when i go into su mode and insert this code in the .bash_profile it does not. Any ideas?

Place the following code into your .bash_profile:

#---------converted from old csh script-------------
cd () { command cd "$@"; echo "$PWD" ;ls -CF; }
#-------automagically does an 'ls' after a 'cd'--------
 
Old 02-08-2006, 11:36 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Arch
Posts: 3,013

Rep: Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225Reputation: 1225
.bash_profile is used only for login shells, which su would not be.

Quote:
Originally Posted by man bash
When bash is invoked as an interactive login shell, or as a non-inter-
active shell with the --login option, it first reads and executes com-
mands from the file /etc/profile, if that file exists. After reading
that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,
in that order, and reads and executes commands from the first one that
exists and is readable. The --noprofile option may be used when the
shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the
file ~/.bash_logout, if it exists.

When an interactive shell that is not a login shell is started, bash
reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
these files exist. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.
So you might want to put that in .bashrc and have .bash_profile source .bashrc

Last edited by ntubski; 02-08-2006 at 11:37 AM.
 
Old 02-08-2006, 12:54 PM   #3
mort_03
LQ Newbie
 
Registered: Feb 2006
Posts: 2

Original Poster
Rep: Reputation: 0
that makes sense. I placed the code into the .bashrc as SU and now it works.
 
  


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
How do I auto start modules that aren't auto loaded on boot? darkbluedrew Debian 2 09-18-2005 10:10 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 02:37 AM
eth0 Auto Connect, How to auto start on logon cornish Linux - Networking 2 05-09-2005 01:02 PM
auto-completion - how does it work & can my script args auto-complete? BrianK Programming 1 06-11-2004 05:51 PM
autofs enabled in kernel but auto.mount and auto.master are NOT in /etc! Alybyzrp Linux - General 0 11-11-2003 01:26 PM


All times are GMT -5. The time now is 10:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration