macOS is a Unix-based operating system, which is similar to Linux, but when we use the mac system, it is not all command-line like Linux. This is because Apple has built a gorgeous user interface on the basis of Unix. We use Mac In fact, it is still interacting with the underlying operating system through the operating interface.
Start terminal
"Terminal" is in the "Utilities" directory of the application. You can find "Utilities" in the startup console. Click on it, find the terminal, and click to start. You can also quickly start the "terminal" by focusing and searching. Enter the shortcut key Comman+space into the terminal and press Enter to start.
Common terminal commands
A cd to enter the directory
After the terminal is started, it is in the user directory by default. Use the cd command to enter the directory you want to enter.
For example, enter the command cd ~/Desktop/ and press Enter to enter the desktop directory.
The ~ symbol is a shortcut to the user directory. For example, your user name is macz, and the ~ symbol is the abbreviation of /Users/macz.
What to do if the directory is too deep, you can drag the directory or file directly into the terminal, and the terminal will automatically generate the path for you.
Enter the upper-level directory as cd ../, of course you can enter ../../ to enter the upper-level directory
Enter the first letter of the folder and press Enter to automatically complete the directory name.
Two view the current directory file
Use the ls command to view files in the current directory
ls -AF can display all files, including hidden files and directories
ls -l displays file information such as permissions, file size, workgroup, etc. in addition to the file name
ls -r sorted display by English name
ls -t sorted by time
Three Quickly view text files
Use the cat command to quickly view the content of the text file, so that it does not need to be opened through an editor, which is more convenient
Four view network information
Use the ifconfig command to view the information of each network card on the mac computer
Five detection of website network
Use the ping command to check whether the website can be connected. For example: input ping www.macz.com to check the connection between your computer and the website. If the ping value is relatively small, it means that the connection is very good. If the ping value is relatively large, it means that the delay is high. If there is a lost situation, it means that there is packet loss.