An ad-free and cookie-free website.
Learn to read and execute commands at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux source Command Summary with Examples (3:38)
Our eighty-seventh word, or command to memorize is
source from our category
source allows you to read and execute
commands from a file.
|None for this command|
Recall from videos (tutorials) #47 and #49 we saw shell built-in programs that modified variables and here we'll learn another shell built-in that reads and executes commands as we transition to our last section on writing scripts to pull together what we've learned here.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
source command has
no options, and the argument is the file.
Unlike most commands, help is not available with double-dash
--help and information is found in
man page for
So why is
source an important command?
Well, at times you need to run scripts in the current setting without
say logging out and back in to take effect, like a configuration file.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Start with
mkdir from video (tutorial) #22 to
create a directory called
bin and put
it in our home directory using the tilde
source reviews directories in the
PATH, but bin won't be there (meaning typing the name of the
script won't work until you add this directory to your PATH). So you
can add a line
you need the colon, and then this section here for the PATH variable
"$PATH" to your
.bashrc file so that
bash at startup adds this directory
to the PATH each time.
Okay, let's move on the script. I used
nano to create
funscript, and at this
point it prints text and the date. We'll add to it in coming videos
Please pause the video to read and create this on your end and save
Okay next, use
chmod 700 so the owner
can read, write and execute
And last, let's type
And there it is, how fun.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
command. So there is a synonym for
source that you really need to know
and it's simply a period
.. That's it.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
We'll keep building on this script as we explore the Intermediate-level topic of shell scripting. It may help to supplement this text-based tutorial with our YouTube videos for the more difficult section ahead.
sshcommand, hit Back.
timecommand, click Next.
A newly-updated free resource. Connect and refer a friend today.