Important skills cheat sheet
Navigating the darkness
cd /path/to/directory: moves you to the specified directory
ls /path/to/directory: shows you all of the files/directories within the specified
directory. Leaving the specified directory blank will show you all
files/directories within the directory you’re in.
ls -a /path/to/directory: same as ls, but shows hidden directories/files (anything
starting with a . cannot be seen by the regular ls command)
pwd: stands for “Print Working Directory.” In other words, will show the absolute
path to your current directory
Absolute paths: an absolute path starts with / specifying the root directory (the
‘root’ of the directory tree) and goes down the branches to a specific location. An
absolute path will take you to the same spot every time and is not dependent on
your current directory.
Relative paths: are far shorter than absolute paths and are usually as simple as
just putting in the name of a directory/file you found from an ls. However, this is
dependent on your current directory meaning a relative path won’t work unless you
are in the right spot
cd ..: moves you to your current directory's parent directory. Can be used multiple
times in a row (cd ../..) to go back a desired number of directories. Note this
doesn’t work like ctrl z. It will take you to the parent directory, not the
previous directory.
cd ~: moves you to your home directory (this is not the root directory)
cd /: moves you to the root directory
mkdir /path/to/make/directory would make the directory ‘directory’ in the directory
‘make’.
rmdir: deletes a directory (only if it is empty)
rm: deletes a file
rm -rf: recursively deletes all files from a designated starting directory. Is
usually used to clear a directory so it can be deleted. BE CAREFUL WITH THIS
COMMAND!!! rm -rf / will delete EVERYTHING on your computer.
touch /path/to/make/file/in.txt: would make in.txt in the file directory
Control C: will terminate a process. You may want to cancel certain commands that
either take a long time or intentionally run indefinitely until you tell them to
stop.
Git
git init: inilitizes a local git repository in your current directory
git add .: adds all files in your current directory
git commit -m “message” makes a version with the added files
Github (These commands are assuming that the github repository has already been
made. If you wanted to make your own repository, just copy and paste the
instructions from github into terminal)
git push: pushes the local commit you made to the github repository
git pull: pulls the latest version from the current branch so you can work on it
git clone [link]: grabs a copy of a repository from github and puts it on your
computer.
git branch: allows you to see which branches exist
git fetch: gets new branches
git checkout: switches which branch you are pulling from / pushing to.