Useful macOS commands you need to know

Posted on by

These are the commands that I would certainly use while working with macOS. Use Terminal or iTerm app to run commands.

1. How to change screenshots location in macOS?

For those who work a lot with taking screenshots and annotating them it is very useful to have folder to store screenshot rather than having them on desktop.

To change the default screenshot location use this command, where /path/ is the target folder.
defaults write com.apple.screencapture location /path/;killall SystemUIServer

Revert to default setting
defaults write com.apple.screencapture location ~/Desktop/;killall SystemUIServer

2. How to show hidden files in macOS?

To output hidden files use this command:
defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder

To hide hidden files (default setting) use this command:
defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder

3. Out of free space? Run this command from /Users/ folder and follow down to find out where space is taken,

du -sk * | sort -g | awk '{ numBytes = $1 * 1024; numUnits = split("B K M G T P", unit); num = numBytes; iUnit = 0; while(num >= 1024 && iUnit + 1 < numUnits) { num = num / 1024; iUnit++; } $1 = sprintf( ((num == 0) ? "%6d%s " : "%6.1f%s "), num, unit[iUnit + 1]); print $0; }'

Comments

Leave a comment

Your email address will not be published.
Required fields are marked *