macOS Cheatsheet
#
macOS is a Unix-based operating system developed by Apple Inc. It powers all Mac computers and is known for its sleek interface, robust performance, and advanced features. Below is a comprehensive cheatsheet to help you get started with macOS, covering various commands and their descriptions.
Cheatsheet
#
Command | Description |
---|
uname -a | Display all system information |
system_profiler | Display detailed system information |
dmesg | Show system boot messages |
top | Display real-time system information |
ps aux | List all running processes |
brew list | List installed Homebrew packages |
brew install <package> | Install a Homebrew package |
brew uninstall <package> | Remove a Homebrew package |
sudo <command> | Run a command with superuser privileges |
User and Group Management
#
Command | Description |
---|
dscl . -create /Users/<username> | Add a new user |
dscl . -delete /Users/<username> | Delete a user |
dscl . -append /Groups/<group> GroupMembership <username> | Add a user to a group |
dseditgroup -o create <group> | Create a new group |
dseditgroup -o delete <group> | Delete a group |
passwd <username> | Change a user’s password |
Network Management
#
Command | Description |
---|
ifconfig | Display or configure network interfaces |
ping <hostname/IP> | Send ICMP ECHO_REQUEST to network hosts |
netstat -nr | Display the routing table |
route -n add <destination> <gateway> | Add a static route |
networksetup -listallnetworkservices | List all network services |
networksetup -setmanual <service> <IP> <subnet> <router> | Configure a network interface manually |
networksetup -setdnsservers <service> <DNS server> | Set DNS servers for a network service |
Disk Management
#
Command | Description |
---|
df -h | Display disk usage in a human-readable format |
du -sh <directory> | Show disk usage of a directory |
diskutil list | List all disks and partitions |
diskutil mount <device> | Mount a filesystem |
diskutil unmount <device> | Unmount a filesystem |
diskutil eraseDisk <format> <name> <device> | Erase and format a disk |
System Services and Daemons
#
Command | Description |
---|
sudo launchctl load /Library/LaunchDaemons/<service>.plist | Load a service |
sudo launchctl unload /Library/LaunchDaemons/<service>.plist | Unload a service |
sudo launchctl start <service> | Start a service |
sudo launchctl stop <service> | Stop a service |
sudo launchctl list | List all loaded services |
`sudo launchctl list | grep ` |
File Operations
#
Command | Description |
---|
cp <source> <destination> | Copy files or directories |
mv <source> <destination> | Move or rename files or directories |
rm <file> | Delete a file |
rm -r <directory> | Delete a directory and its contents |
chmod <permissions> <file> | Change file permissions |
chown <owner>:<group> <file> | Change file owner and group |
ln -s <target> <link> | Create a symbolic link |