Note some of these commands / tricks don't apply to Windows.
cd directory_name
or cd directory_name/blah/de/da
(/
after each directory, this is a unix / linux thing (Mac is based on linux))
..
means 'one directory up'
.
means 'the directory I'm currently in'
To move up a directory: cd ..
ctrl + c
Up Button
Tab Button
You should press it all the time!
If something tab complete's it's 100% correct, if you type it it's 'probably right' -> Tab wins.
ctrl + r then type part of the command to search
;
e.g.
npm install; npm run dev
&&
e.g.
npm install && npm run dev
if npm install
fails, then npm run dev
doesn't get run.
echo
echo "Print this!"
pwd
(present working directory)
Use a single \
to continue a command onto the next line:
bigCommand \
--settings 1 \
--all-one-line 2 \
stuff
is the same as:
big command --settings 1 --all-one-line 2 stuff
cat filename.txt
ctrl + r then type part of the command to search
ps -ef
each process has a PID (process id)
kill <PID>
# example
kill 123
if you want to force it to be killed
kill -9 123
echo "Hello world!" > myFile.txt
This command deletes all previous contents of the file and replaces it with the output of the command.
echo "Hello world!" >> myFile.txt
This command adds the output of the command to the end of the file.
|
Piping takes the output of the command on the left, and passes it as a parameter to the command on the right.
ps -ef | grep node
The example above runs ps -ef
and then runs grep node
on the output.
This will produce ps -ef
filtered to only the lines which contain 'node'