Linux command usage set

Linux command usage set

//============================================== ======File editing
vim
i → Insert mode, press ESC to return to Normal mode.
x → delete a character where the current cursor is located.
:wq → save + exit (:w save, :q quit) (Chen Hao note: :w can be followed by a file name)
dd → delete the current line, and save the deleted line to the clipboard
p → paste the clipboard

a → insert
o after the cursor → insert a new line after the current line
O → insert a new line before the current line
cw → replace the character 0 after the cursor position to the end of a word

→ the number zero, to the beginning of the line
^ → to this The first position of the line that is not a blank character (the so-called blank character is space, tab, line feed, carriage return, etc.)
$ → to the end of the line
g_ → to the last position of the line that is not a blank character.
/pattern → search for the string of pattern (Note for Chen Hao: if you find multiple matches, you can press n to go to the next one)

P → paste
yy → copy the current line to ddP

u → undo
<Cr> → redo

:e < path/to/file> → open a file
: w → save to disk
:saveas <path/to/file> → save as <path/to/file>
:x, ZZ or :wq → save and exit (:x means save only when needed, ZZ don't need to enter colon and enter)
: q! → Quit without saving: qa! Force quits all files being edited, even if other files have changed.
:bn and :bp → You can have many files open at the same time, use these two commands to switch to the next or previous file. (Chen Hao Note: I like to use :n to go to the next file)


//================================== ================Copy files
cp
-f or --force to forcibly copy files or directories, regardless of whether the destination file or directory already exists
-r Recursive processing, will copy files in the specified directory Files are processed along with subdirectories. If the form of the source file or directory does not belong to a directory or symbolic link, it will be treated as a normal file
-R or --recursive Recursive processing, the files and subdirectories in the specified directory will be processed together

cp -f file1 file2 // Copy file file1 to file2,
cp -R dir1 dir2 //Copy directory dir1 to directory dir2


//============================ ========================Move the file
mv
-b : If you need to overwrite the file, make a backup before overwriting.
-f : force means to force, if the target file already exists, it will be overwritten without asking;
-i : If the destination file (destination) already exists, it will ask whether to overwrite!
-u : If the target file already exists and the source is relatively new, it will be updated (update)

mv test.log test1.txt //rename the file test.log-->test1.txt
mv test1.txt test3 //move the file to test3 directory


//================================================== ==== is used to view the file content
tail
-f makes tail keep reading the latest content, which has the effect of real-time monitoring Use Ctrl+c to terminate
tail -f test.txt |grep "12345" //"|"pipeline , grep filter


//============================================== =====File permissions management
chmod
-c : If the file permissions have been changed, only show the change action
-f : If the file permissions cannot be changed, don't show an error message
-v : Show details of permission
changes- R : Perform the same permission change for all files and subdirectories in the current directory (that is, change one by one in a recursive manner)

r means readable, w means writable, x means executable, X means only when the file is is a subdirectory or the file has been made executable.

Indicates the permissions of User, Group, and Other, respectively.
chmod 777 file


//==================================================== ==Network
//View all processes and port usage
netstat --apn

//Display the process status of the port
lsof -i :port
Or :
netstat -apn | grep 80


//========== ========================================= System
//View process status
top

//Kill Dead process
kill -9 PID (process ID)




//Linux file content viewing, starting from the first line to display the file content
cat -An

takes out the following lines of the file
tail -f


//User and user group management




Disk management
Linux disk management commonly used three The commands are df, du, and fdisk.
df: list overall disk usage of filesystem
du: check disk space usage
fdisk: for disk partitions

df -hT
du -ha


ll

cp -a src dec

rm -rf file/dir

mv -u file


scp /home/xing/CEInstantPot.war [email protected]:/opt/apache-tomcat-8.0.24/webapps/



find command
http://www.cnblogs.com/hushaojun/p/4851485.html








Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326355107&siteId=291194637