I have a limited memory, the usual Linux encountered in the project to share the common commands to everyone.
Linux Common commands complete http://www.jb51.net/linux/
^m exists in Linux files
The use of shell command TR can be achieved by removing the following specific commands:
Copy Code code as follows:
Cat-v Yourfile | tr-d "^m" > TargetFile
Select a word in vim
After ESC, use W or WI or Vwi to select a word
Move the cursor quickly in the console
1. Delete
1.1 Ctrl + D deletes the characters at the cursor position equivalent to VIM x or DL
1.2 Ctrl + H deletes the character before the cursor position is equivalent to vim HX or DH
1.3 Ctrl + K Delete all characters behind the cursor equivalent to VIM d,shift+$
1.4 Ctrl + U delete all characters in front of the cursor equivalent to VIM d,shift+^
1.5 Ctrl + W DELETE cursor before a word equivalent to VIM in db
1.6 Ctrl + Y restores characters that were deleted when Ctrl+u last executed
1.7 Ctrl +? Undo previous input
1.8 ALT + R undo Previous action
1.9 Alt + D deletes the post word at the cursor location
2. Mobile
2.1 Ctrl + A moves the cursor to the beginning of the command line equivalent to Vim shift+^
2.2 Ctrl + E moves the cursor to the end of the command line equivalent to Vim shift+$
2.3 Ctrl + F cursor Move backward one character equivalent to Vim L
2.4 Ctrl + B cursor move forward one character equivalent to Vim H
2.5 Ctrl + ARROW key left mouse cursor move to the beginning of the previous word
2.6 Ctrl + ARROW key right mouse cursor move to end of last word
2.7 Ctrl + X jumps between the last character of the cursor and the character at the current cursor
2.8 in Vim in the command input mode, input GG, you can quickly jump to the beginning of the file
2.9 in vim in the command input mode, input GG, you can quickly jump to the end of the file
3.0 returns the position of the previous edit in Vim, using ctrl+o in the input command mode
3.1 Returns the next edit position in Vim, using ctrl+i in the input command mode
3. Statistics
3.1 For example, in Vim to count the number of a string, you can use the command
Copy Code code as follows:
Prevent being deleted by a file
1. Use a shell command to prevent files under files from being deleted
sudo chattr +a Downloads
cd Downloads
rm ngix.pdf
mv:cannot move ' ngix.pdf ' to '/home/gpx/.trash/ngix.pdf ': Operation not permitted
sudo rm ngix.pdf
rm:cannot Remove ' ngix.pdf ': Operation not permitted
2. Use the alias command to remove RM
Alias rm= ' rm-i '
or
alias Rm=trash
Trash ()
{
mv "$@" trash/
}
or
alias rm= ' CP $@ ~/backup; RM $@ '
Data synchronization commands
#!/bin/sh
date-d ' Now ' >/mnt/hd/data/log/rsync.log
index=1 while
: do RSYNC-AZVH-
- Compress-level=0--progress gpx@ip:/mnt/hd/data/priceadj_data//mnt/hd/data/priceadj_data/>>/mnt/hd/data/ Log/rsync.log
if [$-ne 0];then Sleep
5m
else break
fi
let
"index++"
if [$index-eq 5] ; then
curl-d "operator=alert&phone=number&msg=rsync-dell-data-failed" "Http://ip:port/sendmessage"
echo "rsync data Failed!" >>/mnt/hd/data/log/rsync.log
exit 1
fi
did
date-d ' now ' & Gt /mnt/hd/data/log/log_save_datedata.log
nohup python/mnt/hd/data/code/load_today_data.py >>/mnt/hd/ Data/log/log_save_datedata.log
Remove duplicate rows from files in Linux
Copy Code code as follows:
Sort-n Yourfile | Uniq > Save_path
Update Linux system time
Copy Code code as follows:
sudo ntpdate cn.pool.ntp.org
An NTP server in the Asian region
Copy Code code as follows:
. Bangladesh-bd.pool.ntp.org. China-cn.pool.ntp.org. The kong-hk.pool.ntp.org. India-in.pool.ntp.org. Indonesia-id.pool.ntp.org. Iran-ir.pool.ntp.org. Israel-il.pool.ntp.org. Japan-jp.pool.ntp.org. Korea-kr.pool.ntp.org. Malaysia-my.pool.ntp.org. Philippines-ph.pool.ntp.org. Singapore-sg.pool.ntp.org. Taiwan-tw.pool.ntp.org. Thailand-th.pool.ntp.org. Turkey-tr.pool.ntp.org. United Arab emirates-ae.pool.ntp.org
Complete word matching in vim
Using command line Input mode
/\< here, enter the words you want to match \>
If you are using to find and match in a single file
Use directly in command input mode for a word
Data transmission and Backup in intranet using SCP and Rsync
Copy Code code as follows:
RSYNC-AZVH--delete--compress-level=0--progress username@hostname (IP): File_path save_path >> Log_path
Parameter explanation:
-V:--verbose increase verbosity--info=flags fine-grained informational verbosity =flags fine-grained debug verbosity--msgs2stderr special output handling for DEBUGGING-A:--archive archive mode; Equals-rlptgod (no-h,-a,-x)--no-option turn off a implied OPTION (e.g.--no-d)-Z:--compress compress file Data duri ng the transfer--compress-level=num explicitly set compression level--skip-compress=list skip compressing files with Suf Fix in List-h:--human-readable output numbers in a human-readable format--progress show progress during transfer--dele Te delete extraneous files from Dest dirs SCP mode remote_username@remote_hostname (or IP): Remote_file_path dest_file_path >> run_log_path example:name@host:/mnt/hd/data/code/shell$ SCP sql_rsync.sh name@host:/tmp/name@host ' s password:sql_rsync.sh 100% 149 0.2kb/s 00:00 name@host:/mnt/hd/data/code/shell$ Next, we summarize 10 common Linux commands
1. "Empty the original file and write the contents to the file," "Put the content to the end of the file
Copy Code code as follows:
echo "AA" "Test.txt and Echo" BB "test.txt
2 Add Write permissions to group users and other users
Copy Code code as follows:
3. List archived Content
Copy Code code as follows:
4. View file list size
Copy Code code as follows:
5. View the total size of all files
Copy Code code as follows:
6. Mathematical operation
Copy Code code as follows:
7.//View some information about Linux kernel and so on
Copy Code code as follows:
8. Show progress on bad track scan
Copy Code code as follows:
9. View the running time of the command
Copy Code code as follows:
10. Sort by time in reverse order
Copy Code code as follows:
The above is Linux commonly used commands, I hope you like.