When user access to files. Permissions are required to Read, Write, or Execute from CLI.
ls -l
chmod
When you put ls-l in the Terminal, if it starts with d, it means a directory folder, and if it starts with -, it is a file.
The following r, w, and x indicate read permission, write permission, and execute permission.
user: Owner of the file. By default, the person who created the file becomes the owner.
group: A group can contain multiple users. All users belonging to the group have the same access to the file. When you have a project that requires many people to access files, add user is simple way to give permission.
other: Other user with access to the file. use special case.
chmod command can change permission. There are two ways to change the permission: Symbolic method and Absolute form.
chmod g-r filename # removes read permission from group
chmod g+r filename # adds read permission to group
chmod g-w filename # removes write permission from group
chmod g+w filename # adds write permission to group
chmod g-x filename # removes execute permission from group
chmod g+x filename # adds execute permission to group
chmod o-r filename # removes read permission from other
chmod o+r filename # adds read permission to other
chmod o-w filename # removes write permission from other
chmod o+w filename # adds write permission to other
chmod o-x filename # removes execute permission from other
chmod o+x filename # adds execute permission to other
chmod u+x filename # adds execute permission to user
Absolute form grants authorize through the sum of numbers.
Read(r): 4, Write(w): 2, Execute(x): 1
ex)
chmod 744 helloworld.js
7 4(r) + 2(w) + 1(x) rwx read, write and execute
6 4(r) + 2(w) + 0(-) rw- read and write
5 4(r) + 0(-) + 1(x) r-x read and execute
4 4(r) + 0(-) + 0(-) r-- read only
3 0(-) + 2(w) + 1(x) -wx write and execute
2 0(-) + 2(w) + 0(-) -w- write only
1 0(-) + 0(-) + 1(x) --x execute only
0 0(-) + 0(-) + 0(-) --- none
In Linux, you can check environment variables by simply entering export.
The npm module dotenv allows you to use environment variables in Javascript. It must be installed npm i dotenv module.
npm i dotenv
You can use environment variables through .env.
Create .env file, input environment variables to use, and save.
In order to use the environment variable, you need to import the following command in the place where it will be used.
const dotenv = require("dotenv");
dotenv.config();
You can use environment variables to store and manage sensitive information such as API Key and DB Password.