loginis a program that logs users in to a computer.
/etc/passwdfor your shell.
fishare both popular.
lsList files. You can give it a directory to list.
-lDisplay the output in a detailed list, one line per file.
-hDisplay file sizes in a human-readable format.
-aDisplay all files, including hidden ones.
pwdPrint working directory.
cd(without a directory) takes you to
cd -takes you to the previous directory you were in.
mvMove (or rename) files.
-iInteractively ask you before overwriting files.
-nNever overwrite files.
-rRecursively copy directories, which is what you want to do.
rmRemove one or more files.
-fForcibly remove nonexistent files.
mkdirMakes a directory.
-pMakes every missing directory in the given path
rmdirRemoves an directory.
.always refers to the directory you are currently in.
..always refers to the parent of the current directory.
~refers to your home directory.
/refers to the root directory. Everything lives under root.
*matches 0 or more characters in a file or directory name
?matches exactly one character in a file or directory name
ls *.cpplists all the cpp files in the current directory.
catPrint out file contents.
lessPaginate files or STDIN.
headPrint lines from the top of a file or STDIN.
tailPrint lines from the end of a file or STDIN.
-nPrint LINES lines instead of 10.
sortSorts files or STDIN.
uniqto show unique lines.
diffShows differences between files.
man COMMANDopens a manual listing for that command.
qquits the manual.
/searches for things.
Ngo to next/previous search result.
man mangives you the manual for the manual!
When a program runs, it has access to three different "pipes".
We aren't concerned about STDERR (for now), so let's ignore that.
Not all programs need input; not all programs produce output.
... only produces output
By default, the output from STDOUT is sent to your shell...
We can also tell the shell to redirect the output other places.
>>redirect output to files
|redirects output to another program's input
wc reads input over STDIN, counts the number of lines/words/bytes in the input, and prints the counts on STDOUT.
We can use
| to chain programs together. For example...
echo "I love to program" | wc
... tells the shell to redirect the output from
echo "I love to program" into the input of
This effectively counts the number of lines, words, and bytes in the phrase
I love to program!
You can even chain a bunch of programs together using
cat myFile.txt | sort | uniq | wc
cat myFile.txt | sort | uniq | wc
cat myFile.txtprints the contents of
myFile.txton STDOUT, which is redirected to the input of
sortthen sorts that input (alphabetically) and its (sorted) output is redirected to the input of
uniqremoves any repeated lines and its output (the unique lines) is sent to the input of
wccounts the unique lines and prints the counts on the console.
SO! By gluing simple programs together, you now have a program that can count the number of unique lines in a file!
git initMakes a new empty git repository.
git add FILEAdds changes in
FILEto the next commit.
git statusShows the status of the repository.
git rm FILERemoves
FILEfrom working directory and index.
Tell Git who you are!
$ git config --global user.name NAME $ git config --global user.email EMAIL $ git config --global core.editor vim
git logShow a log of commits
--graphNeat ASCII graph
-pShow what changed in each commit
git diffShow uncommitted changes
--allShow all branches
git clonemakes a copy of a repository.
git pushPushes changes from your current branch to the remote branch it tracks. (You may need to run
git config --global push.default simple.)
git pullPulls changes from the remote branch and merges them into your current branch.
a.out) to your repo.
.gitignorefile in your repo.
git help COMMANDwill show you documentation.