spotify logo github logo X logo dribbble logo
  • Home
  • My Work
  • Inspiration
  • Journal

Command Line Cheatsheet

January 21, 2020

Snippets

This is a list of all the command line snippets that I often forget or just need to reference once in a while.

As you can probably tell, I don’t use the command line very often. ????

pwd – print working directory

mkdir – create new directory

touch – create a new file

rm – delete file

use rm -r folderName to delete an entire directory

open – open file

cp – copy file

cp m*.txt scifi/ will copy all the .txt files in the directory you are in currently into the directory named scifi

mv – move file

mv can also be used to rename a file. mv bucks.txt warriors.txt will rename bucks.txt to warriors .txt

nano ~/.bash_profile will get you to the file where you can set keyboard shortcuts

source ~/.bash_profile will initialize the .bash_profile file and allow you to use shortcuts

In .bash_profile alias ll=”ls -la” will assign a a shortcut of ll to ls -la

cal will bring up a small monthly calendar with the current day highlighted

To zip up a file and password protect it: zip -er [archive] [file]

Imagemagick

mogrify -format webp *.png will convert any images in the directory from .png to .webp

magick shot.png -encipher passphrase.txt locked.png to encrypt an image. using the same name as the output will overwrite the original image. You could also save it out with a different name as well.

magick locked.png -decipher passphrase.txt unencrypted.png to decipher an image. The contents in the passphrase must match what was in the file originally when it was encrypted.

.jpeg and .gif are not supported when it comes to encrypting and decrypting.

convert shot.png -resize 100px new.png will resize the original image to have a width of 100px. You can also resize with percent (-resize 50%).

Git

git log to see everything that’s going on

git commit –amend -m “new message goes here” to change the commit message

git cherry-pick 8273g8d to bring a commit from a different branch over to a new branch. The numbers are the hash from the commit you want to bring over

git reset –hard 8273g8d to reset a branch back to a certain commit

git clean -df run this after a git reset to clear any untracked files from the staging area. ‘d’ stands for directories and ‘f’ stands for files

git reflog shows a list of the recent actions

git revert 8273g8d creates a new commit that reverts a certain commit (based on the hash). This doesn’t screw up the history because it’s just another commit added to the log and when people pull it down those changes will be applied

git stash save –keep-index and then git stash drop to revert back and drop the changes that you made

Homebrew

brew search tree to search packages. In this case, we are searching for a package named tree.

brew cask firefox to install the program Firefox. Cask programs are usually Mac versions of popular programs.

brew cask home firefox to take you to the homepage of the cask application you are looking to download.

brew list to see all of the programs currently installed via brew.

brew outdated to show all of the outdated programs installed via brew.

brew upgrade to update all the outdated programs installed via brew.

brew cleanup to remove old versions of the outdated programs.

@joekotlan on X

Need some work done? Say hi 👋 Or just tell me your best joke and I’ll send you back one of mine.

  • This field is for validation purposes and should be left unchanged.
spotify logo spotify logo
github logo github logo
X logo X logo
dribbble logo dribbble logo
  • Home
  • My Work
  • Inspiration
    • Inspiration Boards
    • Inspiring Websites
    • Design Links
    • Web Dev Links
    • Music
  • Journal