Skip to content

Instantly share code, notes, and snippets.

@justinhartman
Last active November 7, 2018 10:06
Show Gist options
  • Save justinhartman/cd6e6dbdda1d2f84535521205e2cf10c to your computer and use it in GitHub Desktop.
Save justinhartman/cd6e6dbdda1d2f84535521205e2cf10c to your computer and use it in GitHub Desktop.
Useful macOS Terminal Commands

Useful macOS Terminal Commands

The following commands I will be using in the https://github.com/justinhartman/Automated-LAMP-with-trusted-localhost-SSL project but they are also useful commands to keep as a reference.

Import certificates into the System Keychain

$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain <certificate>
$ sudo security add-trusted-cert -d -r trustRoot -k $HOME/Library/Keychains/login.keychain <certificate>

Add user to _www group

$ sudo dseditgroup -o edit -a `whoami` -t user _www

Get the user

$ whoami

Get the user group name

$ groups $(whoami) | cut -d' ' -f1

Get the UID of the user

$ id $(whoami) | cut -d' ' -f1

Set directory and file ownership

$ sudo chown -R $(whoami):staff /path/to/folder

Set user to a file

$ echo "User" $(whoami) >> me.txt

Echo the Apache settings to a file

$ echo "<IfModule unixd_module>" > me.txt
$ echo "    User" $(whoami) >> me.txt
$ echo "    Group staff" >> me.txt
$ echo "</IfModule>" >> me.txt

Git tag commands

git tag -a v2.1.4 5c91e9f -m ":rocket: Version 2.1.4 Release."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment