Learn frequently-used Mac commands, assist iOS development, and frequently-used mac commands for ios
Source: Jack_lin (@ Jack_Lin_IOS)
Heavy technology Preface
In the process of iOS development, you pay more attention to the efficiency of iOS development and are proficient in using common commands on Mac terminals. This allows you to better explore iOS development. This article focuses on the basic commands and shortcuts of common Mac terminals, and is more suitable for beginners of IOS to learn and understand.
Mac OS X File System
- Mac OS X is a Unix kernel. It uses Unix multi-user systems and Unix file systems. All files are stored in the root directory./UsersBelow, there is no drive letter concept in Windows. After a user logs on to the system, his/her User Directories generally include public, pictures, documents, downloads, music, movies, sites, desktops, and resource libraries, OS X internationalizes Chinese users, opens terminals, and inputsls, You will see the real Directory Name:Desktop、Documents、Downloads、Library、Movies、Music、Pictures、Public、Sites. Enter cd/in the terminal, switch to the root directory, and typelsIn this way, you can see the overall Unix directory.
As shown in:
Terminal
- Among them, some common file location highlights:
123456 |
1. Driver location/Development me/Library/Extensions; 2. Desktop location/User name/Desktop; 3. The file wildcard is asterisk * 4. In the unixsystem, A. txt is not equal to a.txt. The root directory flag/is not dispensable. cd/System indicates to go to the System in the directory with the root directory, and cd System indicates to go to the System in the current directory. |
Common Mac commands
- List objects:Ls parameter directory nameFor example, view the driver directory:ls/System/Library/Extensions, (Parameter-w displays Chinese characters,-l details,-a includes hidden files );
- Conversion directory:cdFor example, convert to the driver directorycd /System/Library/Extensions;
- Create a new directory:Mkdir directory nameFor example, create a backup file backup under the driver directory,mkdir /System/Library/Extensions/backup;
Create a backup directory backup on the desktop,Mkdir/User name/Desktop/backup;
- Copy an object:Cp parameter source file target fileFor example, you want to copy the Natit. kext file on the desktop to the driver directory.Cp-R/User name/Desktop/Natit. kext/System/Library/ExtensionsThe R parameter indicates recursive operation on the directory. kext looks like a file in the graphic interface and is actually a folder.
Back up all files in the driver directory to the desktop backup
Cp-R/System/Library/Extensions/*/User name/Desktop/backup;
- Delete an object:Rm parameter fileFor example, you want to delete the driver cache.rm -rf /System/Library/Extensions.kextcache 、rm -rf /System/Library/Extensions.mkext, Parameter-rfIndicates recursion and forcible execution.rm -rf /Your system is paralyzed;
- Move files:Mv FileFor exampleAppleHDA.KextMove to desktopMv/System/Library/Extensions/AppleHDA. kext/User name/Desktop,
WantAppleHDA.KextMove to the backup directorymv /System/Library/Extensions/AppleHDA.kext /System/Library/Extensions/backup;
- Text editing:Nano file nameExample: Editnatit Info.plist nano /System/Library/Extensions/Natit.kext/Info.plist;
- Directory operation:
Command name |
Function Description |
Example |
Mkdir |
Create a directory |
Mkdir dirname |
Rmdir |
Delete a directory |
Rmdir dirname |
Mvdir |
Move or rename a directory |
Mvdir dir1 dir2 |
Cd |
Change current directory |
Cd dirname |
Pwd |
Display the path name of the current directory |
Pwd |
Ls |
Display the content of the current directory |
Ls-la |
Command name |
Function Description |
Example |
Cat |
Display or connect files |
Cat filename |
Od |
Show non-text file content |
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 |
Search for files using matching expressions |
Find.-name "*. c"-print |
File |
Display file type |
File filename |
Command name |
Function Description |
Example |
Head |
Display the first few lines of the file |
Head-20 filename |
Tail |
Display the last few lines of the file |
Tail-15 filename |
Cut |
Display certain fields in each row of a file |
Cut-f1, 7-d:/etc/passwd |
Colrm |
Delete several columns from standard input |
Colrm 8 20 file2 |
Diff |
Compare and display the differences between the two files |
Diff file1 file2 |
Sort |
Sort or merge files |
Sort-d-f-u file1 |
Uniq |
Remove duplicate rows from the file |
Uniq file1 file2 |
Comm |
Display public and non-public rows of two ordered files |
Comm file1 file2 |
Wc |
Number of characters, words, and lines in the Statistical File |
Wc filename |
Nl |
Add the row number to the file |
Nl file1> file2 |
Command name |
Function Description |
Example |
Ps |
Display current process status |
Ps u |
Kill |
Terminate a process |
Kill-9 30142 |
Command name |
Function Description |
Example |
Date |
Displays the current date and time of the system. |
Date |
Cal |
Show Calendar |
Cal 4 2016 |
Time |
Statistical Program Execution time |
Time a. out |
- Network and communication operations:
Command name |
Function Description |
Example |
Telnet |
Remote Login |
Telnet hpc.sp.net.edu.cn |
Rlogin |
Remote Login |
Rlogin hostname-l username |
Rsh |
Run the specified command on the remote host |
Rsh f01n03 date |
Ftp |
Transfers files between the local host and remote host |
Ftp.sp.net.edu.cn |
Rcp |
Copy files between the local host and remote host |
Rcp file1 host1: file2 |
Mail |
Read and send emails |
Mail |
Write |
Send messages to another user |
Write username pts/1 |
Mesg |
Allow or reject receiving packets |
Mesg n |
Ping |
Send a Response Request to a network host |
Ping hpc.sp.net.edu.cn |
Command name |
Function Description |
Example |
History |
Lists the commands and numbers that have been executed recently. |
History |
R |
Repeat the execution of a recent command. |
R-2 |
Alias |
Define an alias for a command |
Alias del = rm-I |
Unalias |
Cancels the definition of an alias. |
Unalias del |
Rcp |
Copy files between the local host and remote host |
Rcp file1 host1: file2 |
Mail |
Read and send emails |
Mail |
Write |
Send messages to another user |
Write username pts/1 |
Mesg |
Allow or reject receiving packets |
Mesg n |
Command name |
Function Description |
Example |
Uname |
Displays information about the operating system. |
Uname- |
Clear |
Clear screen or window content |
Clear |
Alias |
Define an alias for a command |
Alias del = rm-I |
Unalias |
Cancels the definition of an alias. |
Unalias del |
Who |
Display All currently set Environment Variables |
Who |
Whoami |
Displays the username currently performing the operation |
Whoami |
Tty |
Display terminal or Pseudo Terminal name |
Tty |
Du |
Query disk usage |
Du-k subdir |
Stty |
Display or reset control key definitions |
Stty- |
Df/tmp |
Displays the total space and available space of the file system. |
- |
W |
Displays the total information of the current system activity. |
- |
- Show resource library:
Method 1: Display
Enter the following command in terminal:
chflags nohidden ~/Library/;
Hide
Enter the following command in terminal:
chflags hidden ~/Library/;
Method 2: Open the Finder, and select to press and hold the option key in the menu to display the resource library items (you need to repeat each time you open the options ).
- Finder shows hidden files
Show Hidden Files
Enter the following command in terminal:
defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder;
Restore hidden files
Enter the following command in terminal:
defaults write com.apple.finder AppleShowAllFiles -bool false
killall Finder.
- Xcode uninstall
Enter the following command in terminal:
sudo /Library/uninstall-devtools –mode=all
The actual installation directory. By default, Xcode is installed in the/Developer directory and can be executed.
sudo /Developer/Library/uninstall-devtools –mode=all;
- Display the complete path in the Finder title bar
Enter the following command in terminal:
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
killall Finder
- Remove the shadow of the window screenshot
When screenshots are taken from the window (Command-Shift-4, space), the image is automatically added with a shadow. If you do not like the shadow effect, you can turn it off.
Enter the following command in terminal:
defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServer;
- Force Safari to open a webpage in a new tag
Safari supports tag browsing by default. However, when we click a link on the page or click a link in another application, Safari often opens a new window, resulting in too many Safari windows on the page, which is difficult to manage. The following tips,
We can make Safari open the webpage in a new tag by default.
Enter the following command in terminal:
defaults write com.apple.Safari TargetedClicksCreateTabs -bool true;
- Change the position where screenshots are saved
Mac OS provides convenient screenshot shortcuts, allowing us to quickly take screenshots of the entire screen, part of the screen or application window. However, this screenshot function has one disadvantage: it can only save screenshots to the desktop. If we take a lot of screenshots, it will make the desktop look messy. Is there any way to change the default storage location of screenshot images? Yes. The method is very simple. You only need to enter the following command in the terminal.
Ults write com. apple. screencapture location
Killall SystemUIServer;
When you enter the command, replace the "storage location" with a real folder. For example, enter
defaults write com.apple.screencapture location ~/Screenshots;
Common shortcut keys in Mac
- Command + Tab switch application under any circumstances-forward Loop
- Shift + Command + Tab switch application-backward Loop
- Command + Delete move the selected resource to the recycle bin
- Shift + Command + Delete clear the waste bin of related programs
- Command + 'Switch between multiple windows of the same application
- Command + F call out the query functions of most applications
- Command + C/V/X copy/paste/cut
- Command + N create application window
- Command + Q exit the current application. Note that there are three small icons in the upper left corner of all application interfaces. Click green to expand to the most suitable window size, and minimize the yellow color, the current window is closed in red, but the program is not exited.
- Using Command + Q with Command + Tab to close the application is the fastest
- Command + L when the current program is a browser, you can directly locate the address bar
- Command + "+/-" to zoom in or out the font
- Control + release key display shutdown dialog box
- Control + Space calls out Spotlight
- Command + Space switching Input Method
Conclusion
- Each type of terminal development cannot be limited to the development tool IDE. Some operations on the operating system may bring unexpected surprises. QQ technology exchange group 290551701 http://cxy.liuzhihengseo.com/