Mac OS Command Reference

Source: Internet
Author: User
Tags clear screen dbx disk usage

1.
How to enter command line operation mode
In the graphical interface, open the Application utility terminal with the Finder
or press F8 at boot, start with the-s parameter, and 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.
2.
Defaults Write Com.apple.finder appleshowallfiles-bool True This command shows hidden files
Defaults Write Com.apple.finder appleshowallfiles-bool false This command turns off show hidden files
3.
Link network server (server has SSH installed)
SSH [email protected][server IP or domain name] then enter the next prompt for the password, the password is entered correctly OK
4.
User folder location/user/user name
The location of the desktop/user/user name/desktop
File wildcard character Asterisk *
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

5.
View catalog Details
Ls/system/library/extensions
Parameter-W displays Chinese,-l details,-a including hidden files
6.
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
7.
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
8.
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
9.
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
10.
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
11.
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.
12.
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.
13.
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
First, run Nano/clean in the terminal
Then, 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/
Then Ctrl +o disk, ctrl+x exit
As soon as the drive is driven, it runs once in the terminal Sh/clean

14.
Typical Operating Procedures
(assuming you've made a clean script, remember to sudo-s get system permissions before each operation)
Suppose you download a video card driver Natit.zip, the desktop decompression to get a natit.kext, how to do it?
For the sake of insurance, back up all the drivers first.
mkdir/user/User name/desktop/backup Create a backup folder on the desktop
Cp-r/system/library/extensions/*/user/User name/desktop/backup backup driver file
Now you can install it safely.
Cp-r/user/user name/desktop/natit.kext/system/library/extensions copy it to the system-driven directory location
Sh/clean Execute cleanup Script, Operation complete
Re-boot failed, into the desktop, found that should not be the driver, how to recover it?
Power on F8, start with-s parameter
Execute MOUNT-UW/
rm-rf/user/User name/desktop/natit.kext Delete this driver
Sh/clean Execute cleanup Script, Operation complete
Restart, back to the original state, do not forget Ah, no special effects how to do it, and heard the need to modify the Natit Info. plist file is fine.
Cp-r/user/user name/desktop/natit.kext/system/library/extensions copy it to the system-driven directory location
Nano/system/library/extensions/natit.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/natit.kext/user/user name/desktop/gooddrivers backup
This sound card requires Applehda.kext to delete and edit the Appleazaliaaudio.kext in the Info.plist file, who knows later will not still use AppleHDA it, rather temporarily disable it.
mkdir/system/library/extensions/disabled Creating a disabled directory
Mv/system/library/extensions/applehda.kext/system/library/extensions/disabled move Past
Nano/system/library/extensions/natit.kext/appleazaliaaudio.kext/info.plist
After editing, use Ctrl +o to save, ctrl+x exit
Sh/clean Execute cleanup Script, Operation complete
Successful, but also put the modified driver back up
Copy content to Clipboard code:


The following is the UNIX command line, for reference (command-description-example):
1. Directory Operations
Mkdir
Create a Directory
mkdir dirname

RmDir
Delete a directory
RmDir dirname

Mvdir
Move or rename a directory
Mvdir Dir1 Dir2

Cd
Change the current directory
CD dirname

Pwd
Displays the path name of the current directory
Pwd

Ls
Display the contents of the current directory
Ls-la

dircmp
Compare the contents of two directories
DIRCMP Dir1 Dir2


2. File operation

Cat
Show or connect files
Cat filename

Pg
Paging formatted display of file contents
PG filename

More
Split-screen display of file contents
More filename

Od
Display the contents of a non-text file
od-c filename

Cp
Copy a file or directory
CP file1 File2

Rm
Delete a file or directory
RM filename

Mv
Change the file name or directory
MV File1 File2

ln
Join file
Ln-s file1 file2

Find
Finding files using matching expressions
Find. -name "*.C"-print

File
Show file types
File filename

Head
Show the first few lines of a file
head-20 filename

Tail
Display the last few lines of a file
tail-15 filename

Cut
Display some fields in each row of a file
Cut-f1,7-d:/etc/passwd

Colrm
Remove several columns from standard input
COLRM 8 File2

Paste
Cross-connect files
Paste File1 file2

Diff
Compare and display the differences of two files
diff File1 File2

Sed
Non-interactive mode flow editor
Sed "s/red/green/g" filename

Grep
Find in Files by pattern
grep "^[a-za-z]" filename

Awk
Find and manipulate patterns in files
awk ' {print '} ' filename

Sort
Sort or Merge files
sort-d-f-u File1

Uniq
Remove duplicate rows from a file
Uniq file1 file2

Comm
Public and non-public rows showing two ordered files
Comm File1 File2

Wc
The number of characters, words, and lines of a statistic file
WC filename

nl
Add a line number to a file
NL file1 >file2

passwd
Modify User Password
passwd

chmod
Change permissions for a file or directory
chmod ug+x filename

Umask
Define a permission mask to create a file
Umask 027

Chown
Change the owner of a file or directory
Chown newowner filename

Chgrp
Change the owning group of a file or directory
CHGRP staff filename

Xlock
To lock the terminal
Xlock-remote


Make
Maintaining the latest version of an executable program
Make

Touch
Update file access and modification times
Touch-m 05202400 filename

Dbx
Command line interface Debugging Tools
DBX a.out

Xde
Graphical user interface Debugging Tools
Xde a.out


Ps
Show the current status of the process
PS u

Kill
Terminating a process
Kill-9 30142

Nice
Change the priority of the pending command
Nice cc-c *.c

Renice
Change the priority of a running process
Renice +20 32768

3. Time Operation:
Date
Displays the current date and time of the system
Date

Aa.
Show Calendar
Cal 8 1996

Time
Execution time of the statistical program
Time A.out

4. Network and communication operations:
Telnet
Telnet
Telnet hpc.sp.net.edu.cn
Rlogin

Telnet
Rlogin hostname-l username
Rsh

Execute the specified command on the remote host
RSH f01n03 Date
Ftp

Transferring files between a local host and a remote host
FTP ftp.sp.net.edu.cn
Rcp

Copying files between a local host and a remote host
rcp file1 host1:file2
Ping

Send a response request to a network host
Ping hpc.sp.net.edu.cn
Mail
Read and send e-mail
Mail

Write
Send a message to another user
Write username PTS/1

Mesg
Allow or deny receiving of messages
MESG N

Korn shell command

History
List several recently executed commands and numbers
History

R
Repeatedly executes a command that has been recently executed
R-2

Alias
To define an alias for a command
Alias Del=rm-i

Unalias
To cancel the definition of an alias
Unalias del

5. Other commands:
Uname
Displays information about the operating system
Uname-a

Clear
Clear screen or window contents
Clear

Env
Show all currently set environment variables
Env

W.H.O.
List all users who are currently logged on
W.H.O.

WhoAmI
Displays the user name that is currently in action
WhoAmI

Tty
Displays the name of the terminal or pseudo terminal
Tty

Stty
Display or reset control key definitions
Stty-a

Du
Querying disk usage
Du-k SubDir

Df
Displays the total and free space of the file system
Df/tmp

W
Displays the total information for the current system activity

Mac OS Command Reference

Related Article

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.