How to Reload the .bash_profile From Command Line

MD Aminul Islam Feb 02, 2024
  1. Create the .bash_profile
  2. Edit and Reload the .bash_profile
How to Reload the .bash_profile From Command Line

In Shell, .bash_profile is used to customize the configuration of user settings. This is stored in the root or home directory and is mostly hidden from other users.

This file holds all the configuration of the shell, and it is also considered the configuration script. It includes the variable specifications, export variables, etc.

This article will show how we can create, delete, and edit the .bash_profile in macOS. We are going to learn them step by step with the necessary commands.

Create the .bash_profile

In this part, we will learn how to create a .bash_profile. For this purpose, we are going to use the below commands:

touch .bash_profile

Now, when we are done creating the .bash_profile, we can check the file using the command below:

ls -la

After executing this command, you will get an output like the one below:

total 16
drwxr-xr-x 1 author author 4096 Aug  7 11:42 .
drwxr-xr-x 1 root   root   4096 Nov  1  2021 ..
-rw------- 1 author author 5378 Aug  6 01:46 .bash_history
-rw-r--r-- 1 author author  220 Nov  1  2021 .bash_logout
-rw-r--r-- 1 author author    0 Aug  7 11:42 .bash_profile
-rw-r--r-- 1 author author 3771 Nov  1  2021 .bashrc
drwx------ 1 author author 4096 Dec 18  2021 .cache
drwx------ 1 author author 4096 Dec 18  2021 .config
drwx------ 1 author author 4096 Dec 18  2021 .dbus
drwxr-xr-x 1 author author 4096 Nov  1  2021 .landscape
-rw-r--r-- 1 author author    0 Aug  7 11:41 .motd_shown
-rw-r--r-- 1 author author  807 Nov  1  2021 .profile
-rw-r--r-- 1 author author    0 Nov 29  2021 .sudo_as_admin_successful
-rw-r--r-- 1 author author    0 Jul  6 15:26 disk_usage.txt

Here, you can see your .bash_profile listed.

Edit and Reload the .bash_profile

We successfully created our .bash_profile. Now, it’s time to do some modifications to it.

To modify a .bash_profile, you can use the nono editor. You can follow the command below to open the .bash_profile with the nono editor.

nano .bash_profile

When we are done modifying the .bash_profile file, we need to reload the file to make the customization active. To do that, we can use any of the two commands below.

source .bash_profile

Or we can use,

source ~/.bash_profile

Now, we are done creating and modifying the .bash_profile. We did it by the command; you can do it manually using any text editor.

Please note that all the code used in this article is written in Bash. It will only be runnable in the Linux Shell environment.

MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn

Related Article - Bash Profile