In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what commands are commonly used in the Linux system. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Linux common commands
Awk / arch /
Bc /
Cp / clock-w / chmod / chkconfig / cal / cut / chmod / cat / crotable / clean /
Date / diff / df / du-sh /
Echo / exit /
Find / free / fdisk-l /
Gzip / Grep /
Help / histroy / head / hostname /
Ifconfig / init
Kill /
Ls / less / locate / logout / lastlog / lscpu / ln / lscpu / lsblk / lspci
Mv / mkdir / more / make & & make install /
Nl / netstat-ntlp /
Pwd / ping / ps /
Reboot / rm-rf / rpm /
Scp / ssh-keygen / ssh-copy-id / setup / Shutdown / server / sh / sed / sync / su / sudo / sort /
Tar / tail-f / top / tac / tree / tzselect /
Useradd / users / useradd / userdel / ulimit / uname / unzip /
Vi /
Wget / who / which / wc /
Yum /
Zip /
Tail-f: the only index of a small f tracking file is the original file tracked even after the name has been changed.
Tail-F: track by the name of the file.
Specific usage can be accessed: http://man.linuxde.net/ or link: http://pan.baidu.com/s/1slCn4O9 password: rscu if unable to download, please contact the author.
1-1), find the files added on the last day
[root@hadoop1 ~] # find /-ctime-1
-1 is from the day before, an analogy
1-2), ls usage
[root@hadoop1 local] # ls-l-R start_sh/
Start_sh/:
Total 32
-rw-r--r--. 1 root root 14 Dec 10 17:56 1.text
-rw-r--r--. 1 root root 16 Dec 10 17:58 2.text
1-3), view the total size of the files under the folder
[root@hadoop1 local] # du-h start_sh/
36K start_sh/
1-4), view the size of each asking price under the folder
[root@hadoop1 local] # du-ah start_sh/
4.0Kstart_sh/zookeeper.sh
4.0Kstart_sh/2.text
4.0Kstart_sh/spark_start.sh
4.0Kstart_sh/hadoop.sh
4.0Kstart_sh/slave
4.0Kstart_sh/1.text
4.0Kstart_sh/kafka_start.sh
4.0Kstart_sh/redis.sh
36Kstart_sh/
[root@hadoop1 local] # du-ch kafka
68Kkafka/config
5.4Mkafka/logs
27Mkafka/libs
496Kkafka/site-docs
80Kkafka/bin/windows
3.2Mkafka/bin
36Mkafka
36Mtotal
1-5), turn off the phone immediately
[root@hadoop1 /] # shutdown-h now
1-6), turn it off after ten minutes
[root@hadoop1 /] # shutdown-h + 10
1-7), which is equal to turning off the computer immediately.
[root@hadoop1 /] # halt
1-8), restart command
[root@hadoop1 /] # reboot
1-9), Xshell clear screen command
[root@hadoop1 /] # clear
Ctrl + l keyboard shortcut to clear the screen
1-10), Vi common commands
Command mode, insert mode, last line mode
A), command mode common commands
Move to the right-- > l
Move left-- > h
Move down-- > j
Move up-- > k
Delete the character where the cursor is located-- > x
Delete the line where the cursor is located-- > dd (knock d twice)
Save the current changes and exit-- > ZZ
Undo the previous operation-- > u
Move the cursor to the beginning of the line-- > 0 (number 0)
Move the cursor to the end of the line-- > $
Move the cursor to the top line of the current page-- > H
Move the cursor to the bottom line of the current page-- > L
Turn one page forward (Page Up)-- > Ctrl + f
Turn back one page (Page Down)-- > Ctrl + b
Copy the data of the current row-- > yy
Paste the copied data-- > p
Replace the old string that first appears on the current line with the new string-- >: s/old/new
Replace the old gnew string with all old strings that appear on the current line-- >: s/old/new/g
Replace the old gnew string with all old strings that appear in the file->:% s/old/new/g
Exit and save-- > ZZ
B), insert mode common commands
Enter the body [commonly used]-- > I on the left side of the cursor
Enter the body [commonly used]-- > an on the right side of the cursor
Add a new line to the next line of the cursor-- > o
Add a new line on the previous line of the cursor-- > O
Enter text at the beginning of the line where the cursor is located-- > I
Enter the body at the end of the line where the cursor is located-- > A
C), last line mode
Save file [commonly used]-- > w
Save the contents of the current file to the file file-- > w file
Save the file and exit the vi editor [Common]-- > wq
Read the contents of the file file and insert it after the line of the current cursor-- > r file
Exit the vi editor (cannot if there are changes to the current file)-- > Q
Force to exit the vi editor (do not save changes) [commonly used]-- > Q!
D), move the cursor operation
Cursor to the beginning of the line-- > Home
Cursor to the end of the line-> End
Turn the page up-- > Page Up
Turn the page down-- > Page Down
Delete the character at the cursor position-- > Delect
Move forward one page-- > Ctrl+f
Move back one page-- > Ctrl+b
Move the cursor one character to the left [commonly used]-- > h
Move the cursor down one character [commonly used]-- > j
Move the cursor up one character [commonly used]-- > k
Move the cursor one character to the right [commonly used]-- > l
Move the cursor to the end of the line [commonly used]-- > 0
Move the cursor to the beginning of the line [commonly used]-- > $
Move the cursor to the end of the file [Common]-- > G
Move the cursor to the beginning of the file [commonly used]-- > gg
Move the cursor to the beginning of the next word [commonly used]-> w
Move the cursor to the suffix of the current or next word [commonly used]-> e
Quickly delete all content-> dG
1-11), the use of the Sed command, where s represents a string and g represents each line
[root@hadoop1 /] # cat 1.text
A
B
A
[root@hadoop1 /] # sed's Uniqa bxiaozhangUniverse g '1.text
A
Xiaozhang
A
1-12), Awk processing text
[root@hadoop1 /] # last-n 3 | awk'{print$1}'
Root
Root
Reboot
Which column can Print choose?
[root@hadoop1 /] # cat / etc/passwd | awk-F':'{print$1}'
Root
Bin
Daemon
Adm
BEGIN chooses to print the header information, and it has to be printed at the end of END.
[root@hadoop1 /] # cat / etc/passwd | awk-F':''BEGIN {print "name,shell"} {print $1 "," $7} END {print "blue,/bin/nosh"}'
Name,shell
Root,/bin/bash
Bin,/sbin/nologin
Daemon,/sbin/nologin
1-13), Shell clear screen shortcut key
Ctrl + l
1-14), Netstart command filter find command
[root@skycloud2 redis_cluster] # netstat-nltp | grep redis
1-15), use of Crontab
Basic format:
* command
Time-sharing, day, month and week order
For example:
30 21 * / usr/local/etc/rc.d/lighttpd restart
The above example shows that apache is restarted at 21:30 every day.
45-4-1-10-10-22 * / usr/local/etc/rc.d/lighttpd restart
The above example shows that apache is restarted at 4: 45 on the 1st, 10th, and 22nd of each month.
10 1 * * 6 0 / usr/local/etc/rc.d/lighttpd restart
The above example shows that apache is restarted at 1: 10 every Saturday and Sunday.
0pr 30 18-23 * / usr/local/etc/rc.d/lighttpd restart
The above example shows that apache is restarted every 30 minutes between 18: 00 and 23: 00 every day.
0 23 * * 6 / usr/local/etc/rc.d/lighttpd restart
The above example shows that apache is restarted at 11: 00 pm every Saturday.
* * / 1 * / usr/local/etc/rc.d/lighttpd restart
Restart apache every hour
* 23-7bat 1 * / usr/local/etc/rc.d/lighttpd restart
Restart apache every other hour between 11:00 and 7 a.m.
0 11 4 * mon-wed / usr/local/etc/rc.d/lighttpd restart
Restart apache on the 4th of each month and 11:00 from Monday to Wednesday
0 4 1 jan * / usr/local/etc/rc.d/lighttpd restart
Restart apache at 4: 00 on January 1st
1-16), soft connection command
Example: sudo ln-s source file target file
Delete: [root@hadoop1 software] rm-rf source file
1-17), check the version of Linux
[root@hadoop1 ~] # cat / proc/version
Linux version 2.6.32-573.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)) # 1 SMP Thu Jul 23 15:44:03 UTC 2015
1-18), view the information of CPU
[root@hadoop1 ~] # cat / proc/cpuinfo
Processor: 0
Vendor_id: GenuineIntel
Cpu family: 6
Model: 58
Model name: Intel (R) Core (TM) i3-3110M CPU @ 2.40GHz
Stepping: 9
Microcode: 18
Cpu MHz: 2394.639
Cache size: 3072 KB
Physical id: 0
Siblings: 1
Core id: 0
Cpu cores: 1
Apicid: 0
Initial apicid: 0
Fpu: yes
Fpu_exception: yes
Cpuid level: 13
Wp: yes
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx f16c hypervisor lahf_lm arat epb pln pts dts fsgsbase smep
Bogomips: 4789.27
Clflush size: 64
Cache_alignment: 64
Address sizes: 42 bits physical, 48 bits virtual
Power management:
1-19), check the local disk
[root@hadoop1 ~] # fdisk-l
Disk / dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008bfe5
Device Boot Start End Blocks Id System
/ dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/ dev/sda2 39 2350 18566144 83 Linux
/ dev/sda3 2350 2611 2097152 82 Linux swap / Solaris
1-20), view the size of each file under the folder
[root@hadoop1] # ll-h
Total 64K
-rw-. 1 root root 3.3K Mar 3 2017 anaconda-ks.cfg
-rw-r--r--. 1 root root 41K Mar 3 2017 install.log
-rw-r--r--. 1 root root 9.0K Mar 3 2017 install.log.syslog
1-21), find the size of the file under a file
[root@hadoop1] # find. -type f-size + 800m | xargs ls-lh
-rw-rw-r-- 1 hadoop root 24G Mar 6 08:49. / data/cities.txt
-rw-rw-r-- 1 hadoop root 18G Mar 6 08:49 / data/order.txt
-rw-rw-r-- 1 hadoop root 50G Mar 6 10:17. / data/maxinfo.txt
-rw-rw-r-- 1 hadoop root 19G Mar 6 08:49 / data/order.txt
-rw-rw-r-- 1 hadoop root 35G Mar 6 10:00 / data/max.txt
1-22), yum common commands
A), installation command
Yum install all installed
Yum install package1 installs the specified installation package package1
Yum groupinsall group1 installer group group1
B), updates and upgrades
Update all yum update
Yum update package1 updates the specified package package1
Yum check-update checks for updatable programs
Yum upgrade package1 upgrade specified package package1
Yum groupupdate group1 upgrader group group1
C), find and display
Yum info package1 displays installation package information package1
Yum list displays all packages that have been and can be installed, using the @ flag
Yum list package1 displays the installation of the specified package package1
Yum groupinfo group1 displays the program group group1 information yum search string finds the installation package according to the keyword string
D), delete the program
Yum remove | erase package1 delete package package1
Yum groupremove group1 delete program group group1
Yum deplist package1 to view program package1 dependencies
E), clear the cache
Yum clean packages clears software packages in the cache directory
Yum clean headers clears the headers in the cache directory
Yum clean oldheaders clears the old headers in the cache directory
Yum clean, yum clean all (= yum clean packages; yum clean oldheaders) clears the software packages in the cache directory and the old headers
1-23), kill all JAVA processes quickly
[root@hadoop1 ~] # pkill java
Or
[root@hadoop1 ~] # killall java
Or
Jps | zargs kill-9
1-24), check the performance of the disk's IO
[root@hadoop1] # iostat-d-k 2 10
Linux 2.6.32-573.el6.x86_64 (hadoop1.hadoop.com) 05max 29x86pm 641 CPU 2017
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Sda 22.21 534.63 32.45 389710 23656
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
Sda 0.00 0.00 0.00 00
-d: displays the usage status of the device (disk)
-m: some columns that use block force the use of Kilobytes as unit
2: how many seconds do you refresh?
10: indicates how many times it has been displayed
1-25), the program to view the port currently being occupied
$lsof-I: 18630
Chrome 3294 xiaoxu 240u IPv4 624822 0t0 TCP localhost:33222- > xiaoxu:18630 (ESTABLISHED)
Chrome 3294 xiaoxu 255u IPv4 624823 0t0 TCP localhost:33224- > xiaoxu:18630 (ESTABLISHED)
Java 18253 xiaoxu 2279u IPv6 616200 0t0 TCP *: 18630 (LISTEN)
Java 18253 xiaoxu 2293u IPv6 624657 0t0 TCP xiaoxu:18630- > localhost:33222 (ESTABLISHED)
************
1-26), create a soft connection
-b: delete the soft connection that overwrites the previous establishment
-d,-F: allows superusers to make hard links to directories
-f: enforcement
-I: interactive mode. If there is a text, it prompts the user whether to override it.
-n: treat symbolic links as general links
-v: displays the detailed process
$ln-s / google/chrome/google-chrome / usr/bin/
/ google/chrome/google-chrome: the path to the source file
The path to the / usr/bin/: target file
1-27), conversion of decimal to 16 prohibited
$echo 1772 | awk'{printf ("% x\ n", $0)}'
6ec
1-28), check whether the network card is a kilo-meter or ten thousand meters.
$ethtool em1
Settings for em1:
Supported ports: [FIBRE]
Supported link modes: 1000baseT/Full
10000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: No
Advertised link modes: 10000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: No
Speed: 10000Mb/s (for 10, 000 m Nic, or 1, 000 m Nic)
Duplex: Full
Port: FIBRE
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000000 (0)
Link detected: yes
1-29), transfer file command
A), the scp command is used
Rcp stands for "remote file copy" (remote file copy)
$scp-r root@192.168.3.122:/root/yarnLog.log ~ / softWare/software
B), using the rcp command
Scp is secure copy, a command used to copy files remotely under linux.
$rcp-r root@192.168.3.122:/root/yarnLog.log ~ / softWare/software
1-30), use of the lsblk command
In the "lsblk" representative (list block device), print the block device by outputting the name (but not RAM) assigned to them in the tree fashion standard
$lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
Sda 8:0 0 465.8G 0 disk
└─ sda1 8:1 0 465.8G 0 part /
Sdb 8:16 1 14.7G 0 disk
└─ sdb1 8:17 1 14.7G 0 part / media/xiaoxu/522D-5D8F
This is the end of this article on "which commands are commonly used in the Linux system". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.