Packaging Code Flashcards
set a variable
variableName=”some value”
no spaces
access a variable
echo $variableName
set a variable before a command
What’s the lifetime of the variable
SOMETHING=”a value” env
The lifetime is just that one line
What happens with this:
$ SOMETHING=”something else” echo $SOMETHING
why?
SOMETHING not found
because variables are evaluated before the setting occurs
Change the prompt
PS1=’whatever’
PS1 is the variable for prompt
turn a variable into a command
newVariable=”echo”
$newVariable ‘a string or whatever’
Mix 2 srings
MESSAGE1=”This is message 1.”
MESSAGE2=”This is message 2.”
MESSAGE=”$MESSAGE1 $MESSAGE2”
echo $MESSAGE
This is message 1. This is message 2.
What happens with this:
MESSAGE=’$MESSAGE1 $MESSAGE2’
echo $MESSAGE
$MESSAGE1 $MESSAGE2
To ensure that variables will be interpolated, you must use double quotation marks (“), not single quotes (‘). Try the following example in your command line to see the difference:
A command is just a file.
How does the computer know where to look for that file?
If it doesn’t have /, ., or ~, it’s not a file name. It will then look in the paths of the PATH variable.
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
looks in sbin first, then bin etc.
Find what folder a command in is
which man
which ls
Add a custom path but maintain the old ones
export PATH=”/path/to/my/executables-directory:$PATH”
So we’re setting path to our new option, then looks for the old options
Users/groups have certain permissions to files
t or f
F
Files have access given to certain users/groups
There’s nothing about a person that inherently gives them permission to dine at a restaurant at a particular table and at a particular time. It’s because the restaurant has labeled, or set apart, that table for that time that the person is able to dine there. So it is with the file system. There’s nothing inherently special about any group or user (except the root user). A user’s privileges are defined by the files and directories themselves.
Do something as root
sudo command
Enter root mode
sudo su
what is the general node project directory structure
.git .gitignore in main path
any code files in lib directory
any test files in test directory
Then a directory called assets, with more directories for images, css, js