Is it wise to edit or write in the bash profile?

Question

Is it wise to edit or write in the bash profile?

Answer

It all depends on a couple of factors: how comfortable we feel with the command line; if we know what kind of result the change will come about; and how helpful the change will be.

Most of the time the only changes we will need to make in our bash profile is to create aliases (simpler or memorable shortcuts to existing commands or command combinations) or to write environment variables, which are variables that can be available from anywhere and any file inside your local machine, which allows for a higher level of safety, commonly used for sensitive data, like API keys, or certain URLs.

It is advisable to interact with it creating our own aliases, so it can feel more comfortable, we will notice that the .bash_profile in our local machine is different than the one in Codecademy, but do not worry, while what is already there is important, if we read through the comments we will see that it has a designated section for aliases and another one for environment variables. At the end it is our own bash profile, and since we are learning programming, it is something that we should not worry or fear.

16 Likes

how do I see all the aliases already created ?

2 Likes

Just type the “alias” command on the command line.

13 Likes

i have question.
i must use only bash_ profile as environment of can i create any environment with any name ?

1 Like

Yeah, I think so because I have tried one with naming the environment with ~/.hello and it works.
$ source ~/.hello

$ pd /home/h1manshu

nano ~/.bash_profile

source ~/.bash_profile

Instead of typing it everytime, we can also make alias of it and make it much more easier.

First

nano ~/.bash_profile

Second

alias bp=“nano ~/.bash_profile”
alias sou=“source ~/.bash_profile”
echo “Created Successfully”

Third

Press Ctrl+O and Hit enter for Save
Ctrl+X for exit as you have learned

Fourth
Now to activate it we have to write

source ~/.bash_profile

Now you have Successfully created alias for nano and source
But i will recommend that you type the whole command everytime as it will be more beneficial.

4 Likes

When I want to save the nano file with ^O it always opens a window asking me to select a file from the computer. Why is that the case. I can therefore only save with ^X.
I am really confused.
Help would be greatly appreciated. :slight_smile:

https://www.codecademy.com/courses/learn-the-command-line/lessons/environment/exercises/bash-profile
I tried to start from the beginning. Now when I call the profile it says “permission denied”

no it isn’t advisable. I just did it and now I can’t go back and I can’t go fhttps://www.codecademy.com/courses/learn-the-command-line/lessons/environment/exercises/bash-profile. Help!