Basic concepts
OS X is a UNIX file system, all files are hung under the directory "/", so there is no concept of the drive letter under Windows. For example, "C:" The hard disk you see on the desktop is hung under/volumes.
For example, a mobile hard disk called "XX", the desktop will show a hard disk icon, where is it actually?
Execute in Terminal: "Ls/volumes/xx" to see if the contents of this mobile drive are displayed.
Drive Location:/systme/library/extensions
User folder location:/user/User Name
Desktop Location:/user/User name/desktop
Root directory Location:/core Mach_kernel file wildcard character asterisk *
Note: In UNIX systems, there is a difference between uppercase and lowercase characters, and A.txt is not equal to a.txt. Root flag/Not dispensable, cd/system means to go to the system under the directory, while the CD system means to go to the system in the current directory.
Enter command line operation mode
Under the graphical interface, open applications > Utilities > Terminal with Finder
If even the graphical interface can not be entered (such as the wrong display driver), when the boot press F8, start with the-s parameter, and then enter the command MOUNT-UW/
Get permission
In order to prevent misoperation to destroy the system, then the user state when there is no access to the operating system important files, so first to get root permissions: "Sudo-s"
Then enter the password, enter the password without any echo, even the asterisk is not, just lose the return on the line.
Here are some common commands ~
To clean up the system-----use the following command: sudo periodic daily then enter the administrator password. If you change the daily to weekly, the weekly cleanup is run. Change to monthly, is to do monthly cleanup. If you enter directly: sudo periodic daily weekly monthly and then enter. is to make three clear.
List files----ls
Example: Want to see what is in the directory,
LS/
Want to see what's in the drive directory,
Ls/system/library/extensions
Parameter-W displays Chinese,-l details,-a including hidden files
Converting catalogs----CDs
Example: Want to see the files under the drive directory
Cd/system/library/extensions
Create a new catalog----mkdir
Example: Create a backup directory in the driver directory
Mkdir/system/library/extensions/backup
Build a backup directory on the desktop back up
mkdir/user/User name/desktop/backup
Copy file----CP
Example: Want to copy the desktop Natit.kext to the drive directory
Cp-r/user/User Name/desktop/natit.kext/system/library/extensions
The parameter R indicates a recursive operation of the directory, and Kext looks like a file under the graphical interface, which is actually a folder.
Back up all files in the drive directory to desktop backup
Cp-r/system/library/extensions/*/user/User name/desktop/backup
Move file----MV
Example: Want to move Applehda.kext to the desktop
mv/system/library/extensions/applehda.kext/user/User name/desktop
Want to move the Applehda.kext to the backup directory
Mv/system/library/extensions/applehda.kext/system/library/extensions/backup
Delete File----RM
Example: To delete a driver's cache
Rm-rf/system/library/extensions.kextcache
Rm-rf/system/library/extensions.mkext
Parameter-RF is recursive and mandatory, be careful to use, if executed "RM-RF/" Your system is all gone.
Change file permissions----chmod
Example: Set all files in the drive directory to root read/write, other users read only
Chmod-r 755/system/library/extensions
The parameter R is recursive, and 755 represents the permissions of each user
Script file name----sh
Example: Modify the driver after all the required operations into a script, after the driver has been modified to run once this script can be.
1. Running Nano/clean in terminal
2. Paste the following code into the 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. Ctrl +o disk, ctrl+x exit
4. Once the driver is moved, run it once in the terminal Sh/clean
Did you see the blackout? This is only a part of it, hehe, to give a specific example of the usual, I will try to use the above command ~
(Remember to sudo-s get system privileges before each operation)
Example: For example, we downloaded a video card driver Weiphone.zip, the desktop decompression got a weiphone.kext, how to do it? The steps are as follows:
A: 1. Back up all drivers first, this seems to be a habit problem, but often good habits can solve a lot of unnecessary problems,
Method: mkdir/user/The user name/desktop/backup create a backup folder on the desktop
Cp-r/system/library/extensions/*/user/User name/desktop/backup backup driver file
2. Installation
Method: Cp-r/user/user name/desktop/weiphone.kext/system/library/extensions copy it to the system-driven directory location
Sh/clean Execute cleanup Script, Operation complete
This step often has problems, the reasons may be many, but I am sure that your own problems, hehe ~
Remedy: Boot by F8, start with-s parameter
Execute MOUNT-UW/
rm-rf/user/User name/desktop/weiphone.kext Delete this driver
Sh/clean Execute cleanup Script, Operation complete
Restart, back to the original state, graphics card without special effects how to do, you need to modify the Natit Info. The plist file is not OK.
Cp-r/user/user name/desktop/weiphone.kext/system/library/extensions copy it to the system-driven directory location
Nano/system/library/extensions/weiphone.kext/info.plist
After editing, use Ctrl +o to save, ctrl+x exit
Sh/clean Execute cleanup Script, Operation complete
Restart, this time, the Carter effect has been, the sound card, God knows what will happen, we have to protect the existing results.
mkdir/user/User name/desktop/gooddrivers to create a directory for valid drivers
Cp-r/system/library/extensions/weiphone.kext/user/user name/desktop/gooddrivers backup
After editing, use Ctrl +o to save, ctrl+x exit
Sh/clean Execute cleanup Script, Operation complete
Successful, also put the modified driver back up a bit.
--------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------
The following method is for those who often toss the computer's students ~
Q: What if we mess up all the drivers?
A: It's okay, if we do. Back up all driver files
Power on F8, start with-s parameter
Execute MOUNT-UW/
rm-rf/system/library/extensions/*, if you mess up, kill them all.
Cp-r/user/User name/desktop/backup/*/system/library/extensions/Copy the original drive back
Cp-r/user/User name/desktop/gooddrivers/*/system/library/extensions/Copy the modified driver back.
Sh/clean Execute cleanup Script, Operation complete
Get!
Q: How does Mac OS X enable super users?
A: first literacy, noun interpretation: root user, aka Superuser, is the most powerful Unix account, the root account can be any part of the entire system to do any "operation", including: Copy files, move/Remove files, execute programs and so on. Therefore, the usual Root account will only be assigned to advanced professional users. Therefore, Apple hides the root user in Mac OS x.
But sometimes we have to enable the root user in order to implement certain operations, you can start the root account in the following three ways.
Still want to wordy: root user Nothing is best not to mess up, equivalent to do internal medicine surgery, not good will be big.
Method One:
You can change your password and start the Superuser mode by placing the Mac OS X CD-ROM into the CD-ROM drive, booting the system with the disc, and selecting the "Password Reset" option in the Install menu. (Copying this tool to the hard drive is not possible, so be sure to boot from the disc.) ) Recommended Index * * *
Method Two:
Launch Terminal (in the Applications/Utilities folder) in Mac OS X and enter the following command:
sudo passwd Root
You will be asked to enter the Root user's new password in real time and then enter it again to ensure that the password is correct. Suggested Index * * * *
Method Three:
Start the NetInfo Manager application (in the Applications/Utilities folder), and then follow these steps:
1. From the menu, select "Domain" → "user" → "Start root user"
2. Click the "Lock" button at the bottom of the window and enter the user name and password that you provided during the installation process.
3. Select the * number from the list in the lower part of the window and enter the new password that the Root user has encrypted.
You can enter the following "htpasswd" command in Terminal to generate the new encrypted password:
[localhost:~] currentuser% htpasswd-nb anylogin YourPassword
[Return]
[localhost:~] currentuser% ANYLOGIN:PU9FQGDZVHRB2
PU9FQGDZVHRB2 is the new password that has been encrypted
4. Click the "Lock" button at the bottom of the window, then save the changes and leave NetInfo Manager.
You can now try the Root user's new password in Terminal recommended index * * *
Q: How to remove files that cannot be deleted in Finder via terminal commands
A: Here I first introduce a recurring question. Someone often for some reason. For example, the crash, file download half unexpectedly back, when there are often files can not be deleted, the system prompts you insufficient authority. At this point we can use a simple one-line command to delete.
1. Open the terminal application
2. Enter command: sudo rm-r-F "You want to delete the file"also note that the terminal commands are case-sensitive, all lowercase。
3. Drag the file or folder you want to delete into the terminal window with mouse, and many more can be dragged together.
4. Then enter in the terminal
5. Enter the current Admin user password. If you don't have a password, enter directly. Note The password is not the root account.
6. There are no messages in the terminal indicating successful deletion
Note: If you cannot delete this command, there are two possibilities: one is to delete the temporary files that the system is using. The second is that there may be a problem with your hard drive directory. Please check your hard drive with the disk utility first.
Explanation: sudo command: Before any command can be added Sudo,sudo represents administrator rights, can directly manage the system of the more important files, general use need to ask for password. After you enter the administrator password, you can complete the operation.
Shutdown command----sudo shutdown-h now
Sometimes the system problem shutdown is not successful can try to test the command line shutdown, after all, the bare power is not good. At first my machine sometimes crashed and I just shut it down with the command line. The weird thing is that since I just bought a machine, I've been dead 2 times before. The terminal can also use the halt command to implement shutdown with other parameters, but the recommended shutdown~
Hide File Command----Hide File command: As if there is a plugin under the Mac to show hidden files, as for the hidden file plugin I have not heard of. But I thought that since I was trying to hide the file, the goal was not to like others to find out, of course, the complexity is better. The MV command is used to move the file, but if it is still under the same path, it is usually named "." In the Mac. The beginning of the file is a hidden file, so we can use the MV command to achieve file hiding. For example, there is a file named tool, I want to hide, you should go to the tool path, such as tool in the program folder, you should go to the program folder to use
MV Tool. Tool
Implements the tool's hiding. The same as MV. Tooltool can realize the display of hidden tool. In the program folder mentioned here, it is necessary to use the CD command. In the Linux/unix system, the top-level directory is called the root directory, and any directory is always under the root directory, such as program may be "/home/program/tool", so we only need to
Cd/home/program
The tool can be hidden. "CD." Indicates that the operation of this level directory is not changed, "CD.." Returns to the parent directory, such as "Cd/home/program" after "CD." Represents to the home folder. Show hidden files, to display hidden files under a folder, use the "CD" to the folder under the command
Ls-a
You can see that all the files under that folder contain hidden files.
MAC OS Terminal Terminal Common commands