[Go] Learn the common commands of Mac and help iOS development

Source: Internet
Author: User
Tags clear screen disk usage

Transferred from: http://www.jianshu.com/p/d9ec00d28237
Heavy and technical preface

In the process of iOS development, more attention to the efficiency of iOS development, familiar with the use of Mac terminal operation of the common commands, you can make a better edge in iOS heavy development. This article focuses on common Mac Terminal Basic instructions and shortcut keys, more suitable for some iOS novice learning and understanding.

File system for Mac OS X
    • Mac OS x itself is the UNIX kernel, the use of UNIX multi-user system, the UNIX file system, all files are placed under the root directory /Users , there is no concept of the drive letter under Windows, the user logged into the system, the user directory of their own general public, pictures, documents, downloads, music, Movie, site, desktop, library, OS x for Chinese users to do internationalization, open the terminal, enter ls , you will see the real directory name: Desktop、Documents、Downloads、Library、Movies、Music、Pictures、Public、Sites . Continue to enter the CD in the terminal/, switch to the root directory, type ls , so that basically you can see the full picture of the Unix directory.
      As shown in the following:

Terminal
    • Among them, some common file location highlights:
      1.驱动所在位置      /Systme/Library/Extensions ;2.桌面的位置        /User/用户名/Desktop ;3.文件通配符为星号 * 4.在 Unix系统中是区别大小写字符的,A.txt 不等于 a.txt。  根目录标志 / 不是可有可无,cd /System 表示转到跟目录下的    System中,而cd System 表示转到当前目录下的 System中 。
Basic commands common to Mac terminals
  • List files: ls 参数 目录名 Example: View driver directory: ls/System/Library/Extensions , (Parameter-w display Chinese,-l details,-a including hidden files);
  • Convert directory: cd For example: Convert to drive directory cd /System/Library/Extensions ;
  • Create a new directory: mkdir 目录名 For example, in the driver directory to build a backup, mkdir /System/Library/Extensions/backup ;
    A backup directory is built on the desktop mkdir /User/用户名/Desktop/backup ;
  • Copy files: cp 参数 源文件 目标文件 example: Want to copy the desktop Natit.kext to the drive directory, the cp -R /User/用户名/Desktop/Natit.kext /System/Library/Extensions parameter R means the directory is recursive operation, kext in the graphical interface looks like a file, is actually a folder.
    Back up all files in the drive directory to desktop backup
    cp -R /System/Library/Extensions/* /User/用户名/Desktop/backup;
  • Delete file: rm 参数 文件 example: Want to delete the driver's cache rm -rf /System/Library/Extensions.kextcache 、rm -rf /System/Library/Extensions.mkext , parameter -rf means recursion and force, execute rm -rf / your system is paralyzed;
  • Move files: mv 文件 , example: Want to AppleHDA.Kext move to the desktop mv /System/Library/Extensions/AppleHDA.kext /User/用户名/Desktop ,
    Want to AppleHDA.Kext move to the backup directory mv /System/Library/Extensions/AppleHDA.kext /System/Library/Extensions/backup ;
  • Text editing: nano 文件名 example: Editing natit Info.plist nano /System/Library/Extensions/Natit.kext/Info.plist ;
  • Directory Operations:
command name function Description Examples of Use
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
    • File operation:
command name function Description Examples of Use
Cat Show or connect files Cat 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
Find Finding files using matching expressions Find. -name "*.C"-print
File Show file types File filename
    • Select action:
command name feature description use example
head Display the first few lines of a file head-20 filename
tail display the last few lines of the file tail- [FileName
cut show files in each row of some domains cut-f1,7-d:/etc/passwd
colrm remove several columns from standard input colrm 8 file2
diff Compare and display two files Difference diff file1 file2
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 that display two ordered files comm file1 file2
WC Statistics file characters, words, and lines WC filen Ame
nl Add line number to file nl file1 >file2
    • Process actions:
command name function Description Examples of Use
Ps Show the current status of the process PS u
Kill Terminating a process Kill-9 30142
    • Time Operation:
command name function Description Examples of Use
Date Displays the current date and time of the system Date
Cal Show Calendar Cal 4 2016
Time Execution time of the statistical program Time A.out
    • Network and communication operations:
command name function Description Examples of Use
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.sp.net.edu.cn
Rcp Copying files between a local host and a remote host rcp file1 host1:file2
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
Ping Send a response request to a network host Ping hpc.sp.net.edu.cn
    • Korn shell command:
command name function Description Examples of Use
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
Rcp Copying files between a local host and a remote host rcp file1 host1:file2
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
    • Other commands:
td> to cancel the definition of an alias
command name feature description use example
uname Display information about the operating system uname-a
Clear clear screen or window contents Clear
alias define aliases for a command alias del=rm-i
unalias unalias del
who Show all currently set environment variables who
whoami Displays the user name that is currently in action whoami
TTY display the name of the terminal or pseudo-terminal Call TTY
du query disk usage du-k subdir
s TTY Display or reset the control key definition stty-a
df/tmp Show file system total and free space -
w Displays the total information for the current system activity -
  • To display the Asset Library:

    Method One:

    显示
    In terminal, enter the following command:
    chflags nohidden ~/Library/;
    隐藏
    In terminal, enter the following command:
    chflags hidden ~/Library/;

    Method Two:

    Open Finder, select the Go to Option key in the menu to display the library item (repeat the action every time you open it).

  • Finder shows hidden files
    显示隐藏文件
    In terminal, enter the following command:
    defaults write com.apple.finder AppleShowAllFiles -bool truekillall Finder;
    恢复隐藏文件
    In terminal, enter the following command:
    defaults write com.apple.finder AppleShowAllFiles -bool falsekillall Finder.

  • Xcode Uninstall
    In terminal, enter the following command:
    sudo /Library/uninstall-devtools –mode=all
    For the actual installed directory, Xcode is installed in the/developer directory by default and can be executed
    sudo /Developer/Library/uninstall-devtools –mode=all;

  • Show full path in Finder title bar
    In terminal, enter the following command:
    defaults write com.apple.finder _FXShowPosixPathInTitle -bool YESkillall Finder

  • Remove the shadow from the window screenshot
    When you take a screenshot of the window (command-shift-4, space), the resulting picture is automatically added with a circle of shadows around it. If you don't like the effect of this shade, you can turn it off.
    In terminal, enter the following command:
    defaults write com.apple.screencapture disable-shadow -bool truekillall SystemUIServer;

  • Force Safari to open a Web page in a new tab
    Safari is the default support for tag browsing. However, when we click on a link on a page or click a link in another app, Safari tends to open a new window that causes too many safari windows on the page and is not well managed. By following this little trick,
    We can let safari open the page by default in a new tab.
    In terminal, enter the following command:
    defaults write com.apple.Safari TargetedClicksCreateTabs -bool true;

  • Change the location where screenshots are saved
    Mac OS provides a handy screenshot shortcut that allows us to take screenshots of the entire screen, part of the screen, or the application window very quickly. However, this screenshot feature has one disadvantage, that is, you can only save screenshots to the desktop. If we take a lot of pictures, it will make the desktop seem very messy. Is there any way to modify the default location of screenshots? Yes. The method is very simple, as long as you enter the following command in "terminal".
    defaults write com.apple.screencapture location 存放位置killall SystemUIServer;
    When you enter a command, replace the "storage location" with a real folder. For example, if you want to store the screenshots folder in your user directory, enter
    defaults write com.apple.screencapture location ~/Screenshots;

Common Shortcuts for Mac
    • Command+tab switching applications In any case-forward loop
    • Shift+command+tab Switching applications-loop backwards
    • Command+delete Move the selected resource to the Trash
    • Shift+command+delete emptying the trash for related programs
    • Command+ ' Switching between multiple windows of the same application
    • Command+f calls out most of the application's query capabilities
    • command+c/v/x copy/paste/Cut
    • Command+n New application window
    • Command+q exit the current application, the top left corner of all the application interface has red and yellow green Three small icons, click on the green extension to the most suitable window size, yellow minimized, red off the current window, but did not exit the program.
    • Use COMMAND+Q with Command+tab to close applications most quickly
    • Command+l the current program is a browser, you can directly navigate to the address bar
    • Command+ "+/-" to enlarge or shrink the font
    • control+ Launch key display shutdown dialog box
    • Control+space Exhaled Spotlight
    • Command+space Switching Input Method
Written in the last
    • Each terminal development can not only be limited to the development tool IDE, often some operating system operation will bring unexpected surprises, but also hope that you understand carefully. If you want to understand the common operation of MAC system, recommend this article to everyone, if you want to learn UNIX instructions, you can click.

[Go] Learn the common commands of Mac and help iOS development

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.