Input: Sudo/applications/textedit.app/contents/macos/textedit/etc/hosts can edit the hosts directly with text editing.
Whether the hidden file shows a number of ways to set up, the simplest to be counted in the Mac Terminal Input command. Show/Hide the Mac hidden files command as follows (note the spaces and case sensitivity):
command to display Mac hidden files: Defaults write Com.apple.finder appleshowallfiles-bool true;
Hide the Mac hidden file command: Defaults write Com.apple.finder appleshowallfiles-bool false;
Or
Displays the Mac hidden file command: Defaults write Com.apple.finder appleshowallfiles YES;
Hide the Mac hidden file command: Defaults write Com.apple.finder appleshowallfiles NO;
After you have finished, click Enter to exit the terminal and restart the finder.
Restart Finder: Mouse clicks the apple flag in the upper left corner of the window--> Force exit-->finder--> reboot;
Mac OS X terminal Screen shortcuts: cammand+k (Clear is not really for birds)
Linux system Clear Screen shortcut key: ctrl+l (reset)
Windows command line Clear-screen command: CLS
The Unix file system used by OS X, all files are hung in the root directory/below, so there is no longer a letter concept under Windows.
The hard disk you see on the desktop hangs under the/volumes.
For example, a mobile hard disk called USBHD, the desktop will show a hard disk icon, where is it actually?
Perform LS/VOLUMES/USBHD in the terminal to see if the contents of this removable hard drive are displayed.
root directory location is/core Mach_kernel right here,
Drive Location/systme/library/extensions
User folder location/user/user name
The location of the desktop/user/user name/desktop
The file wildcard character is an asterisk *
Note: In UNIX systems, the difference between uppercase and lowercase characters is A.txt not equal to A.txt.
Root flag/Not dispensable, Cd/system represents go to system under Directory, and CD system represents go to system in current directory
——————————————————————————————————————————————
How to get into command line operation mode
In the graphical interface, use the Finder to open the Application utility terminal
If even the graphical interface is not going to go (for example, the wrong display driver), press F8 on the power-on, start with the-s parameter, and then enter the command MOUNT-UW/
Get permission
In order to prevent the misuse of the system, the user state does not have the right 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 line.
——————————————————————————————————————————————
Basic commands
Listing files
LS parameter directory name
For example: Want to see what's in the catalogue,
LS/
Want to see what's in the driver directory,
Ls/system/library/extensions
Parameter-W displays Chinese,-l details,-a includes hidden files
Convert Directory
Cd
Example: Think of a drive directory to stroll around
Cd/system/library/extensions
Create a new directory
mkdir Directory Name
Example: Build a backup directory in the driver directory backup
Mkdir/system/library/extensions/backup
Build a backup directory on the desktop
mkdir/user/User name/desktop/backup
Copy files
CP parameter source file destination file
Example: To copy the desktop Natit.kext to the driver directory
Cp-r/user/User Name/desktop/natit.kext/system/library/extensions
The parameter R represents a recursive operation of the directory, and Kext appears to be a file under the graphical interface and is actually a folder.
Back up all files in the driver directory to desktop backup
Cp-r/system/library/extensions/*/user/User name/desktop/backup
deleting files
RM parameter file (RM-RF folder)
Example: To delete a driven cache
Rm-rf/system/library/extensions.kextcache
Rm-rf/system/library/extensions.mkext
Parameter-rf means recursion and coercion, be careful to use, if executed RM-RF/your system is all gone
Moving files
MV File
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
Change file permissions
chmod parameter permission file (#add CH rep Change)
Example: Set all files in the driver directory to root read and write, other users read only
Chmod-r 755/system/library/extensions
Parameter R represents recursion, and 755 represents the permissions of each user
Change file Owner
Chown parameter User: Group file
Example: Change all files in the driver directory to root user
Chown-r root:wheel/system/library/extensions
Parameter R represents recursive operations
To fix permissions on files throughout the system
Diskutil repairpermissions/
Strictly speaking this is not a UNIX command, but OS X software, remember to modify or add the driver to execute once.
Text editing
Nano filename
Example: Edit Natit info.plist
Nano/system/library/extensions/natit.kext/info.plist
Save after editing with Ctrl +o, ctrl+x exit
Another text editing software is VI, the operation is a bit strange, cooked is very useful, and in all Unix-like systems, it is not afraid of the world.
Run script command
SH script filename
Example to modify the driver after all the required operations to save as a script, after the driver modified to run once the script is OK, convenient
1. Running Nano/clean in the 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. In the future, as long as the drive, in the terminal run once Sh/clean
————————————————————————————————————
Small Tips
Use the Tab key to automatically make up commands
For example, think of the/system directory, input cd/sy and then click the TAB key, the command will automatically fill into equal Cd/system
Manipulate files and directories with spaces in the name
Spaces in the command written in space, such as to enter My Documents, the command for the CD My Documents
View detailed help for a command
Man command name (#add manual)
For example, to see the detailed usage of the LS command, execute man LS
————————————————————————————————————
Typical operation Process
(assuming that the cleanup script has been made, remember that sudo-s get system permissions before each operation)
Suppose download a video card driver Natit.zip, in the desktop decompression got a natit.kext, how to do?
To be on the safe side, first back up all the drivers.
mkdir/user/user name/desktop/backup set up a backup folder on the desktop
Cp-r/system/library/extensions/*/user/User name/desktop/backup backup driver file
Now you can safely install the
Cp-r/user/username/desktop/natit.kext/system/library/extensions Copy it to the system-driven directory location
Sh/clean Execute cleanup Script, Operation complete
Reboot failed, do not go to the desktop, found that should not Ann this drive, how to restore it?
Boot press F8, start with the-s parameter
Perform MOUNT-UW/
rm-rf/user/User name/desktop/natit.kext remove this driver
Sh/clean Execute cleanup Script, Operation complete
Restart, back to the original state, do not forget Ah, no special effects how to line it, and heard that need to modify the Natit Info. plist file, okay, then.
Cp-r/user/username/desktop/natit.kext/system/library/extensions Copy it to the system-driven directory location
Nano/system/library/extensions/natit.kext/info.plist
Save after editing with Ctrl +o, 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, the existing results to protect good.
mkdir/user/username/desktop/gooddrivers A directory for effective drivers
Cp-r/system/library/extensions/natit.kext/user/user name/desktop/gooddrivers backup
This sound card requires the Applehda.kext to delete and edit Appleazaliaaudio.kext in the Info.plist file, who knows later will also use AppleHDA, as a temporary ban it.
Mkdir/system/library/extensions/disabled set up a disabled directory
Mv/system/library/extensions/applehda.kext/system/library/extensions/disabled moved Past
Nano/system/library/extensions/natit.kext/appleazaliaaudio.kext/info.plist
Save after editing with Ctrl +o, ctrl+x exit
Sh/clean Execute cleanup Script, Operation complete
Successful, also put the modified driver back up to copy the contents to the Clipboard code.