Let's talk about it briefly:
OSX uses UNIX file systems. All files are mounted under the directory "/". Therefore, the concept of drive letters in windows is not required. For example, what "C:" is the hard disk you see on the desktop mounted under/volumes.
For example, if a mobile hard drive named "XX" is connected, a hard drive icon is displayed on the desktop. Where is it actually?
Run "ls/volumes/xx" on the terminal to check whether the content of the mobile hard disk is displayed.
Driver location:/me/library/extensions
User folder location:/user/User Name
Desktop location:/user name/desktop
The root directory is/Core mach_kernel.
The file wildcard is asterisk *
Note: In the unixsystem, A. txt is not the same as a.txt. The root directory flag/is not dispensable. CD/system indicates to go to the system in the directory with the root directory, and CD system indicates to go to the system in the current directory.
Enter the command line operation mode
Then, use the Finder to open the application utility terminal.
If you cannot connect to the graphic interface (for example, if you have installed an incorrect display driver), press F8 at startup, start with the-S parameter, and then enter the command Mount-UW/
Get Permissions
In order to prevent misoperation and damage to the system, if the user does not have the permission to operate important files of the system, the user must first obtain the root permission.: "Sudo-S"
Then enter the password. When you enter the password, there is no echo and no star number. Just press Enter.
The following are some common commands ~
Cleaning System
----- Run the following command: sudo periodic daily, press enter, and enter the administrator password. If you change "Daily" to "Weekly", weekly cleanup is performed. Change to monthly to clean up every month. If you enter sudo periodic daily weekly monthly directly, then press Enter. It is equivalent to clearing the three together.
List Files ---- ls
For example, I want to see what is in the directory,
Ls/
Want to see what is in the driver directory,
Ls/system/library/extensions
Parameter-W displays Chinese characters,-l details,-A includes hidden files
Conversion directory ---- CD
For example, you want to view the files in the driver directory.
CD/system/library/extensions
Create a directory ---- mkdir
For example, create a backup directory backup under the driver directory.
Mkdir/system/library/extensions/backup
Create a backup directory backup on the desktop
Mkdir/user name/desktop/backup
Copy file ---- CP
For example, you want to copy the natit. kext file on the desktop to the driver directory.
CP-r/user name/desktop/natit. kext/system/library/extensions
The R parameter indicates recursive operation on the directory. kext looks like a file on the GUI, but actually a folder.
Back up all files in the driver directory to the desktop backup
CP-r/system/library/extensions/*/user name/desktop/backup
Mobile file ---- mv
For example, you want to move applehda. kext to the desktop.
MV/system/library/extensions/applehda. kext/user name/desktop
I want to move applehda. kext to the backup directory.
MV/system/library/extensions/applehda. kext/system/library/extensions/backup
Delete file ---- RM
For example, you want to delete the driver cache.
Rm-RF/system/library/extensions. kextcache
Rm-RF/system/library/extensions. mkext
Parameter-RF indicates recursion and force. Be careful when using this parameter. If you run "RM-RF/", your system will be completely gone.
Change file permissions ---- chmod
For example, set all files in the driver directory to root for read and write, while other users are read-only.
Chmod-r 755/system/library/extensions
The R parameter indicates recursion, and 755 indicates the permissions of each user.
Script File Name---- Sh
For example, after the driver is modified, all required operations are saved as a script. After the driver is modified, you only need to run the script once.
1. Run nano/clean in the terminal
2. paste the following code into Nano.
Rm-RF/system/library/extensions. kextcache
Rm-RF/system/library/extensions. mkext
Chown-r root: wheel/system/library/extensions
Chmod-r 755/system/library/extensions
Diskutil repairpermissions/
Kextcache-k/system/library/extensions/
3. Press Ctrl + O to save the disk, press Ctrl + X to exit
4. Run sh/clean once on the terminal as long as the driver is activated.
Are you dizzy? This is only part of the list ~
(Remember that Sudo-s obtained system permissions before each operation)
For example, we downloaded a video card driver weiphone.zip and obtained a weiphone. kext file from the desktop. What should we do?The procedure is as follows:
Answer: 1.Back up all drivers first. This seems to be a habit, but it is often a good habit to solve many unnecessary problems,
Method:Mkdir/user name/desktop/backup create a backup folder on the desktop
CP-r/system/library/extensions/*/user name/desktop/backup driver File
2. Installation
Method:CP-r/user name/desktop/Weiphone. Kext/system/library/extensions: copy the file to the system driver directory.
SH/clean: Execute the cleanup script. The operation is complete.
This step may often cause problems for many reasons, but I am sure it is your own problem ~ Remedy:
Method: Press f8. start with the-S parameter.
Run Mount-UW/
Rm-RF/user name/desktop/weiphone. kext Delete this driver
SH/clean: Execute the cleanup script. The operation is complete.
Restart and return to the original status. You need to modify the info. plist file of natit if the video card has no special effects.
CP-r/user name/desktop/Weiphone. Kext/system/library/extensions: copy the file to the system driver directory.
Nano/system/library/extensions/Weiphone. Kext/info. plist
After editing, press Ctrl + O to save the disk, and press Ctrl + X to exit.
SH/clean: Execute the cleanup script. The operation is complete.
Restart. By the way, all the video effects are available. It's time to get the sound card. You know what will happen, and you have to protect the existing results.
Mkdir/user name/desktop/gooddrivers create a directory for the effective driver
CP-r/system/library/extensions/Weiphone. Kext/user name/desktop/gooddrivers backup
After editing, press Ctrl + O to save the disk, and press Ctrl + X to exit.
SH/clean: Execute the cleanup script. The operation is complete.
Now, back up the modified driver.
Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Which of the following methods do you need ~
Q: What if we mess up all the drivers?
A:No, but we have backed up all the driver files.
Press f8. start with the-S parameter.
Run Mount-UW/
Rm-RF/system/library/extensions /*.
CP-r/user name/desktop/backup/*/system/library/extensions/copy the original driver back
CP-r/user name/desktop/gooddrivers/*/system/library/extensions/copy the modified driver back
SH/clean: Execute the cleanup script. The operation is complete.
Done!
Q:How does Mac OS X enable superuser?
Answer::Literacy first, Glossary: Root User, also known as Super User, is the most powerfulUNIX
The root account can perform any "operation" in any part of the system, including copying files, moving/removing files, and executing programs. Therefore, the root account is usually only assigned to senior professional users. Therefore, Apple hides the root user in Mac OS X.
However, sometimes we have to enable the root user for some operations. You can start the root account in the following three ways.
You still need to give me a comment: Root
The user has nothing to worry about. It is equivalent to having a medical operation.
Method 1:
Place the installation disc of Mac OS X into the optical drive, start the system with the disc, and select "Password Reset" in the installation menu to change your password and start the superuser mode. (Copying the tool to a hard disk cannot be started. It must be started from the disc .)
Recommendation index ***
Method 2:
Start terminal in Mac OS X (in the "Application/utility" folder) and enter the following command:
Sudo passwd Root
The system requires you to enter the new password of the root user in real time, and then enter it again to ensure that the password is correct.
Recommendation index *****
Method 3:
Start the netinfo Manager application (in the "Application/utility" folder) and follow these steps:
1. Select "Domain"> "user"> "Start root user" from the menu"
2. Click the lock button at the bottom of the window and enter the user name and password provided during installation.
3. Select * from the list in the lower part of the window, and enter the new password encrypted by the root user.
Enter the following "htpasswd" command in terminal to generate a new encrypted password:
[Localhost: ~] Currentuser % htpasswd-Nb anylogin yourpassword
[Return]
[Localhost: ~] Currentuser % anylogin: pu9fqgdzvhrb2
Pu9fqgdzvhrb2 is the new encrypted password
4. Click the lock button at the bottom of the window to save the changes and leave netinfo manager.
Now you can try the new password of the root user in terminal.Recommendation index ****
Q: How can I use terminal commands to delete files that cannot be deleted in the finder?
A: Here I will first introduce a regular problem. Sometimes for some reason. For example, if the system crashes or downloads half of the files accidentally, files may not be deleted and the system prompts that you have insufficient permissions. In this case, we can use a single line of simple commands to delete them.
1. Open the terminal application
2. Enter the command: sudo Rm-r-F "file to be deleted"
Note that terminal commands are case-sensitive and all are in lower case.
3. Drag the file or folder you want to delete into the terminal window with the mouse. You can drag multiple files or folders together.
4. Press enter in the terminal.
5. Enter the password of the current Administrator. If there is no password, press Enter. Note that it is not the password of the root account.
6. There is no prompt on the terminal indicating that the deletion is successful.
Note: If this command cannot be deleted, there are two possibilities: First, you can delete temporary files that are being used by the system. Second, there may be problems with your hard disk directory. Check your hard disk with the disk tool.
Explanation:Sudo command: You can add sudo before any command. sudo indicates that it is administrator privilege and can directly manage important files in the system. Generally, you need to ask for a password. The operation can be completed only after the administrator password is entered.
Shutdown command
----Sudo shutdown-H now
In some cases, if the system fails to shut down, you can use the command line to shut down the system.Power SupplyNot good. Initially myMachineSometimes I shut down the machine with command line. The strange thing is that since I first bought a machine, I had to die twice and never again. You can also use the halt command in the terminal to shutdown with other parameters, but we recommend that you shutdown ~
Hide file commands----
Hide file command: It seems that a plug-in MAC can display hidden files. I have never heard of the plug-in for hiding files. However, I think that since the purpose of hiding a file is not to be found by others, the complexity is better. The MV command is used to move files, but if it is still in the same path, it is renamed. "the file at the beginning is a hidden file, so we can use the MV command to hide the file. For example, if the file name is tool and I want to hide it, it should be under the tool path. For exampleProIn the "Gram" folder, it should be used in the "program" folder.
MV tool. Tool
To hide the tool. Similarly, MV. tooltool can be used to hide the tool. The CD command is required in the program folder. In Linux/Unix systems, the top directory is "/", which is called the root directory. Any directory is always under the root directory, for example, the program may be "/home/Program/tool", so we only need
CD/home/Program
You can hide the tool. "CD. "indicates that the current directory does not change," CD .. "indicates returning to the parent directory, such as" CD/home/Program "after" CD .. "To the home folder. To show hidden files, you need to display the hidden files in a folder. You can use the "cd" command to go To the folder.
Ls-
All the files in this folder include hidden files.