Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Summarize the commands commonly used in inux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "inux common command summary", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's train of thought slowly in depth, together to study and learn "inux common command summary" bar!

^ M exists in the linux file

You can remove it by using the shell command tr, which is as follows:

The code is as follows:

Cat-v yourfile | tr-d "^ M" > targetfile

Select a word in VIM

After ESC, you can choose a word by using w or wi or vwi

Quickly move the cursor in the console

1. Delete

1.1 ctrl + d to delete the character in the cursor position is equivalent to x or dl in VIM

1.2 ctrl + h removes the character before the cursor position is equivalent to hx or dh in VIM

1.3 ctrl + k deleting all characters after the cursor is equivalent to dshiftkeeper $in VIM

1.4 ctrl + u deleting all the characters in front of the cursor is equivalent to dcenture shift + ^ in VIM

1.5 ctrl + w deleting the word before the cursor is equivalent to db in VIM

1.6 ctrl+ y restores the characters deleted during the last execution of ctrl+u

1.7 ctrl +? Undo the previous input

1.8 alt + r undo the previous action

1.9 alt + d delete the last word where the cursor is located

two。 move

2.1 ctrl + a move the cursor to the beginning of the command line equivalent to shift+ ^ in VIM

2.2 ctrl + e moves the cursor to the end of the command line equivalent to shift+$ in VIM

2.3 moving the ctrl + f cursor backward one character is equivalent to l in VIM

2.4 moving the ctrl + b cursor forward one character is equivalent to h in VIM

2.5 ctrl + left key cursor move to the beginning of the previous word

Ctrl + right arrow key move the cursor to the end of the next word

2.7 ctrl + x jumps between the character of the last cursor and the character of the current cursor

2.8 in the command input mode in vim, type gg to quickly jump to the beginning of the file

2.9 in command input mode in vim, type GG to quickly jump to the end of the file

3.0 returns the location of the previous editor in vim, using ctrl+o in input command mode

3.1 return to the location of the next editor in vim and use ctrl+i in input command mode

3. Statistics

3.1 for example, to count the number of a string in vim, you can use the command

The code is as follows:

:% s/Name//gn

Prevent a file from being deleted

1. Use a shell command to prevent files under files from being deleted

Sudo chattr + a Downloadscd Downloadsrm Ngix.pdfmv: cannot move 'Ngix.pdf' to' / home/gpx/.trash/Ngix.pdf': Operation not permittedsudo rm Ngix.pdfrm: cannot remove 'Ngix.pdf': Operation not permitted

two。 Use the alias command to remove rm

Alias rm='rm-i'oralias rm=trashtrash () {mv "$@" trash/} oralias rm='cp $@ ~ / backup; rm $@'

Data synchronization command

#! / bin/sh date-d 'now' > / mnt/hd/data/log/rsync.log index=1while: 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 fidonedate-d 'now' > / 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 lines from a file in linux

The code is as follows:

Sort-n Yourfile | uniq > save_path

Update Linux system time

The code is as follows:

Sudo ntpdate cn.pool.ntp.org

Ntp servers in Asia

The code is as follows:

. Bangladesh-bd.pool.ntp.org. China-cn.pool.ntp.org. Hong 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

Match complete words in vim

Use command line input mode

/\

If you use it in a single file to find and match

Use directly for a word in command input mode *

Using scp and rsync to transfer and backup data in the intranet

The code is 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--debug=FLAGS fine-grained debug verbosity--msgs2stderr special output handling for debugging-a:--archive archive mode Equals-rlptgoD (no-Hmalli A -X)-- no-OPTION turn off an implied OPTION (e.g.-- no-D)-z:--compress compress file data during the transfer--compress-level=NUM explicitly set compression level--skip-compress=LIST skip compressing files with suffix in LIST-h:--human-readable output numbers in a human-readable format--progress show progress during transfer--delete delete extraneous files from dest dirsscp mode remote_username@remote_hostname (or ip): remote_file_path dest_file_path > run_log_pathexample : 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 0.2KB/s 00namehands hostlade hand MNT Unix HdUnix Dataport codeCharger $next we summarize 10 commands commonly used in linux

1. "empty the original file and write the contents to the file,"put the contents at the end of the file."

The code is as follows:

Echo "aa"test.txt and echo" bb "" test.txt

2 add write permissions to group users and other users

The code is as follows:

Chmod go+w-R / home/zhangy

3. List archived content

The code is as follows:

Tar-tzvf test.tar.gz

4. View file list is large

The code is as follows:

Du-ah

5. View the total size of all files

The code is as follows:

Du-sh

6. Mathematical operation

The code is as follows:

Echo '1room2' | bc-l

7. / / check some information about linux kernel, etc.

The code is as follows:

Uname-a

8. Show progress during bad track scan

The code is as follows:

Badblocks-s / dev/sda

9. View the running time of the command

The code is as follows:

Time command

10. Sort in reverse order of time

The code is as follows:

Ls-lrt

Thank you for your reading, the above is the content of "inux common command summary", after the study of this article, I believe you have a deeper understanding of the problem of inux common command summary, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report