MAC command Line Daquan

Source: Internet
Author: User

OSX's File system
OSX uses the Unix file system, all the files are hanging in the directory/below, so there is no need to have the concept of the drive letter under Windows.
The hard drives you see on the desktop are hung under/volumes.
For example, after a mobile drive called USBHD, the desktop will show a hard disk icon, where is it actually?
Execute LS/VOLUMES/USBHD in the terminal to see if the contents of this mobile 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
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, and the CD system means to go to the system in the current directory
——————————————————————————————————————————————
How to enter command line operation mode
In the graphical interface, open the Application utility terminal with the 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 permission 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.
——————————————————————————————————————————————
Basic commands
List files
LS parameter directory name
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
Cd
Example: Think of a drive directory to stroll around
Cd/system/library/extensions
Create a new directory
mkdir Directory Name
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 files
CP parameter source file destination file
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
deleting files
RM parameter File
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 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
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
Change file Owner
Chown parameter User: Group file
Example: Change all the files in the drive directory to the root user
Chown-r root:wheel/system/library/extensions
Parameter r indicates a recursive operation
Fix permissions on files throughout the system
Diskutil repairpermissions/
Strictly speaking, this is not a Unix command, but OSX is a software that remembers the modification or addition of the driver to execute once.
Text editing
Nano file name
Example: Edit Natit info.plist
Nano/system/library/extensions/natit.kext/info.plist
After editing, use Ctrl +o to save, ctrl+x exit
Another text editing software is VI, the operation is a bit odd, cooked is very useful, and in all Unix-like systems, it is not afraid to go all over the world.
Run script command
SH Script file name
Example to modify the driver after all the required operations into a script, after the driver has been modified to run once this script is OK, convenient
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
————————————————————————————————————
Little Tricks
Use the Tab key to auto-complement commands
For example, think of the/system directory, enter the Cd/sy and then press the TAB key, the command will automatically fill into equal Cd/system
Manipulate files and directories with spaces in the name
Spaces are written in the command, for example, to enter My Documents, the command is CD My Documents
View detailed help for a command
Man command name

For example, to see the detailed use of the LS command, execute the man ls

MAC command Line Daquan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.