Command Line part 8

Steven Klavins
2 min readFeb 25, 2020

Week 1 -Command line

When in the command line we are always in an environment, you terminal will know which user your operating under, your permissions and so forth. You can see the details of your environment entering “env” in terminal and “SET” in Windows. Each item on the list will have a key value pair, example “USERNAME = Steven”.

Setting environment variables

Here is an example of how to set and use an environment variable, we use the command “export”. An example of when we may wish to do this is when we want to hide sensitive info such as passwords. For example we could do the following “export SECRET_KEY=password1234” then, in our code read the value as follows “secret_key = ENV[‘SECRET_KEY’]”. This means if we were to upload the code and share it with the world this information would remain hidden. One important thing to note however is when we close the environment this environment we created will cease to exist, in order to make this a more permanent solution we will need to use rvm.

To achieve this we do the following (this will not work on windows without something such as c9io) “echo “export PASSWORD=1234” >> ~/.bash_profile” (>> means append, > means overwrite). Now when we close terminal this environment should be saved for future use.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Steven Klavins
Steven Klavins

Written by Steven Klavins

Hi, I’m Steven, most call me Steve! I’m a programmer, musician, and artist. This blog contains various tutorials and posts related to software development.

No responses yet

Write a response