Difference between source and dot command in Linux
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Difference between source and dot command in Linux
Hi,
I have written a set of aliases in a file.
When i tried to dot it( "Prompt> . filename" ). It said
" .: Permission denied. "
But, when I sourced it ("Prompt> source filename"). It worked perfectly.
Linux manual has one entry for both the commands. Then what am I missing ?
I have written a set of aliases in a file.
When i tried to dot it( "Prompt> . filename" ). It said
" .: Permission denied. "
But, when I sourced it ("Prompt> source filename"). It worked perfectly.
Linux manual has one entry for both the commands. Then what am I missing ?
Check the file's permissions with
Code:
ls -l <filename>
It's probably something like rw-rw-r--; in other words, it's not marked as executable. You'll need to use the chmod command to change the permissions; something like
@RockDoctor: actually the files don't need executable permissions, just for the fact they are sourced and not executed.
@itismohit: in BASH the . and the source built-ins are synonyms. Historically the . is the name of the source command for the Bourne Shell, whereas source is the name for C-shells.
I suspect your user's shell is not BASH, since it should manage the two versions properly. Unlike C-shells (e.g. /bin/tcsh) that recognize only source and not dot.
The C-shell interprets the "command" . as the "current working directory". It tries to execute a current working directory somewhere in the PATH. You can easily verify it using this dummy script:
The -x option echoes the commands before the execution (first line echoes the dot). As you can see, here the dot (as command) is mapped to /usr/bin/. hence the permission denied error (since a directory has the executable bit, but you don't have permission to actuall "execute" it).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.