Big data - virtual machine configuration

Big data - virtual machine configuration

After logging into the system

1, Configure model machine

The CD /etc/sysconfig/network scripts directory
The Modify the file ifcfg-eth0
The vi ifcfg-eth0 interface configuration - Ethernet

DEVICE=
HWADDR=network address (Cannot be the same)
TYPY=
UUID=
ONBOOT=
NM_CONTROLLED=
BOOTPROTO=

1. Note network card address
2. ONBOOT is set to yes
3. BOOTPROTO set to static

The 192.168.25.0 -192.168.25.255 range
The 192.168.25.0 network number
The 192.168.25.255 broadcast
The 192.168.25.2 gateway
The 192.168.25.1 host ip

The Available ip range 3-254
4. Add IP address
​ IPADDR=192.168.25.240

5. Netmask
​ NETMASK=255.255.255.0
6. Gateway
​ GATEWAY=192.168.25.2
7,DNS
​ DNS1=114.114.114.114
8. Restart network service
​ service network restart
Try pinging www.baidu COM
If the problem is not solved:
The Reference article:
https://jingyan.baidu.com/article/4d58d54137d2a19dd5e9c050.html
Note:
[3 option on means startup, and off means startup
The The following VMware services under this machine must be enabled
​ 1,DHCP service
​ 2,NET service
​ 3,Workstations service

Turn off a module for firewalls and security checks

Query the current Linux system which services are turned off or disabled
​ chkconfig

1. Turn off firewall

[root@MgsLocalhostData /]# chkconfig 
auditd         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
blk-availability	0:off	1:on	2:on	3:on	4:on	5:on	6:off
crond          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
ip6tables      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
iptables       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
iscsi          	0:off	1:off	2:off	3:on	4:on	5:on	6:off
iscsid         	0:off	1:off	2:off	3:on	4:on	5:on	6:off
lvm2-monitor   	0:off	1:on	2:on	3:on	4:on	5:on	6:off
mdmonitor      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
multipathd     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
netconsole     	0:off	1:off	2:off	3:off	4:off	5:off	6:off
netfs          	0:off	1:off	2:off	3:on	4:on	5:on	6:off
network        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
postfix        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
rdisc          	0:off	1:off	2:off	3:off	4:off	5:off	6:off
restorecond    	0:off	1:off	2:off	3:off	4:off	5:off	6:off
rsyslog        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
saslauthd      	0:off	1:off	2:off	3:off	4:off	5:off	6:off
sshd           	0:off	1:off	2:on	3:on	4:on	5:on	6:off
udev-post      	0:off	1:on	2:on	3:on	4:on	5:on	6:off

1. Stop firewall service
service iptables stop
2. Disable firewall
chkconfig iptables off

Case:
[root@MgsLocalhostData /]# chkconfig 
​......
​iptables       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
​.....
​[root@MgsLocalhostData /]# service iptables stop
​iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
​iptables: Flushing firewall rules:                         [  OK  ]
​iptables: Unloading modules:                               [  OK  ]
​[root@MgsLocalhostData /]# chkconfig iptables off
​[root@MgsLocalhostData /]# chkconfig 
​......
​iptables       	0:off	1:off	2:off	3:off	4:off	5:off	6:off
​.....

3. System security
​cd /etc/selinux
​vi config
Change SELINUX to =disabled
​[root@MgsLocalhostData selinux]# cat config
​......

disabled - No SELinux policy is loaded.

​ SELINUX=disabled
​ ......
​ SELINUXTYPE=targeted
Delete files related to network physical addresses

	[root@MgsLocalhostData selinux]# cd /etc
​	[root@MgsLocalhostData etc]# cd udev
​	[root@MgsLocalhostData udev]# cd rules.d
​	[root@MgsLocalhostData rules.d]# ls -l
​	total 16
​	-rw-r--r--. 1 root root 316 Nov 22  2013 60-raw.rules
​	-rw-r--r--. 1 root root 789 Jul 19 23:40 70-persistent-cd.rules
​	-rw-r--r--. 1 root root 420 Jul 19 23:36 70-persistent-net.rules
​	-rw-r--r--. 1 root root  54 Dec  8  2011 99-fuse.rules
​	[root@MgsLocalhostData rules.d]# cat 70-persistent-net.rules

This file was automatically generated by the /lib/udev/write_net_rules

program, run by the persistent-net-generator.rules rules file.

​	#

You can modify it, as long as you keep each rule on a single

line, and change only the value of the NAME= key.

PCI device 0x8086:0x100f (e1000)

​	SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d5:f3:c7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
​	[root@MgsLocalhostData rules.d]# rm -f  /etc/udev/rules.d/70-persistent-net.rules
​	poweroff

2, The obtained virtual machine is used as a model machine to configure other hosts
Snapshot virtual machine
Clone 4 virtual machines through snapshots

Start the virtual machine cloned by snapshot, and modify the
1. IP address
vi /etc/sysconfig/network-scripts/ifcfg-eth0
The first IP 192.168.25.50, the second IP 192.168.25.51
2. Hostname
vi /etc/sysconfig/network
HOSTNAME = MDNode01
3. Address mapping
vi /etc/hosts
192.168.25.50 MDNode01
192.168.25.51 MDNode02
192.168.25.52 MDNode03
192.168.25.53 MDNode04
4. The hosts setting under wind is different from the third operation
5. Check communication between 5 devices

Common Linux commands

  1. ifconfig View the current computer network configuration

    [root@MDNode01 ~]# ifconfig
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:BF:3A:BE  
    		  inet addr:192.168.25.50  Bcast:192.168.25.255  Mask:255.255.255.0
    		  inet6 addr: fe80::20c:29ff:febf:3abe/64 Scope:Link
    		  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    		  RX packets:212 errors:0 dropped:0 overruns:0 frame:0
    		  TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
     	  collisions:0 txqueuelen:1000 
    		  RX bytes:19036 (18.5 KiB)  TX bytes:11912 (11.6 KiB)
    
    lo        Link encap:Local Loopback  
    		  inet addr:127.0.0.1  Mask:255.0.0.0
    		  inet6 addr: ::1/128 Scope:Host
    		  UP LOOPBACK RUNNING  MTU:16436  Metric:1
    		  RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    		  TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
     	  collisions:0 txqueuelen:0 
    		  RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
    
  2. type ifconfig You can find the location of the command program
    [root@MDNode01 ~]# type ifconfig
    ifconfig is hashed (/sbin/ifconfig)

  3. file ifconfig View the command file. ELF represents the executable file,
    [root@MDNode01 sbin]# file ifconfig
    ifconfig: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

  4. echo print variable or string
    [root@MDNode01 sbin]# echo $PATH
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

  5. yum install command program
    yum install man man-pages

  6. Learn external commands through the man command.
    man ifconfig

  7. help to learn internal commands,

    [root@MDNode01 /]# help
    GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
    These shell commands are defined internally.  Type `help' to see this list.
    Type `help name' to find out more about the function `name'.
    Use `info bash' to find out more about the shell in general.
    Use `man -k' or `info' to find out more about commands not in this list.
    
    A star (*) next to a name means that the command is disabled.
    
     job_spec [&]                                history [-c] [-d offset] [n] or history >
     (( expression ))                            if COMMANDS; then COMMANDS; [ elif COMMA>
     . filename [arguments]                      jobs [-lnprs] [jobspec ...] or jobs -x c>
     :                                           kill [-s sigspec | -n signum | -sigspec]>
     [ arg... ]                                  let arg [arg ...]
     [[ expression ]]                            local [option] name[=value] ...
     alias [-p] [name[=value] ... ]              logout [n]
     bg [job_spec ...]                           mapfile [-n count] [-O origin] [-s count>
     bind [-lpvsPVS] [-m keymap] [-f filename]>  popd [-n] [+N | -N]
     break [n]                                   printf [-v var] format [arguments]
     builtin [shell-builtin [arg ...]]           pushd [-n] [+N | -N | dir]
     caller [expr]                               pwd [-LP]
     case WORD in [PATTERN [| PATTERN]...) COM>  read [-ers] [-a array] [-d delim] [-i te>
     cd [-L|-P] [dir]                            readarray [-n count] [-O origin] [-s cou>
     command [-pVv] command [arg ...]            readonly [-af] [name[=value] ...] or rea>
     compgen [-abcdefgjksuv] [-o option]  [-A >  return [n]
     complete [-abcdefgjksuv] [-pr] [-DE] [-o >  select NAME [in WORDS ... ;] do COMMANDS>
     compopt [-o|+o option] [-DE] [name ...]     set [--abefhkmnptuvxBCHP] [-o option-nam>
     continue [n]                                shift [n]
     coproc [NAME] command [redirections]        shopt [-pqsu] [-o] [optname ...]
     declare [-aAfFilrtux] [-p] [name[=value] >  source filename [arguments]
     dirs [-clpv] [+N] [-N]                      suspend [-f]
     disown [-h] [-ar] [jobspec ...]             test [expr]
     echo [-neE] [arg ...]                       time [-p] pipeline
     enable [-a] [-dnps] [-f filename] [name .>  times
     eval [arg ...]                              trap [-lp] [[arg] signal_spec ...]
     exec [-cl] [-a name] [command [arguments >  true
     exit [n]                                    type [-afptP] name [name ...]
     export [-fn] [name[=value] ...] or export>  typeset [-aAfFilrtux] [-p] name[=value] >
     false                                       ulimit [-SHacdefilmnpqrstuvx] [limit]
     fc [-e ename] [-lnr] [first] [last] or fc>  umask [-p] [-S] [mode]
     fg [job_spec]                               unalias [-a] name [name ...]
     for NAME [in WORDS ... ] ; do COMMANDS; d>  unset [-f] [-v] [name ...]
     for (( exp1; exp2; exp3 )); do COMMANDS; >  until COMMANDS; do COMMANDS; done
     function name { COMMANDS ; } or name () {>  variables - Names and meanings of some s>
     getopts optstring name [arg]                wait [id]
     hash [-lr] [-p pathname] [-dt] [name ...]>  while COMMANDS; do COMMANDS; done
     help [-dms] [pattern ...]                   { COMMANDS ; }
    
    

sudoku

file system
df -h
Displays the drive letter size of the computer
[root@MDNode01 etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 195G 834M 184G 1% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 194M 28M 157M 15% /boot

[root@MDNode01 usr]# ls -l
total 60
dr-xr-xr-x.  2 root root 12288 Jul 20 18:05 bin
drwxr-xr-x.  2 root root  4096 Sep 23  2011 etc
drwxr-xr-x.  2 root root  4096 Sep 23  2011 games
drwxr-xr-x.  3 root root  4096 Jul 19 23:36 include
dr-xr-xr-x.  9 root root  4096 Jul 19 23:37 lib
dr-xr-xr-x. 24 root root 12288 Jul 20 18:05 lib64
drwxr-xr-x.  9 root root  4096 Jul 20 18:05 libexec
drwxr-xr-x. 12 root root  4096 Jul 19 23:36 local
dr-xr-xr-x.  2 root root  4096 Jul 20 18:05 sbin
drwxr-xr-x. 61 root root  4096 Jul 19 23:37 share
drwxr-xr-x.  4 root root  4096 Jul 19 23:36 src

lrwxrwxrwx.  1 root root    10 Jul 19 23:36 tmp -> ../var/tmp

Query the size of all files under the current directory

[root@MDNode01 usr]# du -sh ./*
19M		./bin
4.0K	./etc
4.0K	./games
40K		./include
98M		./lib
55M		./lib64
7.8M	./libexec
132K	./local
24M		./sbin
182M	./share
12K		./src
0		./tmp

File name of query file

[root@MDNode01 dev]# ls -l /dev/
total 0
crw-rw---- 1 root video    10, 175 Jul 21 05:49 agpgart
.....
crw-rw-rw- 1 root root      1,   5 Jul 21 05:49 zero

c. C the beginning represents the executable equipment file

man read

file descriptor

Describe the three forms of documents,

Any process has three basic flows

0 Represents the input stream

one Correct output stream

two Faulted output stream

file system

[root@MDNode01 /]# ls -l
total 94
dr-xr-xr-x.  2 root root  4096 Jul 19 23:37 bin
dr-xr-xr-x.  5 root root  1024 Jul 19 23:38 boot
drwxr-xr-x  18 root root  3700 Aug  8 16:30 dev
drwxr-xr-x. 61 root root  4096 Aug  8 16:30 etc
drwxr-xr-x.  2 root root  4096 Sep 23  2011 home
dr-xr-xr-x.  8 root root  4096 Jul 19 23:37 lib
dr-xr-xr-x.  9 root root 12288 Jul 19 23:37 lib64
drwx------.  2 root root 16384 Jul 19 23:35 lost+found
drwxr-xr-x.  2 root root  4096 Sep 23  2011 media
drwxr-xr-x.  2 root root  4096 Sep 23  2011 mnt
drwxr-xr-x.  2 root root  4096 Sep 23  2011 opt
dr-xr-xr-x  84 root root     0 Aug  8 16:30 proc
dr-xr-x---.  2 root root  4096 Jul 20 02:21 root
dr-xr-xr-x.  2 root root 12288 Jul 19 23:37 sbin
drwxr-xr-x.  2 root root  4096 Jul 19 23:36 selinux
drwxr-xr-x.  2 root root  4096 Sep 23  2011 srv
drwxr-xr-x  13 root root     0 Aug  8 16:30 sys
drwxrwxrwt.  3 root root  4096 Aug  8 17:31 tmp
drwxr-xr-x. 13 root root  4096 Jul 19 23:36 usr
drwxr-xr-x. 17 root root  4096 Jul 19 23:36 var

bin and sbin are executable directories (ELF and scripts)

Home directory of root administrator

media mount point directory, mobile device

mnt mount point, additional temporary file system

proc pseudo file system, kernel mapping file

sys pseudo file system, hardware related attribute mapping file

tmp temporary file

Var changeable file /var./tmp

erc profile

Lib and lib64 secondary development libraries

Boot boot directory

dev in Linux, everything is a file. Abstract the system into a file and put it under this directory

Home user's home directory

var directory, where files, data and logs generated by program execution are stored

usr directory, directory of the installer

opt directory directory of the custom installer

[root@MDNode01 /]# du -sh ./*

Query the size of the directory under the current directory

file type

Under the ls -l command

The first word represents the file type

-- Common file

b Byte stream

c Character stream

d catalogue

c. b Equipment documentation

l link

p. s Invisible pipes and networks

Operation documents

cd- Previous file

Depth bedstead file mkdir -p [directory name / directory name]

Horizontal creation mkdir [] [] can accept multiple parameters

The You can also create mkdir/ [directory] / {1,2,3}dir

rm delete command

rm -fr Force delete

[root@MDNode01 ~]# ls -li
total 24
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog


11796491 represents the index number of physical storage

ln soft connection and hard link
[root@MDNode01 ~]# vi a.txt
[root@MDNode01 ~]# cat a.txt
ls Show the files under the current directory
ls -li	Detailed display of the information of the files under the current directory
pwd	Show current file location
touch	Create a file
clear	Clear screen information
hop	Show the current system CPU Operating conditions
[root@MDNode01 ~]# ll -li
total 28
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  1 root root  234 Aug  8 19:51 a.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
[root@MDNode01 ~]# ln a.txt b.txt
[root@MDNode01 ~]# ll -li
total 32
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  2 root root  234 Aug  8 19:51 a.txt
11796496 -rw-r--r--  2 root root  234 Aug  8 19:51 b.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
[root@MDNode01 ~]# cat b.txt
ls Show the files under the current directory
ls -li	Detailed display of the information of the files under the current directory
pwd	Show current file location
touch	Create a file
clear	Clear screen information
hop	Show the current system CPU Operating conditions
[root@MDNode01 ~]# 

For the hard link created, after deleting the original file, the ln hard linked file will not be affected

[root@MDNode01 ~]# rm -f a.txt 
[root@MDNode01 ~]# ll -li
total 28
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  1 root root  234 Aug  8 19:51 b.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
[root@MDNode01 ~]# cat b.txt
ls Show the files under the current directory
ls -li	Detailed display of the information of the files under the current directory
pwd	Show current file location
touch	Create a file
clear	Clear screen information
hop	Show the current system CPU Operating conditions
[root@MDNode01 ~]# 

Create a soft link

ln -s [file] [file]
[root@MDNode01 ~]# ln b.txt c.txt
[root@MDNode01 ~]# ll -li
total 32
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  2 root root  234 Aug  8 19:51 b.txt
11796496 -rw-r--r--  2 root root  234 Aug  8 19:51 c.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
[root@MDNode01 ~]# ln -s c.txt d.txt
[root@MDNode01 ~]# ll -li
total 32
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  2 root root  234 Aug  8 19:51 b.txt
11796496 -rw-r--r--  2 root root  234 Aug  8 19:51 c.txt
11796494 lrwxrwxrwx  1 root root    5 Aug  8 20:00 d.txt -> c.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
[root@MDNode01 ~]# 

Soft connection:

The Have an independent physical storage space pointed to, and the number of links has not changed

The But deleting the source file is similar to a hard link. Changing the information under that link will change the other link

Soft connection -- >> source file -->> physical memory

The Hard link -->> Point to the same physical location as the source file

[root@MDNode01 ~]# rm -f c.txt
[root@MDNode01 ~]# ll -li
total 28
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  1 root root  234 Aug  8 19:51 b.txt
11796494 lrwxrwxrwx  1 root root    5 Aug  8 20:00 d.txt -> c.txt[There will be problems with this link]
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog

[root@MDNode01 ~]# cat d.txt
cat: d.txt: No such file or directory

Create a file you deleted and you can repair it

[root@MDNode01 ~]# vi c.txt
[root@MDNode01 ~]# ll -li
total 32
11796491 drwxr-xr-x  3 root root 4096 Aug  8 18:55 a
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796496 -rw-r--r--  1 root root  234 Aug  8 19:51 b.txt
11796497 -rw-r--r--  1 root root   33 Aug  8 20:21 c.txt
11796494 lrwxrwxrwx  1 root root    5 Aug  8 20:00 d.txt -> c.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
[root@MDNode01 ~]# 

That's it,

stat
[root@MDNode01 /]# cd etc
[root@MDNode01 etc]# stat ./profile
  File: `./profile'
  Size: 1796      	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 4980771     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-08-08 16:32:12.672043023 +0800
Modify: 2013-10-02 17:06:18.000000000 +0800
Change: 2019-07-19 23:36:08.683998356 +0800

stat view file metadata [equivalent to file attributes of wind]

Access: Time of last visit

Modify: Time when the content was last modified

Change: Last change time of metadata

[root@MDNode01 /]# cd etc
[root@MDNode01 etc]# stat ./profile
  File: `./profile'
  Size: 1796      	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 4980771     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-08-08 16:32:12.672043023 +0800
Modify: 2013-10-02 17:06:18.000000000 +0800
Change: 2019-07-19 23:36:08.683998356 +0800
[root@MDNode01 etc]# chmod a+x ./profile
[root@MDNode01 etc]# stat ./profile
  File: `./profile'
  Size: 1796      	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 4980771     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-08-08 16:32:12.672043023 +0800
Modify: 2013-10-02 17:06:18.000000000 +0800
Change: 2019-08-08 20:29:13.799044630 +0800
[root@MDNode01 etc]# ll -li | grep profile
4980771 -rwxr-xr-x.  1 root root   1796 Oct  2  2013 profile
4980772 drwxr-xr-x.  2 root root   4096 Jul 19 23:36 profile.d
[root@MDNode01 etc]# date
Thu Aug  8 20:31:46 CST 2019
[root@MDNode01 etc]# vi ./profile
[root@MDNode01 etc]# ll -li ./profile
4981697 -rwxr-xr-x 1 root root 1805 Aug  8 20:32 ./profile
[root@MDNode01 etc]# stat ./profile
  File: `./profile'
  Size: 1805      	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 4981697     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-08-08 20:32:31.589055215 +0800
Modify: 2019-08-08 20:32:31.589055215 +0800
Change: 2019-08-08 20:32:31.598054119 +0800
[root@MDNode01 etc]# 

touch

Touch,

[root@MDNode01 ~]# stat b.txt
  File: `b.txt'
  Size: 234       	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 11796496    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-08-08 19:56:09.671039508 +0800
Modify: 2019-08-08 19:51:10.567018568 +0800
Change: 2019-08-08 20:10:24.560042611 +0800
[root@MDNode01 ~]# touch b.txt
[root@MDNode01 ~]# stat b.txt
  File: `b.txt'
  Size: 234       	Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d	Inode: 11796496    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-08-08 20:40:11.507017786 +0800
Modify: 2019-08-08 20:40:11.507017786 +0800
Change: 2019-08-08 20:40:11.507017786 +0800
[root@MDNode01 ~]# 

You can use this command as a security mechanism

You can also create a file or directory that does not exist

cat command

cat is an external command and a process

more command

more is a view file

less command

These three commands are commands to view the contents of a file

head command and tail

head view the first ten lines of the file, and tail display the end of the file

head -4 [file name] tail -4 [file name] view the first 4 lines of the file and view the last 4 lines of the file

You can use the pipe to assign the last line from the head query to the tail command to display the last line

echo "/" | xargs ls -l

vi editor

vi +4 [file name] open the relative file and move the cursor to line 4

vi +/etc [file name] after opening editing, the cursor moves to the number of lines in etc relative to. Acquaintance search function,

When exiting the edit mode, ZZ means exit.

Edit -- > > Input

i: Insert in front of the cursor

a: Insert after current cursor

o: Create a new line under the line where the cursor is located, move the cursor to the down line, and change to the input mode

O: Create a new bank at the top and switch to input mode

1: Move the cursor to the beginning of the current line and change to input mode

A: Move the cursor to the end of the line to change to input mode

Esc-->> edit mode:

In edit mode: / "string" finds the first position in the text where the string appears

byte

h: Cursor moves left

j: Move under cursor

k: Move cursor up

l: Cursor move right

word

w: Move to next word

e: Jump to the end of the current or next word

b: Jump to the beginning of the current or next word

Hanlin Academician

0 (zero): absolute line beginning

^: the first white space character of the current line

$: absolute end of line

Between lines

G: End of article

3G: third line

gg: the beginning of the article

Flip screen:

ctrl+f or ctrl+b

Delete and replace individual characters

x: Delete character at cursor position

3x: delete the first three characters of the cursor

r: Replace current character

delete

dw: delete current character

dd: delete the current row

Copy and Paste

2dd: clip the two lines below the current cursor

ym: copy the current word

yy: copy the current row

2yy: copy two rows

P (upper case), paste to previous line

P (lowercase), paste to next line

ctrl+r to return to the previous operation

u: Revocation

..: Execute the command executed in the previous step

Edit mode -- > > last line mode

:

😕 "": find string

: set nu display line number

: set nonu turn off display of line numbers

/"" find directly

n next

N previous

In the last line mode, 1,$d deletes the first line to the last line

Find and replace

1,$s/a/b/

Replace the a character from the first line to the last with the b character, and the slash can be replaced with \

Prompt for information in behavior unit, prompt for replacement

: set nu: like

Range in last line mode

n: Representative bank No

..: Current cursor line

+n: Remote you can

$: end line

%, full text

Grep: Command

Find the line in the b.txt file that contains the ls string

[root@MDNode01 ~]# grep ls b.txt
ls Show the files under the current directory
ls -li	Detailed display of the information of the files under the current directory

Show rows without ls

[root@MDNode01 ~]# grep -v ls b.txt
pwd	Show current file location
touch	Create a file
clear	Clear screen information
hop	Show the current system CPU Operating conditions
[root@MDNode01 ~]#

wildcard

[root@MDNode01 ~]# ls -li
total 32
11796491 drwxr-xr-x  3 root root 4096 Aug  9 06:40 a
11796495 -rw-r--r--  1 root root    0 Aug  9 06:40 ab
11796496 -rw-r--r--  1 root root    0 Aug  9 06:40 abc
11796489 -rw-------. 1 root root  900 Jul 19 23:38 anaconda-ks.cfg
11796499 -rw-r--r--  1 root root    0 Aug  9 06:40 bcd
11796498 -rw-r--r--  1 root root  234 Aug  9 06:20 b.txt
11796500 -rw-r--r--  1 root root    0 Aug  9 06:41 cde
11796497 -rw-r--r--  1 root root   33 Aug  8 20:21 c.txt
11796494 lrwxrwxrwx  1 root root    5 Aug  8 20:00 d.txt -> c.txt
11796482 -rw-r--r--. 1 root root 8815 Jul 19 23:38 install.log
11796483 -rw-r--r--. 1 root root 3384 Jul 19 23:37 install.log.syslog
11796501 -rw-r--r--  1 root root    0 Aug  9 06:41 xyz
[root@MDNode01 ~]# ll -li ./a*
11796495 -rw-r--r--  1 root root    0 Aug  9 06:40 ./ab
11796496 -rw-r--r--  1 root root    0 Aug  9 06:40 ./abc
11796489 -rw-------. 1 root root  900 Jul 19 23:38 ./anaconda-ks.cfg

./a:
total 4
11796492 drwxr-xr-x 3 root root 4096 Aug  8 18:55 b
[root@MDNode01 ~]# ll -li ./a?
11796495 -rw-r--r-- 1 root root 0 Aug  9 06:40 ./ab
[root@MDNode01 ~]# ll -li ./a??
11796496 -rw-r--r-- 1 root root 0 Aug  9 06:40 ./abc
regular expression

Match operator

\The Escape character

Match any single character

^The Line beginning

The$ End of line

|The Join operator

(,) selection operator

\n Back reference

[] Character sequence single character placeholder

[1249a]:1249 exists in the representative file a Character match of,
[^12]:Negative, no 1 or 2 characters

Word beginning and ending boundary

\<,\>;\<abc Match words with abc First word

Repeat operator

?		Match 0 to 1 times
*		Match 0 to more than once
+		Match 1 to more than once
{n}		matching n second
{n,}	matching n To many times
{n,m}	matching n reach m second

Tags: Linux Big Data

Posted by gaz_hayes on Mon, 30 May 2022 12:31:19 +0530