Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.


  Search this Thread
Old 02-23-2006, 01:20 PM   #1
LQ Newbie
Registered: Feb 2006
Posts: 2

Rep: Reputation: 0
use of source command

hi everyone,

i'm new to linux. what is the use of "source command"? i know it executes a script file.

my script file has the following commands:
echo "hello world";
echo "$pwd";
if ran the script using source command or simply on the shell, i get the same answer. then how is "source" command different shell and what is the use of "source command"?

Old 02-23-2006, 01:27 PM   #2
Senior Member
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,124

Rep: Reputation: 164Reputation: 164
The source command does it's stuff in the current shell instead of a sub-shell - the commands behave as if you typed them in your current shell. If you made the file executable and then ran it, the commands would execute in a sub-shell.

When you're only displaying stuff it doesn't matter which way you do it, but when you're controlling variables and processes it does.
Old 02-24-2006, 04:07 AM   #3
LQ Newbie
Registered: Feb 2006
Posts: 2

Original Poster
Rep: Reputation: 0
thanks steve
Old 02-28-2006, 08:34 PM   #4
Registered: Feb 2006
Distribution: Red Hat 9
Posts: 112

Rep: Reputation: 15
You might want to use the pwd command like so: echo "$(pwd)" instead of $pwd incase you use variables with that name.
Old 02-28-2006, 08:42 PM   #5
Registered: Oct 2005
Posts: 162

Rep: Reputation: 30
If you for example, make changes to /home/testuser/.bashrc and you want the changes to take effect immediately, simply run "source /home/testuser/.bashrc". That will update your current shell and you will see the effects of the changes.


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
the `source` command and my $PATH jayeola Programming 6 12-14-2005 10:45 PM
about the source command kpachopoulos Linux - General 2 06-12-2005 08:16 PM
what the command [source] does ? hq4ever Linux - Newbie 4 06-26-2004 04:09 PM
Where is source for 'who' command grittkmg Programming 2 10-15-2003 01:49 PM
What is the source (Bash) command do ? Linh Linux - General 5 06-09-2003 04:46 PM

All times are GMT -5. The time now is 07:47 AM.

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