Console Flashcards
show files in the current directory
ls (name: list. list files)
ls - additional commands
- l (prints long form of file list)
- a (show all files, including hidden files)
ls - l
prints long form of file list drwxrwxr-x r: read w: write x: execute
- first rwx - permissions of the creator
- second rex - permissions of a group
- last r-x - permission for everyone else
what a folder is called in a console
directory
show you your current directory
pwd - print working directory
shortcut to home directory
~ (tilda)
move to a different directory
cd - change directory
you don’t need start with a / if you are moving to relative directory from where you currently are.
if you do an absolute path, you have to start with /user…
move up a directory level
cd ..
to move two levels up: cd ../..
a program that displays the content of a file
less
need to hit the “q” key to exit out of the less program
prints the contents of one or more files to the console
cat
a simple text editor in the console
nano
shortcuts use the ^ which is actually the control button
how to move or rename a file or directory
mv (move)
takes two arguments:
1) what do we want to move
2) where we want to move it
Renaming:
$ mv hello.txt hi.txt (this is same as renaming it)
Moving directories:
$ mv hi.txt documents/
(this is moving it because documents is a directory)
represents our current directory
.
(dot)
$ mv documents/hi.txt .
this would move it up one directory (my current directory)
copies a file or directory
cp
works the same as move -
1) what do we want to copy
2) where we want to copy it to?
for copying a directory though you have to use -r (recursive) which will copy of the document within the directory as well. example:
$ cp -r documents docs
(this will copy the documents folder and call it docs (with all of the
removes files or directories
rm
be careful of using remove because there is no going back in console.
you can’t remove a directory without an -r just like copy because you need to recursively remove all of the files and sub-directories in within the directory as well
how to create a directory (including nested directories)
mkdir
(make directory)
to create nested directories
use the -p documents/notes/console/part1 (the -p allows us to create as many sub directories as needed)
repository
a collection of all the different versions and files of a project
committing
git commit
other commit commands:
git commit -a -m
a - means that all changes to the files in the repository will be committed.
m - means that you can add the commit description message directly to the commit command
when you tell the version control system that you are done with a version and ready for the next
create a repository
git init [name of project]
how to add a file to the repository so that i can be tracked
git add [file name to be added to the repository]
you can also use “git .” which will stage all changes to the files in that directory.
how to get the status of a commit
git status
this will show you the staging area and tell git what you want to commit (if you do or don’t want to commit all changes)
get the history of your git repository
git log
(latest commits start at the TOP)
To make it on one line per commit, you can use the:
git log –pretty=oneline
Move to (look into the details) of a commit in the repository and then return to the latest
To check out a previous commit
git checkout [first 5 or 6 characters of the commit number]
(note: that you can make changes here but that is dangerous.
To return to the latest versions
git checkout master (or git checkout HEAD)
- ‘master’ is the name of the default branch. By checking out a branch by name, you go to the latest version of that branch.
- if you use git checkout HEAD~! it is a special commit identifier in git; it stands for the previous commit (not the one we just made, but the one before that).
Also, the checkout command can be used to discard changes
how to look at the difference between two commit (what has changed)
git diff [first commit num] [second commit nun]