Command Line Environment Configuration Flashcards

1
Q

What is the .bash_profile?

A

A bash profile is a file used to store environment settings for your terminal. On most computer systems, the file is in the home directory and is accessible by the name .bash_profile.
Note on Ubuntu the file is in the user directory and is called .profile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

source

A

The source command is used to execute a script or configuration file in the current shell environment.
It reads the contents of the file and executes the commands as if they were typed directly into the terminal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an alias?

A

An alias is a keybaord shortcut for commonly used commands.

$ alias pd=”pwd”
Here, alias pd=”pwd” creates the alias pd for the pwd command, which is then saved in the bash profile.
The pd alias will be available each time we open a new terminal session, and the output of pd will be the same as the pwd command.
source .bash_profile will make the alias pd available in the current session.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Environment Variables

A

Environment variables are variables that can be used across commands and programs and hold information about the environment.
he environment refers to the preferences and settings of the current user.

Example the USER variable:
export USER=”Jane Doe”
-sets the environment variable USER to a name “Jane Doe”. Usually the USER variable is set to the name of the computer’s owner.
-export makes the variable available to all child sessions initiated from the session you are in.
-the command echo $USER returns the value of the variable. Note that $ is always used when returning a variable’s value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

export

A

Is used to set or modify environment variables.
Environment variables are variables that are accessible to all processes running within a shell session. They can be used to store information that needs to be shared between different programs or scripts.
o make changes to environment variables permanent, you can add them to your shell’s configuration file (e.g., .bashrc or .zshrc).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

PS1 environment variable

A

The PS1 is an environment variable that defines the makeup and style of the command prompt.
ie. the text that is displayed before the user enters a command.

export PS1=”» “
-sets the command prompt variable and exports the variable. Here we change the default command prompt from $ to&raquo_space; .
After using the source command, the command line displays the new command prompt.

common elements of the PS1 variable:
\u: The username.
\h: The hostname.
\w: The current working directory.
\n: A newline character.
$: The dollar sign (if the user is a regular user) or a hash sign (#) if the user is root.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

HOME environment variable

A

The HOME variable is an environment variable that displays the path of the home directory ~.
typically:
/home/user_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

PATH environment variable

A

PATH is an environment variable that stores a list of directories separated by a colon.
Example:
$ echo $PATH

/home/ccuser/.gem/ruby/2.0.0/bin:/usr/local/sbin:
/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin

Each directory contains scripts for the command line to execute. The PATH variable simply lists which directories contain scripts.

NOTE many commands are scripts stored in the /bin directory.
Eample:
/bin/pwd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

env

A

The env command stands for “environment,” and returns a list of the environment variables for the current user.
The env command returns a number of variables, including PATH, PWD, PS1, and HOME.

You can use grep to search for a specific variable
Example:
env | grep PATH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly