One page to easily find all my main commands for the terminal and other programming languages. Clicking on a cell in any of the a “command” columns copies the content to your clipboard!
Quick Links
A few links I want to have quick access with info and instructions specific to the 2021 year of Fab Academy:
Terminal
command | functionality |
---|---|
cd [dir] |
Change directory |
ls -Al |
List all the files and hidden files in the directory |
mkdir [dir] |
Create a new directory within the current directory |
`du -sh * | sort -n` |
This Bash scripting cheatsheet might come in handy at some point?
Git
Git is a free and open source distributed version control system. For now I’m using the Git GUI within Visual Studio Code to commit and push my changes to this website, but below are the commands I’ve tried (or think might be useful) for usage in the terminal when doing more complex steps.
command | functionality |
---|---|
git clone [url] |
Clone the Git repository found at the url to the current directory |
git status |
Show the status of any changed/removed/new files |
git add [file] |
Add the file to your next commit |
git add . |
Add all changed files to your next commit |
git mv [old name] [new name] |
Move/rename a folder or file without Git thinking it’s a new file |
git commit -m "[message]" |
Commit all the stages files, creating a new “snapshot” |
git commit -a -m "[message]" |
Stage and commit all the changed files |
git push |
Push all the commits to the online repository |
git push origin master |
Push all the commits of the brach master specifically to the origin |
git pull |
Pull and merge any commits from the online repository |
git push origin master |
Pull all the commits of the brach master specifically from the remote origin |
git diff |
See a difference of everything that is changed but not yet staged |
git diff --staged |
See a difference of everything that is staged but not yet committed |
git log |
Prints out the history of commits |
Other Git commands that I haven’t used yet, but that could become useful in the future
command | functionality |
---|---|
git remote add origin [SSH URL] |
Add a remote connection, called origin of a repo that’s on your local |
git remote set-url origin [new URL] |
Reset the URL of the remote called origin |
git remote -v |
View remote connections |
git branch |
List all the branches of the repository |
git switch [branch-name] |
Switch to the named branch |
git checkout [branch-name] |
Switch to the named branch |
git merge [branch-name] |
While on another branch, merge the named branch back in |
git mergetool |
Run one of several merge utilities to resolve merge conflicts |
git branch -m [new-name] |
Rename the current brach |
git branch -d [branch-name] |
Delete the named branch |
git push origin --delete [branch-name] |
Delete the named branch on the remote origin |
git fetch --dry-run |
See changes to the remote before you pull in |
git init |
Initialize the current directory as a Git repository |
git reset [file] |
Undo uncommited changes to the file |
git reset |
Undo uncommited changes to all changed files |
git revert |
Undo a commit |
git submodule |
Keep a Git repository as a subdirectory of the current Git repository |
git stash |
Save modified and staged changes |
git stash pop |
Write working from top of stash stack |
git stash drop |
Discard the changes from top of stash stack |
Here is a pretty good Git Cheatsheet PDF with even more commands, and this Git tutorial shows how to use several commands. The Git-it tutorial was really useful to get some experience with the more difficult parts of Git. If something goes wrong and you don’t know how to fix it, you might find the solution in Dangit, Git!?!.
ffmpeg
An extremely handy command-line tool to convert video files; changing video format, making smaller sizes, cropping, trimming, and a lot more.
command | functionality |
---|---|
ffmpeg -i input.mp4 |
Get the details of the (video) file |
ffmpeg -i input.mp4 -vf scale=1280:-1 output.mp4 |
Scale the video (down) to 1280 pixels in width and keep the same aspect ratio |
ffmpeg -i input.mp4 -ss 00:00:04.00 -t 5 -c copy output.mp4 |
The output video is from the 4th second and lasts for 5 seconds, while the video is not re-encoded |
ffmpeg -i input.mp4 -vcodec libx264 -crf 28 -vf scale=1280:-1 output.mp4 |
Convert to the H.264 codec, use a quality of 28, and scale it to 1280 pixels in width |
ffmpeg -i input.mp4 -vcodec libx264 -crf 28 -vf crop=out_w:out_h:x:y,scale=500:-1 output.mp4 |
First crop the video to out_w width and out_h height, with x:y being the top-left corner of the rectangle, then rescale and downgrade |
ffmpeg -r 24 -f image2 -s 840x560 -start_number 15 -i %04d.png -vcodec libx264 -crf 25 -pix_fmt yuv420p video.mp4 |
Turn a collection of 0001.png images into mp4. With -r 24 24 fps, -s 840x560 resolution of 840x560 pixels, -start_number 15 starting at image 15 |
Some more commands from Neil.
ImageMagick
A very handy command-line tool to edit and convert images, either for one file or in batch mode.
command | functionality |
---|---|
identify [file] |
Get the details of the (image) file |
convert -resize 1280x720 [file-in] [file-out] |
Resize the file-in to 1280x720 pixels and called file-out |
convert -resize x800 -quality 55 [file-in] [file-out] |
Resize the image to a height of 800px and reduce the quality to 55 |
convert -crop 600x800+35+0 [file-in] [file-out] |
Crop the image to 600x800px taking the top-left corner at 35 pixels from the left and 0 pixels from the top |
mogrify -format jpg *.png |
Create a jpg copy of each png file |
mogrify -resize 1200\> -quality 55 *.png |
Resize any png image larger than 1200px wide to 1200px, keeping the aspect ratio, and reduce the quality to 55 |
Markdown
Markdown is a lightweight markup language for creating formatted text using a plain-text editor. It basically maps human-readable files to HTML.
command | functionality |
---|---|
# H1 |
<h1> header |
## H2 |
<h2> header |
### H3 |
<h3> header |
#### H4 |
<h4> header |
_italics_ |
italics |
**bold** |
bold |
`inline code` |
inline code |
```html ``` |
longer code blocks |
- list item |
creates an enumerated list with bullet points |
[link title](https://url.com) |
create a link |
![image alt tag / figure caption](image.png) |
add an image |
Even more options can be found in the Markdown Cheatsheet. The possible language options for the syntax highlighting.