Reload .bash_profile from the command line
In the shell, .bash_profile is used to customize the configuration of user settings. It is stored in the root directory or home directory and is mostly hidden from other users.
This file holds all the configuration of the shell and is also known as a configuration script. It includes variable specifications, exported variables, etc.
This article will show you how to create, delete, and edit .bash_profile in macOS. We will go through the necessary commands step by step.
Create .bash_profile
In this part, we will learn how to create .bash_profile. For this, we will use the following command:
touch .bash_profile
Now, when we are done creating .bash_profile, we can check the file using the following command:
ls -la
After executing this command, you will get output similar to the following:
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 .bash_profile listed.
Edit and reload .bash_profile
We have successfully created .bash_profile. Now, it’s time to make some modifications to it.
To modify .bash_profile, you can use nono editor. You can open .bash_profile using nono editor by following the command below.
nano .bash_profile
When we are done modifying the .bash_profile file, we need to reload the file for the customization to take effect. To do this, we can use either of the following two commands.
source .bash_profile
Or we can use,
source ~/.bash_profile
We have now completed the creation and modification of .bash_profile. We did this from the command line; you can do it manually using any text editor.
请注意
, all the codes used in this article are written in Bash. It can only be run in the Linux Shell environment.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Check if input parameter exists in Bash
Publish Date:2025/03/21 Views:191 Category:OPERATING SYSTEM
-
When we create a Bash script, we may want to use parameters in our script to run successfully. Therefore, we need to create a script to check the number of input parameters used by the user in the script. All of this prevents unexpected beh
Getting optional input arguments in Bash
Publish Date:2025/03/21 Views:180 Category:OPERATING SYSTEM
-
Sometimes we need to create a dynamic function which can be executed in both without passing any arguments or without passing any arguments. For this we need to set some default values for those arguments so that if the arguments are
Using Double and Single Pipes in Bash
Publish Date:2025/03/21 Views:136 Category:OPERATING SYSTEM
-
In Bash, the double pipe || is also known as the OR operator in other programming languages. On the other hand, the single pipe | is known as a pipeline. In this article, we will see how to use double pipe (also known as OR) and pipelines i
Breaking out of a loop in Bash
Publish Date:2025/03/21 Views:131 Category:OPERATING SYSTEM
-
Using loops is a common task in any programming or scripting language. While using a loop, sometimes we need to stop it under a predefined condition. Like other programming and scripting languages, Bash uses the keyword break to stop any lo
Bash configuration files in macOS
Publish Date:2025/03/21 Views:185 Category:OPERATING SYSTEM
-
In this article, we will discuss how to create, delete, and edit bash profiles in macOS. Create .bash_profile To create .bash_profile, open a terminal and move to your home directory using the following command. cd ~/ Now you can create usi
eval command in bash script
Publish Date:2025/03/21 Views:87 Category:OPERATING SYSTEM
-
This article is about using strings as commands in Bash scripts. For this purpose, the eval command is used. Eval Command in Bash Scripts In some Bash scripts, you have to create a string using variables or input values (for example)
Exit Bash Script
Publish Date:2025/03/21 Views:99 Category:OPERATING SYSTEM
-
This article provides a brief introduction to Bash scripting and discusses exiting a Bash script when an error occurs. It further discusses the limitations and benefits of Bash scripting. What is Bash Scripting A computer script/program tel
timeout command in Bash
Publish Date:2025/03/21 Views:105 Category:OPERATING SYSTEM
-
This article is a simple guide to setting a timeout for a specific program using the timeout command from GNU's coreutils package in Bash. timeout command in Bash In many cases, such as fetching data from a server or running a function or p
Start a new terminal session in Bash
Publish Date:2025/03/21 Views:51 Category:OPERATING SYSTEM
-
In various situations when using Bash or another shell, you may need to run a script or program in a new terminal instance or in another tab in the same terminal. Opening a new terminal instance or tab from within Terminal is simple; we'll