In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Linux briefly introduces Linux command basic Linux command help directory and file basic operation Linux family Redhat Red Hat three certifications (open source but not free)-"Community (system developer) -" Centos (server side) Ubuntu best client system, open source pure free (software developer crowd) Debian-"kali Linux (dedicated tool resources take up very little) raspberry pie suse Linux---" ISP (Telecom, Mobile) Unicom) A special program of customized version of shell--Linux system-- "translator"
A shell program is automatically loaded when the user logs in to the Linux system. Bash is the shell program used by default in the Linux system.
The kernel of Linux is developed by C language (process-oriented language), and applications are developed in C++.
Compiler-- gcc gcc-c++ jdk (compiler of Java) the compiler of Python is Python2/3
Source file-"(compiler) -" execution file
Classification of Linux commands Internal commands external commands common command line usage format:
Command word [option] [parameter] (corresponding to operation, function, operation object)
-combination of single characters-- introduction of words to root@localhost ~] # root-- current user @-- delimiter localhost-- host name ~-- current directory location #-administrator $--introduction to ordinary user path
Absolute path: for example-- / etc/sysconfig/network-scripts/
Relative path (path to current location): for example-- sysconfig/
Home directory: administrator (/ root) ordinary user (/ home)
Root directory: /
II. Linux command set (combined with examples)
Cd: switch working directory
Pwd: view the absolute directory path where you are currently located
[root@lokott ~] # cd / etc/sysconfig/network-scripts/ enter the folder under the absolute path [root@lokott network-scripts] # pwd / / display the absolute path of the current directory / etc/sysconfig/network-scripts [root@lokott network-scripts] # cd-/ / return the last directory entered command Namely cd / etc/sysconfig/network-scripts//root [root@lokott ~] # cd-/ etc/sysconfig/network-scripts [root@lokott network-scripts] # cd.. / / return to the upper directory [root@lokott sysconfig] # cd.. /.. / / return to the upper two-tier directory [root@lokott /] #
Ls: displays the contents of the current directory
-l display file details-a view hidden file-A view except. .. Hidden file-d displays information in this directory-h friendly form displays information with units-R recursive display-color distinguishes file types by color black (data file) blue (directory) red (compressed package) green (execution file / command file / script) sky blue (link file) yellow (device file / disk file) [root@lokott ~] # lsanaconda-ks.cfg initial -setup-ks.cfg note shell Public template Video Picture document download Music Desktop [root@lokott ~] # cd shell/ [root@lokott shell] # ls 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello [root@lokott shell] # ls-a. .. 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello [root@lokott shell] # ls-A1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello [root@lokott shell] # ls-l total dosage 24-rwxr-xr-x. 1 root root 111October 25 19:10 1.sh-rwxr-xr-x. 1 root root 124 October 25 19:12 2.sh-rwxr-xr-x. 1 root root 192 October 25 19:25 3.sh-rwxr-xr-x. 1 root root 104 October 25 19:33 4.sh-rwxr-xr-x. 1 root root 147October 25 19:36 5.sh-rwxr-xr-x. 1 root root 26 October 25 19:37 6.shdrwxr-xr-x. 2 root root 18 October 30 13:53 hello [root@lokott shell] # ls-R.:1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello./hello:0.sh [root@lokott shell] # ls-d. [root@lokott shell] # ls-ah. .. 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello [root@lokott shell] # ls-lR.: total dosage 24-rwxr-xr-x. 1 root root 111October 25 19:10 1.sh-rwxr-xr-x. 1 root root 124 October 25 19:12 2.sh-rwxr-xr-x. 1 root root 192 October 25 19:25 3.sh-rwxr-xr-x. 1 root root 104 October 25 19:33 4.sh-rwxr-xr-x. 1 root root 147October 25 19:36 5.sh-rwxr-xr-x. 1 root root 26 October 25 19:37 6.shdrwxr-xr-x. 2 root root 18 October 30 13:53 hello./hello: total dosage 0-rwxrwxrwx. 1 root root 0 October 30 13:53 0.sh [root@lokott shell] #
Alias: give the command an alias
Du: statistics of directory and file space occupancy
-a Murh friendly display-s
Which: find the command storage directory
The search scope is determined by the environment variable PATH
Mkdir: create a directory
-p Recursive nested creation
Touch: creating fil
[root@lokott shell] # alias cantilever clear` / / clear means that clearing the screen is equivalent to Ctrl+l [root@lokott shell] # which c alias cantilever clear` / usr/bin/clear [root@lokott shell] # which clear/usr/bin/clear [root@lokott shell] # mkdir linux [root@lokott shell] # ls1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello linux [root@lokott shell] # touch 0.sh [root@lokott shell] # ls0.sh 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh hello linux [root@lokott shell] # du-ah4.0K. / 1.sh4.0K. / 2.sh4.0K. / 3.sh4.0K. / 4.sh4.0K. / 6.sh0. / hello/0.sh0. / hello0. / linux0. / 0.sh24K. [root@lokott shell] # du- Sh24K. [root@lokott shell] # du-as / / cannot set the option to-as (h) du: cannot both display the total dosage At the same time, it also displays each project Try'du-- help' for more information. [root@lokott shell] # [root@lokott shell] # mkdir-p / 20119 touch 2017 / / create a folder [root@lokott shell] # cd / 20119 touch 2017 / [root@lokott 2017] # touch {1.. 10} .t xt / /.. Means to create 10 consecutive txt files named 1-10 [root@lokott 2017] # ls10.txt 1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt 9.txt
The file node (inode value) appears during the following operation: the identification sequence that the file stores on disk.
Ln: create a linked file (a shortcut similar to a Windows system)
Soft link: equivalent to shortcut-s hard link: alias the file (hard link folder cannot be created) [root@lokott shell] # ln-s 1.sh 8.sh [root@lokott shell] # ln 1.sh 10.sh [root@lokott shell] # ls-l Total usage 28-rwxrwxrwx. 1 root root 0 October 30 13:59 0.sh-rwxr-xr-x. 2 root root 111October 25 19:10 10.sh / / hard link-rwxr-xr-x. 2 root root 111October 25 19:10 1.sh-rwxr-xr-x. 1 root root 124 October 25 19:12 2.sh-rwxr-xr-x. 1 root root 192 October 25 19:25 3.sh-rwxr-xr-x. 1 root root 104 October 25 19:33 4.sh-rwxr-xr-x. 1 root root 147October 25 19:36 5.sh-rwxr-xr-x. 1 root root 26 October 25 19:37 6.shlrwxrwxrwx. 1 root root 4 October 30 14:07 8.sh-> 1.sh / / soft link drwxr-xr-x. 2 root root 18 October 30 13:53 hellodrwxr-xr-x. 2 root root 6 October 30 13:59 linux [root@lokott shell] # ls-ih / / displays the size of the file node value 19397655 0.sh 20564913 10.sh 20564913 1.sh 20564915 2.sh 20564917 3.sh 20564916 4.sh 20564918 5.sh 20564919 6.sh 19134334 8.sh 20565286 hello 35183604 linux// above the file is the file node (inode value) the soft link is inconsistent with the file node of the source file The hard-linked file node is consistent with the source file.
Cp: copy file or directory source | destination
-f does not ask-I ask whether to overwrite the original-p to keep the user rights of the source file unchanged, and high-privilege users use-r recursive replication
Rm: deletin
-I: default reminder-rf: force recursive deletion
Mv: move files or directories
[root@lokott shell] # cd hello/ [root@lokott hello] # ls0.sh [root@lokott hello] # cp.. / 5.sh. [root@lokott hello] # ls0.sh 5.sh [root@lokott hello] # cp-I. / 5.sh .cp: is ". / 5.sh" overwritten? Yes [root@lokott hello] # cp-f.. / 5.sh. / / guess has been alias cp: whether to overwrite ". / 5.sh"? Y [root@lokott hello] # [root@lokott hello] # which cp / / View the cp command has been changed by alias alias cp='cp-i' / usr/bin/cp [root@lokott hello] # cp-r.. / linux/. / / Recursively copy all contents of the upper path linux folder to the current path (currently no content) [root@lokott hello] # ls0.sh 5.sh linux [root@lokott hello] # cd linux/ [root@lokott linux] # ls [root@lokott linux] # mkdir 2020 / / create folder [root@lokott linux] # ls2020 [root@lokott linux] # cd 2020 / [root@lokott 2020] # touch 2.txt / / create File [root@lokott 2020] # cd. /.. / [root@lokott hello] # ls0.sh 5.sh linux [root@lokott hello] # mv linux/.. / / Mobile folder mv: overwrite ".. / linux"? Y [root@lokott hello] # cd. [root@lokott shell] # ls0.sh 10.sh 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh 8.sh hello linux [root@lokott shell] # ls-l linux/ Total amount 0drwxr-xr-x. 2 root root 19 October 30 14:15 2020 [root@lokott shell] # cp-r linux/ hello/ Recursively copy all the contents of the linux folder to the hello folder [root@lokott shell] # cd hello/ [root@lokott hello] # ls0.sh 5.sh linux [root@lokott hello] # ls-l linux/ Total usage 0drwxr-xr-x. 2 root root 19 October 30 14:16 2020 [root@lokott hello] # ls-lR linux/ Recursively view the copied folder information linux/: total usage 0drwxr-xr-x. 2 root root 19 October 30 14:16 2020linux/2020: the total dosage is 0murr RWMI. 1 root root 0 October 30 14:16 2.txt
Wildcard character
? Represents one * represents more than one
Find: find a file or directory
Find [look in] [option] [expression]
-name: search by target name-type: find by file type-size: find by size-user: find [root@lokott hello] # find based on the user owner of the file. -name "* .sh" / / * denotes the wildcard. / 0.sh./5.sh [root@lokott hello] # find. -type f./0.sh./5.sh./linux/2020/2.txt [root@lokott hello] # find. -size-10k../0.sh./5.sh./linux./linux/2020./linux/2020/2.txt./ifcfg-ens33 [root@lokott hello] # find. -size-10k | du-ah0. / 0.sh4.0K. / 5.sh0. / linux/2020/2.txt0. / linux/20200. / linux4.0K. / ifcfg-ens338.0K. Centos7 command listing 1. Init 0 shutdown 2. Init 1 single user mode (system maintenance Break password) 3. Init 2 multi-user mode without network 4. Init 3 multi-user mode has network * 5. Init 4 retains 6. Init 5 multi-user mode graphical interface has network 7. Init 6 restart (reboot) 3. Directory structure of Linux
Tree directory structure
/ etc administrator home directory / home normal user home directory / command file directory for all bin users / sbin administrator command file directory / boot boot partition (grub boot menu, compressed kernel, etc.) / usr application directory / etc configuration file directory / var variable length file directory (log) / dev device file directory (disk) Optical drive) / tmp temporary file / proc hardware information (CPU memory) / lib service management file (systemctl) View file contents command
Cat [] file name...: view the contents of the file
More [] file name.. Paging the contents of the file in full screen mode
The extended END of the less [] file name.: more command can be found (man less to view, it is not very convenient to demonstrate the effect here)
Head look at the first part of the file (default is 10 lines)
Tail: look at the contents at the end of the file (default is 10 lines)
[root@lokott hello] # cat ifcfg-ens33 TYPE= "Ethernet" PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "dhcp" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "IPV6_DEFROUTE=" yes "IPV6_FAILURE_FATAL=" no "IPV6_ADDR_GEN_MODE=" stable-privacy "NAME=" ens33 "UUID=" 0d6ffef5-693f-4d48-88b5-d2e1a66cf9c4 "DEVICE=" ens33 "ONBOOT=" yes "[root@lokott hello] # more ifcfg-ens33 TYPE=" Ethernet "Ethernet METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "dhcp" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens33" UUID= "0d6ffef5-693f-4d48-88b5-d2e1a66cf9c4" DEVICE= ens33 "ONBOOT=" yes "root@lokott hello] # head ifcfg-ens33 TYPE=" Ethernet "PROXY_METHOD=" none "BROWSER_ONLY=" BROWSER_ONLY= "no" BOOTPROTO= "BOOTPROTO=" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" [root@lokott hello] # tail ifcfg-ens33 IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= ens33 "UUID=" 0d6ffef5-693f-4d48-88b5-d2e1a66cf9c4 "DEVICE=" ens33 "ONBOOT=" yes
Wc (default all statistics)
-l: count rows-w: count words-c: count bytes [root@lokott hello] # cat 5.sh #! / bin/bashread-p "please input an ip address!" Ipping-C1 $ip & > / dev/nullif [$?-eq 0] then echo "$ip is up." else echo "$ip is down" fi [root@lokott hello] # wc-l 5.sh 9 5.sh [root@lokott hello] # wc-w 5.sh 30 5.sh [root@lokott hello] # wc-c 5.sh 147 5.sh [root@lokott hello] # retrieve and filter file contents
Grep command: find lines in the file that do not display the specified string
Grep [options] PATTERN [FILE...] grep [options] [- e PATTERN |-f FILE] [FILE...]-I: ignore case-v: reverse lookup Output the line [root@lokott hello] # grep-I up 5.sh echo "$ip is up." [root@lokott hello] # grep-v 'bash$' / etc/passwd bin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd: / sbin/nologinsync:x:5:0:sync:/sbin:/bin/syncshutdown:x:6:0:shutdown:/sbin:/sbin/shutdownhalt:x:7:0:halt:/sbin:/sbin/haltmail:x:8:12:mail:/var/spool/mail:/sbin/nologinoperator:x:11:0:operator:/root:/sbin/nologingames:x:12:100:games:/usr/games:/sbin/nologinftp:x:14:50:FTP User:/var/ftp : / sbin/nologinnobody:x:99:99:Nobody:/:/sbin/nologinsystemd-network:x:192:192:systemd Network Management:/:/sbin/nologindbus:x:81:81:System message bus:/:/sbin/nologinpolkitd:x:999:998:User for polkitd:/:/sbin/nologinabrt:x:173:173::/etc/abrt:/sbin/nologinlibstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologinrpc:x:32:32: Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologincolord:x:997:995:User for colord:/var/lib/colord:/sbin/nologinsaslauth:x:996:76:Saslauthd user:/run/saslauthd:/sbin/nologinrtkit:x:172:172:RealtimeKit:/proc:/sbin/nologinpulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologinchrony:x:995:991::/var/lib/chrony:/sbin/nologinrpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologinnfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologinntp:x:38:38::/etc/ntp:/sbin/nologintss:x:59:59:Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologinusbmuxd:x:113:113:usbmuxd user:/:/sbin/nologingeoclue:x:994:989:User for geoclue:/var/lib/geoclue:/sbin/nologinqemu: X:107:107:qemu user:/:/sbin/nologinradvd:x:75:75:radvd user:/:/sbin/nologinsetroubleshoot:x:993:988::/var/lib/setroubleshoot:/sbin/nologinsssd:x:992:987:User for sssd:/:/sbin/nologingdm:x:42:42::/var/lib/gdm:/sbin/nologingnome-initial-setup:x:991:986::/run/gnome-initial-setup/:/sbin/nologinsshd:x:74:74:Privilege -separated SSH:/var/empty/sshd:/sbin/nologinavahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologinpostfix:x:89:89::/var/spool/postfix:/sbin/nologintcpdump:x:72:72::/:/sbin/nologinapache:x:48:48:Apache:/usr/share/httpd:/sbin/nologinroot@lokott hello] # grep-v 'bash$' / etc/passwd | wc-l / will After the results are written into the pipeline, use the wc command to display the number of results 40 [root@lokott hello] #
Ctrl + r can search for commands
[root@lokott hello] # vim ifcfg-ens33 use shortcut keys! Enter the following mode and enter the command that you typed before will automatically find
(reverse-i-search) `vested: vim ifcfg-ens33
Compress command
Gzip command and bzip2 command: make compressed files, extract files
-9 means high compression ratio-d decompress [root@lokott hello] # ls0.sh 5.sh ifcfg-ens33 linux [root@lokott hello] # gzip-9 0.sh 5.sh [root@lokott hello] # ls0.sh.gz 5.sh.gz ifcfg-ens33 linux [root@lokott hello] # gzip-d 0.sh.gz [root@lokott hello] # gzip-d 5.sh.gz [root@lokott hello] # ls0.sh 5.sh ifcfg-ens33 linux [root @ lokott hello] # bzip2-9 0.sh 5.sh [root@lokott hello] # bzip2-d 0.sh.bz2 [root@lokott hello] # bzip2-d 5.sh.bz2 [root@lokott hello] # ls0.sh 5.sh ifcfg-ens33 linux [root@lokott hello] #
Tar command: make archive file, release archive file
-c: create the package-x: extract the package-v: display the detailed process-f: execute-p: retain the original permissions-t: view the contents of the package-C: extract it somewhere-z:gz format-j:bz2 format [root@lokott hello] # ls0.sh 5.sh ifcfg-ens33 linux [root@lokott hello] # tar czvf if.tar.gz ifcfg-ens33 ifcfg-ens33 [root@lokott hello] # ls0. Sh 5.sh ifcfg-ens33 if.tar.gz linux [root@lokott hello] # tar xzvf if.tar.gz-C.. / ifcfg-ens33 [root@lokott hello] # cd. [root@lokott shell] # ls0.sh 10.sh 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh 8.sh hello ifcfg-ens33 linux [root@lokott shell] # / / if it is in bz2 format, change the suffix name of the file format and replace z with j. Text editor vi/vim (proficiency in vim editors can improve productivity)
Action
Create or modify text files to maintain various configuration files in the Linux system
Command mode, input mode, last line mode (bottom line command mode) conversion relationship and operation
Related operation commands of vim editor
Line number setting operation
: set nu:set nu! And: set nonu cancel line number attention! Remember to switch to last line mode (bottom line command mode)
Locate the line (in command mode)
Gg: navigate to the beginning G: navigate to the end 3G:3 represents the line number, navigate to the third line
Copy, paste, delete
X: delete a single character at the cursor dd: delete the current cursor line dw: delete a word where the cursor is located # dd: delete the # line content starting from the line where the cursor is located ddp: swap the position between the upper and lower lines yy: copy the line change to the clipboard nyy: copy n lines to the clipboard p: paste
Other actions in the vim editor
Shift+r replacement replaces at the cursor
PG UP turns the page up
PG DN turns the page down
: e ~ / install.log opens a new file for editing (in last line mode)
R file-- reads data from another archive in the edited data. Also add the contents of the file "filename" to the line where the cursor is located (in the last line mode)
W / opt/test.txt writes the file to opt and renames it to test.txt file but does not maintain the same permissions as the source file
N1 word1 n2sqqqword1max Word2Universe g change all word1 to word2 between N1 and N2 lines
:% s/word1/word2/g change all word1 to word2
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.