Generally, terminal applications are often used only by high-end users. This does not mean that the command line is very difficult to learn. Sometimes, the command line can easily and quickly solve the problem. I believe that all Mac users have tried the command line. Today, we have nine very practical command line operations. Some command lines can be used only after xcode is installed. xcode is available for free in MAC app store.
1. Use caffeinate to prevent mac from running Screen Protection and sleep
Caffeinate can prevent mac from entering sleep state, and screen protection will not be activated. We 'd better use-t to add the specific time for the command. For example, the following command does not enable Mac to sleep for an hour.
- Caffeinate-T 3600
Copy code
2. Use pkgutil to decompress the PKG File
To view a special file in the PKG Installation File, run the pkgutil command. The following command will decompress the macx. PKG file to the desktop
- Pkgutil -- expand macx. PKG ~ /Desktop/
Copy code
3. Use the purge command to release memory
The purge command can clear the cache of memory and hard disk, which is similar to restarting Mac. The purge command can convert inactive system memory to available memory. You only need to enter the following command in the terminal.
Purge
4. Use the open command to open multiple identical applications
The open command can enable the application on the terminal, and use-N to enable multiple identical applications. For example, you can use the following command to open the new Safari window.
- Open-N/applications/safari. APP/
Copy code
5. Update OS X without using App Store
Do you want to update the system but do not want to open a bloated Mac App Store? The following command can help you use the terminal to upgrade OS X.
- Sudo softwareupdate-I-
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 shadow a file or folder, you can run the chflags command. You only need to fill in the correct file path, for example, to hide the macx folder on the desktop. If you want to see the folder again, you only need to change hidden to nohidden.
- Chflags hidden ~ /Desktop/macx
Copy code
8. automatically enter the file path
Do you know how to drag any file from the Finder to the terminal window to obtain the detailed path of the file. If you want to enter the path of a file, drag and drop the file.
9. Create a compressed file with password protection
You can create a password-protected file protected.zip using the following commands.
- Zip-e protected.zip ~ /Desktop/macx.txt
Copy code
References:
Document address