npm init -y
will runnpm init
and auto-confirm the default response prompt values.npm i -S
is an alias fornpm install --save
: Updatesdependencies
inpackage.json
npm i -D
is an alias fornpm install --save-dev
: UpdatesdevDependencies
inpackage.json
npm i -O
is an alias fornpm install --save-optional
: UpdatesoptionalDependencies
inpackage.json
npm i -E
is an alias fornpm install --save-exact
: Updatesdependencies
inpackage.json
with exact version numbers.
cd ..
will navigate one directory backcd ~
will navigate to your home directorycd -
will change directory to your previous directory
Grep is a super powerful utility for searching text using string or regular expression patterns. To learn more on regular expressions, see our handy guide.
ps aux | grep [something]
will list all running processes matching the text or RegEx in[something]
[command] | grep [string/pattern]
will pipe the output ofcommand
to thegrep
utility to allow the result to be searched. See the section below on tailing a log file for another example of usinggrep
with other commands.
tail -f /var/log/apache2/error_log
- will stream a log file in real-time. Press[CTRL]+C
to exittail
cat /var/log/apache2/error_log
- will print the log file to the consoletail -f /var/log/apache2/error_log | grep 127.0.0.1
- will stream a log file, but will only print the lines containing the text '127.0.0.1'
Ever get stuck in vi
? Here are some basics. A much more comprehensive list can be found on Lagmonster.org.
[ESC]:x
- Quit, saving changes[ESC]:q
- Quit if there are no changes[ESC]:wq
- Write file and Quit[ESC]:q!
- Exit and ignore any changesi
- Enable input at the cursor position/string
- Search forward for string?string
- Search backward for stringn
- Search for next instance of stringN
- Search for previous instance of string
You can create alias
commands in your ~/.bash_profile
file in macOS to create your own shortcut commands. For example, look at the following shortcut ideas:
alias ll='ls -lG'
alias add="git add"
alias commit="git commit -m"
alias s="git status"
alias rename="git branch -m"
alias b="git branch"