laptop

All macOS features are well thought out and their settings are optimal for most users. However, with Terminal commands, you can change the behavior of the system and expand its capabilities. And in some cases, this can be very useful.

Showing hidden files and folders in the Finder
It is not often that you need to see the hidden files on your disk. By default they are not displayed in the Finder, and you have to use a special command to see them.

How to enable:
defaults write com.apple.finder AppleShowAllFiles -bool TRUE && killall Finder

How to disable:
defaults write com.apple.finder AppleShowAllFiles -bool FALSE && killall Finder

Hiding files and folders
If you want to, you can also hide the private data on the disk from prying eyes. The chflags command is used for this. After that, you should enter the path to the file or folder that you want to hide. To avoid entering the path, you can simply type the command and then drag and drop the desired folder into the Terminal window.

How to enable:
chflags hidden ~/Desktop/Secret folder

How to disable:
chflags nohidden ~/Desktop/Secret folder

Copying text in the Viewer
Pressing the space bar in Finder opens a quick preview of the files. It’s very convenient to check the contents of text documents this way. Except that selection doesn’t work in this window – you have to open the document to copy text. To avoid wasting time on this, activate the highlighting feature for quick view.

How to turn it on:
defaults write com.apple.finder QLEnableTextSelection -bool TRUE && killall Finder

How to disable:
defaults write com.apple.finder QLEnableTextSelection -bool FALSE && killall Finder

Downloading files without a browser
You don’t have to use Safari or Chrome to download a file using a link from the internet. Sometimes it is much faster and easier to do this through “Terminal” with the curl command.

How to use:
curl -O https://get.videolan.org/vlc/3.0.3/macosx/vlc-3.0.3.dmg

Create a file of any size
It is convenient to test the speed of data transfer over the network or from external media by copying files. Searching for a movie or an image of the right size for this purpose takes a long time, so it’s much easier to create a test file using the mkfile command. You can set the desired size with a number and the symbols b, k, m or g, which stand for bytes, kilobytes, megabytes and gigabytes, respectively.

How to use:
mkfile 1g test.abc