Fundamentals 4 min read

How to Use Linux’s source Command to Refresh Environments and Run Scripts

This guide explains the Linux source command, covering its syntax, how to refresh the current shell environment, execute scripts within the same session, import functions, and read variables from other scripts, with practical examples and command-line illustrations.

Liangxu Linux
Liangxu Linux
Liangxu Linux
How to Use Linux’s source Command to Refresh Environments and Run Scripts

Introduction

The source built‑in shell command reads and executes a file in the current shell session, allowing you to modify or preserve environment variables without spawning a new process.

Syntax

The basic form is: source FILENAME [ARGUMENTS] You can also use the shorthand . (dot) instead of source:

. FILENAME [ARGUMENTS]

1. Refreshing the Current Shell Environment

Define an alias in ~/.bashrc and reload it with source: echo "alias ll='ls -al'" >> ~/.bashrc Then refresh: source ~/.bashrc After reloading, the ll alias lists all files, including hidden ones.

Refreshing shell environment with source
Refreshing shell environment with source
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxBashscriptEnvironmentsource command
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.