Terminal is a command-line tool under the Mac system, below I give you a brief introduction of the use of the terminal:
1. PWD Displays the current system location
Ls-l-a lists the files in the specified directory
-L Display File details
-a displays all files in the directory (including hidden files)
-d display the specified directory PWD displays the path of the current working directory
CD Switch working directory
. Represents the current directory
.. Represents the top-level directory of the current directory
/root directory/directory separator
./Current Directory
.. /go to the top level directory
Relative path/absolute path general/start path, absolute path
Cd.. Go to the top level directory
CD Plus wave symbol: Enter the current login user directory
mkdir: Creating a new Directory
RmDir: Only empty directories can be deleted
Cat filename. txt: View the contents of the specified text file (suitable for viewing small files)
More split screen Pause display text file contents
Diff/vimdiff Comparison of two files
Touch Directory Name: View the specified file, create an empty file without this file; change the file timestamp
chmod changing permissions for a specified file or directory
Belong to the main group of others
RWX rwx rwx
421 421 421
2^2+2^1+2^0
chmod u-x,g-wx,o=-file indicates that the primary user does not have permission to execute the file files, the group user does not have the ability to read the file files, and the other person does not have permissions to the file files.
PS aux static viewing process
Top Dynamic View Process
Echo: output string or Variable value
> If the specified file does not exist, create the file, if present, overwrite the original file content
Output redirection character
>> If the specified file does not exist, create the file, if present, append content after the original file content
Difference
echo "string" > File
echo "string" >> file
Kill kills the process
Kill-9 PID kills the specified process
Man Display Help file (press Q to exit)
Ifconfig view or modify IP addresses
sudo executes the command once with root privileges
Clear/ctrl+l Clear Screen
CTRL + C unconditionally terminate
RM–RF * Force deletion of all files in the current directory
RM-RF Deleting a file or directory
Cp-r Copying files
MV Moving files
Stat file name view file details
Find File
Find/-name * finding files
Use of shortcut keys when editing the contents of a file:
A in the cursor next word prompt insert
I insert at the cursor
o Insert a new row next to the line where the cursor is located
R replaces the character of the cursor
R enters the replacement mode
DD cuts the line of content on the cursor
NDD cuts the contents of n rows from the beginning of the line where the cursor is located
YY Copy the line of the cursor
Nyy the contents of n rows after the start of the line where the cursor is located
P Paste the cursor in the row
D Delete all content to the right of the cursor
x Delete the character of the cursor
GG quickly moves the cursor to the top of the file
G move the cursor quickly to the end of the file
0 quickly move the cursor to the beginning of the line
$ move the cursor quickly to the end of the line
/n Find content n skip to next item
Gg=g paragraph Alignment
: Set Nu Sets line number
: Set Nonu Cancel line number
: line number navigates to the specified line
U undo
: x equals: Wq
: W Save
: Q Not saved direct exit
: Wq Save and exit
: w! Force Save
: q! Force exit
: wq! Force Save exit
7XL Force Save exit
: syntax on/off syntax tips
Unexpected shutdown of Shell. *.SWP (First locate the corresponding. *.swp file with the Ls–a command, and then delete the. *.swp file)
: 1,10s/printf/kkk/g means to replace 1-10 rows of printf with KKK
Copy out your own ssh-key.
Pbcopy < ~/.ssh/id_rsa.pub
Mac basic Commands