In general, only high-end users will often use the terminal application. This does not mean that the command line is very difficult to learn, sometimes the command line can easily and quickly solve the problem. Believing that all Mac users have tried the command line, today brings you 9 very useful command-line operations. Some command lines need to be installed in Xcode to be practical, and Xcode is available for free in the Mac App store.
1. Use Caffeinate to prevent your Mac from running screen saver and sleep
Caffeinate can prevent your Mac from going to sleep, and screen saver won't activate. We'd better use-t to add a specific time to the command. For example, the following command can make the Mac not sleep in an hour.
CAFFEINATE-T 3600
Copy Code
2. Using Pkgutil to extract pkg files
If you want to view a special file in the PKG installation file, you can do so using the Pkgutil command. The following command extracts the macx.pkg file to the desktop
Pkgutil--expand macx.pkg ~/desktop/
Copy Code
3. Use the Purge command to free up memory
The purge command clears both the memory and the hard disk cache, similar to the effect of restarting the Mac. The Purge command allows inactive system memory to be converted into memory that can be used. You just need to enter the following command in the terminal.
Purge
4. Use the Open command to open multiple identical applications
The Open command opens the app in the terminal and uses-N to open multiple identical apps. For example, you can use the following command to open a new safari window
Open-n/applications/safari.app/
Copy Code
5. Do not update OS X from the App Store
Want to update your system but don't want to open the bloated Mac App Store? The following command can help you to upgrade OS X using a terminal.
sudo softwareupdate-i-A
Copy Code
6. List all downloaded files
We can use the following command to list all downloaded content
Sqlite3 ~/library/preferences/com.apple.launchservices.quarantineeventsv* ' Select lsquarantinedataurlstring from Lsquarantineevent ' |more
Copy Code
7. Use the Chflags command to hide files or folders
If you want to hide a file or folder, the Chflags command can be implemented. You just need to fill in the file path, like we're going to hide the Macx folder on the desktop. If you want to see the folder again, simply change the hidden to Nohidden.
Chflags Hidden ~/desktop/macx
Copy Code
8. Automatically enter file path
You know that you can get a detailed path to a file by dragging any file from the Finder to a terminal window. When you want to enter a path to a file, you may wish to drag the file to try.
9. Create a password-protected compressed file
You can use the following command to create a macx.txt file on the desktop as a password-protected compressed file protected.zip.
ZIP-E Protected.zip ~/desktop/macx.txt
Copy Code
9 Useful terminal command lines that all Mac users need to know