MACOS FUNDAMENTALS
CHEAT SHEET
macOS Fundamentals
File & Directory Commands
Command Description
defaults write com.apple.Finder Enable the setting to view hidden files
AppleShowAllFiles true && killall Finder in finder from CLI
ls Lists directory contents.
ls -l list directory contents and their
attributes
ls -la list directory contents to include
hidden files & their attributes
cd <path> Changes the directory.
clear Clears the terminal.
touch <file> Creates an empty file in your current
working directory.
mkdir <directory> Creates a new directory in your
current working directory
Command Description
mv /Users/htb-student/Documents/Test /Users/htb- Move a file from one directory to
student/Desktop/Test another
chmod -vv <octal value> <file> Modify permissions of a file and show
the results
sudo chown <userOwn>:<groupOwn> <file> Change the user and group owner of
a file
Networking Commands
Command Description
ifconfig View basic networking configurations
ifconfig <interface> View specific networking configurations of an
interface
ifconfig en0 inet <192.168.1.1> Manually set an interfaces IP address and subnet
netmask < 255.255.255.0 > mask
lsof -n -i4TCP -P View TCP ports that are bound while displaying the
application that has it bound
hostname Check the hostname of the computer
networksetup - Displays a list of all the network services (devices)
listallnetworkservices on the computer’s hardware. This will print out the
logical name of the device. (ex. Wi-Fi)
networksetup - This will print out the network services running and
listnetworkserviceorder the order in which they are queried for connection. A
service at the beginning of the list is checked first.
networksetup -getinfo <devicename> Get basic info about a networkservice (device), such
as the IP address assigned, subnet mask, gateway,
and Mac-Address.
networksetup -getcurrentlocation Prints out the currently set network location.
Command Description
networksetup -setmanual This will manually configure the IP address, network
<networkservice> <ip> <netmask> mask, and gateway for the device specified.
<Gateway>
networkQuality -I <interface> Check network speeds of a specific interface
security find-generic-password -wa Pull the password associated with a specific SSID
<SSID> from the security keychain
nc Can be used to bind ports to connect with or listen
from
Application Management
Command Description
/bin/bash -c "$(curl -fsSL Install
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" Homebrew
brew -v Display the
version/package
information for
Homebrew
brew install <package> Install a
package using
Homebrew
brew search firefox Have
Homebrew
search its
repository for a
package named
"firefox"
brew install <package> --cask Install a cask
application
brew uninstall <package> Remove a
package from
the host
Command Description
brew upgrade Upgrade
Homebrew and
all packages
installed with it
brew cleanup Cleanup old &
unused files and
applications
with Homebrew
Shell Management Commands
Command Description
.bashrc Configuration
file for Bash
.zshrc Configuration
file for Zsh
chsh -s /bin/bash Change our env
shell to Bash
brew install zsh Install zsh with
Homebrew
chsh -s /bin/zsh Change our env
shell to Zsh
alias ll='ls -l' Set an alias for
ll in the .zshrc
file
sh -c "$(curl -fsSL Install Oh My
https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" Zsh
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git Install Zsh-
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting syntax-
highlighting
Command Description
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git Install the
${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k Powerlevel-10k
theme to Zsh
brew install romkatv/powerlevel10k/powerlevel10k Install the
Powerlevel-10k
theme to Zsh
using
Homebrew
echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh- Set the theme
theme" >>~/.zshrc of our shell in
the .zshrc file