LinuxQuestions.org
Review your favorite Linux distribution.
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-26-2008, 06:54 AM   #1
udayakumarsv
LQ Newbie
 
Registered: Aug 2007
Posts: 17

Rep: Reputation: 0
Unhappy understand /etc/profile.


i would like to know wat is the job of /etc/profile and how to understand /etc/profile, wat is the contents of /etc/profile and how to retrieve the PATH from /etc/profile.


regards,
uday
 
Old 02-26-2008, 07:19 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
/etc/profile is read by Bourne-type shells (or at least sh and bash) for system wide configuration of login shells. The contents can be seen with '$PAGER /etc/profile'. /etc/profile is generally kept short and contains only a few variable assignments and commands but, since it's interpreted by the shell, it can contain anything a shell script can. As far as getting the path, that should be in environment and accessible as 'echo $PATH' but, if you want it directly from the file, "grep 'PATH=' /etc/profile" should work.

For more info, 'man $SHELL'.
 
Old 02-26-2008, 08:41 AM   #3
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
See this for some additional information; the page is from the LFS (Linux From Scratch) book.

http://www.linuxfromscratch.org/lfs/...7/profile.html

Quoted from the linked page:
Quote:
The files /etc/profile and ~/.bash_profile are read when the shell is invoked as an interactive login shell.
and note the "interactive login shell" part.
 
Old 02-27-2008, 12:14 AM   #4
udayakumarsv
LQ Newbie
 
Registered: Aug 2007
Posts: 17

Original Poster
Rep: Reputation: 0
Unhappy thanks for u r information, but when i executes grep 'PATH=' /etc/profile

Thanks for u r information,
but when i executes "grep 'PATH=' /etc/profile" it has given like below,


PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin
test -d $dir && PATH=$dir:$PATH
test "$UID" = 0 && PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
test -d $dir && PATH=$PATH:$dir
MANPATH=`test -x /usr/bin/manpath && /usr/bin/manpath -q`
INFOPATH=$INFODIR
XNLSPATH=/usr/X11R6/lib/X11/nls.

But , i want it like "/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin
"

I want only the PATH , but while grepping it displays a piece of code.
 
Old 02-27-2008, 01:09 AM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
grep 'PATH=' /etc/profile | cut -d= -f2
or
awk -vFS='=' '/PATH=/{ print $2 }' /etc/profile

Be careful, though - the box I'm on now sets a path for root and a path for the rest in a conditional, so that will return two strings.

-- Oh yeah if you post stuff with long lines in tags, that will set up a scroll box and not widen the page out so much. Plus, when it needs to be clearer to read, it is clearer. (I don't always do it for short one liners, obviously, but figured I'd mention it.)

Last edited by slakmagik; 02-27-2008 at 01:11 AM. Reason: about code tags and scrolling
 
Old 02-27-2008, 01:41 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
Or you could just edit it in vi and grab it, or
echo $PATH
Can you be a bit clearer about whether you just want to look at it or use it, and in what context.
From your OP, it sounds like just reading through /etc/profile will tell what you want to know.
 
Old 02-27-2008, 02:38 AM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Quote:
Originally Posted by chrism01 View Post
Or you could just edit it in vi and grab it, or echo $PATH<snip>
I believe we've covered that.

Quote:
Originally Posted by digiot View Post
The contents can be seen with '$PAGER /etc/profile'.<snip>As far as getting the path, that should be in environment and accessible as 'echo $PATH'<snip>
 
  


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
Don't Understand melp57 Linux - Newbie 6 11-13-2007 08:14 PM
system profile vs user profile bonito SUSE / openSUSE 3 06-28-2006 02:02 PM
can not understand ramanadyv Linux - General 1 06-06-2006 08:13 AM
non roaming profile on a roaming profile system fieldyweb Linux - Newbie 1 10-03-2005 01:27 PM
Understand | tuananhbirm Linux - General 3 01-10-2005 06:02 PM


All times are GMT -5. The time now is 06:31 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