unix shell tutorial
navigating files & directories
- man <command> : opens manual for that command
- syntax of shell command:
- shortcuts
- cd : go to home directory
- ~ : home directory
- options for ls
- -s : display size of files & directories
- -S : sort files & directories by size
- -F : classify output (* = executable, / = directory, @ = link)
- -l : long list format (additional info)
- -h : “human readable”
- -a : show all (useful for hidden directories)
- -R : list all nested subdirectories
working with files & directories
pipes & filters
- wc options:
- -l : only show number of lines
- -w : only show number of words
- -m : only show number of characters
- less [file] : displays a screenful of file
- next: spacebar
- back: b
- quit: q
- sort options:
- -n : numerical sort
- -r : reverse order
- head options:
- -n [number] : display first [number] lines
- cut : cuts out certain sections of each line in file
- -d : specify delimiter character
- -f [number] : specify which field to extract
git commands
<aside>
💡 current directory must be a repository
</aside>
- git log : check history
- git help or man git -<verb> : get help (q to exit)
- git add [file] : add file to “staging area”
- git commit -m “comment” : commit to the repository
- git push -u origin main : push changes from local to remote repository (in “main” branch)
- git status : check status
- git diff : check difference
- git pull : pull changes from remote to local repository
- git branch: lists branches
- git branch [name]: creates new branch
- git checkout [branch]: switch to branch
- git merge [branch]: merges changes from listed branch to current branch
other
vi commands
- [esc] : enter command mode
- in command mode:
- :wq exit vi (& save changes)