This command disables the default shadow if you take a screenshot of a window. Especially if you take a screenshot, using ⌘ + ⇧ + 4 + Space, this comes in handy.
# Disable Shadows
defaults write com.apple.screencapture disable-shadow -bool TRUE
killall SystemUIServer
# Enable Shadows
defaults write com.apple.screencapture disable-shadow -bool FLASE
killall SystemUIServerAvoid Desktop Cluttering by putting your Screenshots in its own dedicated folder.
Replace ~/Desktop/Screenshots with your folder location.
defaults write com.apple.screencapture location ~/Desktop/Screenshots
killall SystemUIServerThis command lets you select test directly from QuickLook to quickly copying text from a file without opening it. However, some files do not let you copy text from it.
# Enable text selection
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
killall Finder
# Disable text selection
defaults write com.apple.finder QLEnableTextSelection -bool FALSE
killall FinderSometimes your “Open with …” menu can be cluttered by the same application multiple times. To remove the duplicates, simply use this command.
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user# Set save location to HD
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool FALSE
# Reset save location to iCloud
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool TRUEView hidden files
# Show hidden files
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
# Reset
defaults write com.apple.finder AppleShowAllFiles -bool FALSEAll of these actions use the shutdown command with different flags. -r is for restart, -h is for shutdown (halt) and -s is for sleep. All of these commands take a specific time. You can use the keyword now to execute the command immediately, +number to restart in the given amount of minutes relative from now, or you can define a specific date/time in the format yymmddhhmm, while year, month and day default to the current system values.
# Put mac to sleep in 60 minutes from now
sudo shutdown -s +60
# Shutdown now
sudo shutdown -h now
# Restart on 16th March 2015 at 16:20 (yymmddhhmm)
sudo shutdown -r 1503161620
# Restart today at 17:20
sudo shutdown -r 1720If your mac is in sleep mode, you can schedule a wake up call at a given time.
# Wake up your mac from sleep on 1st January 2017 at 20:00
pmset schedule wake "01/01/2017 20:00:00"Sometimes you need to prevent your mac to go to sleep. Instead of altering your energy saving settings, you can just use the caffeinate command. If just type in caffeinate without any flags, it will run until you cancel it with Ctrl + C
# Start imediately, cancel with Ctrl + C
caffeinate
# Prevent to sleep for 600 seconds (10 Minutes)
caffeinate -u -t 600Caution: Avoid using this on SSDs. They have a limit number of reads/writes to a disk, so this can drastically shorten its lifespan. If you need to use it, keep the level as low as possible.
If you delete a file, it is flagged free for overwriting. This means it is still on the HD until the place is needed and the file will be overwritten. This means, special tools may be able to recover the files, that are not overwritten, which is a bad thing if you want to sell your mac. Use this command to overwrite the free space with empty data to ensure that nobody can recover the contents of your HDD.
The number after freespace defines the level of security. You can choose one of the following:
0 - Single-pass zero-fill erase.
1 - Single-pass random-fill erase.
2 - US DoD 7-pass secure erase. (US Department of Defense's standard)
3 - Gutmann algorithm 35-pass secure erase. (Overwrite files 35 times)
4 - US DoE algorithm 3-pass secure erase.
# Overwrite free space on Macintosh HD 7 times
diskutil secureErase freespace 2 "/Volumes/Macintosh HD"Creates a file with a specific size (1mb in this case). You can use any extension you want.
mkfile 1m test.tmpYou can base64 encode any file with this command. It creates a copy of the file with a new name in the same destination.
base64 lato-regular.ttf -o latoregular-base64.txtThis is a simple backup method using rsync. The BackupFolder gets copied from the Volume SourceVolume to the Volume TargetVolume. The --delete flag removes all files that have been deleted on the source folder. The -aE flag makes sure permissions and metadata are included in the copy.
rsync -aE --delete "/Volumes/SourceVolume/BackupFolder" "/Volumes/TargetVolume"