TAB completion use it!
whoami display current user
pwd print working directory
ls list files in working directory (add file path to see that directory)
cd change directory (defaults to home directory)
cd ~ cd to home directory
cd / cd to root directory
cd .. cd up one level
absolute file path = file path relative to the root directory
relative file path = file path relative to the current working directory
cat view contents of a file
open open a file (start on PC)
echo print something
> redirect text to a file
mkdir create a directory
touch create a file
cp copy and paste (cp -r source dest)
mv cut and paste
rm delete a file
rm -r directory_name delete a directory
man pwd access help files (spacebar to advance, q to quit)
screencapture take screenshot
say speech function (Mac)
Up/down arrow keys cycle through previous commands
Option + left/right arrow keys move cursor word by word
Ctrl c abort process
Ctrl d terminate input
Ctrl r search (recursive)
Ctrl l clear console
Ctrl a move cursor to beginning of line
Ctrl e move cursor to end of line
Ctrl k cut to end of line
Ctrl u cut to beginning of line
Ctrl y paste
ls | grep "Lawrence" python_script.py do (partial) pattern matching within a particular file
grep Laboratory * to search all files for some text (the word "Laboratory" in this case)
NOTE: to run Python and R scripts you must first install Python Anaconda 3.7 (https://www.anaconda.com/distribution/) and/or R 3.6.2 (https://cloud.r-project.org/)
bash execute bash script
bash scripts/bash.sh
python execute Python script
python scripts/python_script.py
Rscript execute R script
Rscript scripts/r_script.R
If you have previously attended a D-Lab workshop you have probably downloaded some workshop materials from GitHub by clicking a download button, downloading the .ZIP file, and then extracting that .ZIP file to your Desktop.
The Git equivalent is git clone, but the process is similar:
-
Visit a GitHub repository, like for this BashGit workshop or for upcoming R-Fundamentals or Python-Fundamentals workshops.
-
Click the green "Clone or download" button
-
However, this time click the clipboard icon to copy the URL
-
At your Bash prompt type git clone URL to clone the repository (paste the URL)
For example:
$
git clone git@github.com:dlab-berkeley/R-Fundamentals.git
$
git clone git@github.com:dlab-berkeley/python-fundamentals.git
- Type git pull to ensure you have the latest remote version of the repository
Fork: A copy of a repository; you can experiment freely without affecting the original repository. You can fork a repository to make proposed changes.
Clone: Download an existing Git repository to your local computer, while the original still lives on the remote server.
Pull: synchronize your local repository with changes in the central upstream repo (even though it is cloned from the origin) ... (and pushed to the fork!)
NOTE: The Origin is the URL of the upstream repopsitory, but the Upstream is the maintainer's repository; once cloned, the origin becomes wherever it was cloned from.
Stage: Designate altered files to be included in the next commit.
Commit: Revisions to a file/set of files that creates a unique ID of those changes ("hash") to track changes that are pushed.
Push: Send your committed local changes to a remote repository.
Pull request: A way to communicate changes you wish to make to a repository, used to facilitate discussion with collaborators and additional commits before it is merged into the master branch.
Merge: Turning a pull request's changes into a single commit and merged into the master branch.
-
First, cd into the local directory on your laptop where you wish to make changes before adding them to your remote GitHub repository.
-
git add . changes you want to make from your laptop to the remote GitHub repository. This function will stage all local files to be committed to the remote repository (replace . with an individual filename if desired).
-
git commit -m "commit message" commit your local changes to remote and add a message for documentation purposes.
-
git push -u origin master push your local changes from your laptop to overwrite the remote GitHub repository.
-
refresh your GitHub repository URL to see the changes!
git status view files ready to be committed; run this after the "git add" function
git log view commits
git log -p -2 view commit details (press Enter to see more lines; press q to quit)
git checkout -b branch_name will create a new branch.