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

What are the commonly used vi editing commands in shell

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

Share

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

This article mainly introduces which vi editing commands are commonly used in shell. It is very detailed and has certain reference value. Friends who are interested must finish reading it.

1. Common vi editing commands

Mode switching

Search: enter trailing mode, / key enter to match automatically and press N key to find the next one.

Line number setting: enter trailing mode set line number: set nu cancel line number: set nonu

Common keyboard shortcuts in command line mode:

Dd: delete the current line

DG: deletes all lines currently under the cursor

Ndd: delete the current line of the cursor and the n lines below

Gg: jump to the first letter of the first line

G: jump to the first letter of the last line

End of shift+$ Lin

Note: when you want to paste the contents of a file in command line mode, press the I key before pasting, otherwise the contents of the file will be lost.

Note: be sure to make a backup before editing or tuning the configuration file

2. System command

View disk

[root@hadoop ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_hadoop-lv_root 50G 3.8G 43G 8% / tmpfs 996M 0996m 0% / dev/shm/dev/sda1 477M 42m 410m 10% / boot/dev/mapper/vg_hadoop-lv_home 94G 2.3G 87G 3% / home/dev/sr0 3.7G 3.7G 0100% / mnt/cdrom

View memory (extended content: http://blog.itpub.net/30089851/viewspace-2131678/)

[root@hadoop] # free-h total used free shared buffers cachedMem: 1.9G 691M 1.3G 256K 46M 74M Muhammad + buffers/cache: 570M 1.4G Swap: 3.9G 0B 3.9G

View load

[root@hadoop] # toptop-23:04:17 up 14 min, 2 users, load average: 0.04,0.01, 0.00Tasks: 150 total, 1 running, 149 sleeping, 0 stopped, 0 zombieCpu (s): 0.0%us, 0.0%sy, 0.0%ni, 99.9%id, 0.0%wa, 0.0%hi, 0.1%si, 0.0%stMem: 2039008k total, 707992k used, 1331016k free 47688k buffersSwap: 4095996k total, 0k used, 4095996k free 76636k cached PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND 866 root 2000 S 4.7 0.0 vmmemctl 01.14 root 21 20 0 00 0 S 0.3 0.0 0:00.55 events/2 1 root 20 0 19364 1536 1228 S 0.0 0.1 0:01.28 init 2 root 20 00 00 S 0.0 0.0 0:00.01 kthreadd 3 root RT 00 00 S 0.0 0.0 0:00.01 migration/0

Case: load control

[root@hadoop] # toptop-23:04:17 up 14 min, 2 users, load average: 0.04,0.01,0.00

Note: the value of load balancer cannot exceed 10, that is, load average: 0.04,0.01,0.00. The last three values are more than 10. If the value exceeds 10, the current machine is busy.

For example:

PID USER PR NI VIRT RES SHR S CPU MEM TIME+ COMMAND

1777000S 50% 70% root 34.13 xxxx to see what the xxx process is doing.

1777 root 2000 0 S 3908% 80% 0A 34.13 hbase regionserver

There are two problems in the above case description

(1) if a service takes up cpu or men for a long time, check what the process is doing

(2) if cpu soars by more than 3000%, tamping down, code level, if not self-written code, high probability hardware level-- > memory is broken.

Check everything else. Restart the machine.

3. View the process and the port number

View the process: ps-ef to view the processes running in the background of this server, which can be filtered using pipe characters. The current query process represented by the last record

[root@hadoop ~] # ps-ef | grep ssh# process user process pid parent id process user's content (directory to which the process belongs) root 2081 1 0 22:49? 00:00:00 / usr/sbin/sshdroot 2367 2081 0 22:50? 00:00:00 sshd: root@pts/0 root 2395 2081 0 22:54 ? 00:00:00 sshd: hadoop [priv] hadoop 2397 2395 0 22:54? 00:00:00 sshd: hadoop@pts/1root 2534 2369 0 23:38 pts/0 00:00:00 grep ssh

Filter out the process of your current query:-v means filter

[root@hadoop] # ps-ef | grep ssh | grep-v greproot 2081 1 0 22:49? 00:00:00 / usr/sbin/sshdroot 2367 2081 0 22:50? 00:00:00 sshd: root@pts/0 root 2395 2081 0 22:54? 00:00:00 sshd: hadoop [priv] hadoop 2397 2395 0 22:54? 00:00:00 sshd: hadoop@pts/1

Check the port number: netstat-nlp queries all port numbers, and filters the port number you want with grep.

[root@hadoop ~] # ps-ef | grep ssh | grep-v greproot 2081 1 0 22:49? 00:00:00 / usr/sbin/sshdroot 2367 2081 0 22:50? 00:00:00 sshd: root@pts/0 root 2395 2081 0 22:54? 00:00:00 sshd: hadoop [priv] hadoop 2397 2395 0 22:54? 00:00:00 sshd : hadoop@pts/1 [root@hadoop ~] # netstat-nlp | grep 2397 # does not show no port number [root@hadoop ~] # netstat-nlp | grep 2081 # port number: 22tcp 0 0 0 LISTEN 2081/sshd tcp 22 0 0 0: 22 : * LISTEN 2081/sshd [root@hadoop ~] # netstat-nlp | grep 2395 [root@hadoop ~] #

Find port (port number) through pid: because a service can run without a port number

1: start a process ps must

2: it is not necessary to start a port netstat

Deploy big data component in centos and find an error Connection refused

(1) Firewall web iptables

(2) ping ip test ip

(3) telnet ip port test ip and port number (Note: telnet needs to be deployed separately in Windows7, command deployment is described below)

Deploy telnet commands

The window cmd black window does not have the telnet command, so you need to install and restart the computer.

Linux deployment Telnet command

[root@hadoop ~] # yum install-y telnetLoaded plugins: fastestmirror, refresh-packagekit SecuritySetting up Install ProcessLoading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.163.combase | 3.7 kB 00:00 extras | 3.4 kB 00:00. .installed: telnet.x86_64 1vl 0.17-48.el6 Complete! [root@hadoop ~] # which telnet/usr/bin/telnet

4. High risk command

Rm-rf /

Vi production configuration file 100line save = "cp xxx.xml xxx.xml20191117

Kill-9

Kill-9 process pidkill-9 process pid process pid process pidkill-9 $(pgrep-f matches keywords) ps process xxx,top command query tamped / deleted xxx process kill process, first ps to find the relevant process, find out which are you want to kill, otherwise cause production accident

5. Install yum software

Yum search xxx # find yum install-y xxx-yyy # install-y indicates that when you encounter a yes/no query, it defaults to yesyum remove xxx-yyy # uninstall.

6. Rpm package management

[root@hadoop ~] # rpm-qa | grep http # View httpd-tools-2.2.15-69.el6.centos.x86_64httpd-2.2.15-69.el6.centos.x86_64 [root@hadoop ~] # rpm-e httpd-tools-2.2.15-69.el6.centos.x86_64 # Uninstall [root@hadoop ~] # rpm-e-- nodeps httpd-tools-2.2.15-69.el6.centos.x86_64 # Force uninstall without verification Delete directly

7. Download the installation package for wget

Wget http://archive.cloudera.com/cdh6/cdh/5/hadoop-2.6.0-cdh6.16.2.tar.gz

8. Compression and decompression

Compress

Zipzip-r xxx.zip. / * in the folder zip-r ruozedata.zip ruozedata/* is outside

Decompression

Unzip ruozedata.zip

Almost all the compressed packages of big data components are suffixed with tar.gz.

Tar-xzvf hadoop-2.6.0-cdh6.16.2.tar.gz

Tar-czvf hadoop-2.6.0-cdh6.16.2.tar.gz hadoop-2.6.0-cdh6.16.2/*

Examples: tar-cf archive.tar foo bar # Create archive.tar from files foo and bar. Tar-tvf archive.tar # List all files in archive.tar verbosely. Tar-xf archive.tar # Extract all files from archive.tar.

Add: clear this content

Cat / dev/null > xxx.log is perfect

1 byte exists in echo'> xxx.log

These are all the contents of this article entitled "what are the vi editing commands commonly used in shell?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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

Servers

Wechat

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

12
Report