2021-11-29 the 38th step towards procedural ape

catalogue

1, linux overview

2, Installing VMware

3, Installing LINUX

4, linux common commands

4.1 description of command format

4.2 three common commands

4.3 help command

4.4 document processing instructions

4.5 document viewing instructions

4.6 document search instruction

4.7 file (DE) compression instruction

4.8 time instruction date

4.9 system shutdown command

4.10 shortcut keys, basename and dirname of Linux

1, linux overview

        Just know a little from Baidu~

2, Installing VMware

        The operation is simple. It defaults to the next step. If a vm has been deleted before, you may need to clean the registry with the next cccleaner. After successful installation, check whether there are more vmnet1 and vmnet8 network adapters

3, Installing LINUX

        Configure the hardware information of the virtual machine according to the capacity of your computer. If the computer is good, you can also choose downward compatibility. Generally, you can use 2G2 core 50G memory, and then install a centos image file. The minimum version and visualization are OK

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4, linux common commands

4.1 description of command format

  Enter the prompt analysis of the command line interface
 [root@localhost ~]#
  root location:   Login user name
 @: Connection symbol
  localhost location:   Host name of this machine  
 ~ Location:   Current location
 # Location:   Indicates whether you are a super administrator or an ordinary user
  Super administrators use#
  Ordinary users use$  

4.2 three common commands

1. pwd :  print current work directory Abbreviations of three words
          The function is to display the current position in the form of absolute path
          eg:
          [root@localhost network-scripts]# pwd
		  /etc/sysconfig/network-scripts
		  [root@localhost ~]# pwd
		  /root
2. ls :   list directory contents Abbreviation for
          The function is to list the contents in the specified directory(Files, subdirectories, etc)
          eg:  ls   By default, the contents in the current workspace are listed
          
          Common options:  
          	-l :  List the attribute details of each sub file     
            -a :  Show all content, including hidden
            -S :  Sort the display in descending order by size, and try to match with-h,-l Use together
            -h:   A unit of size displayed in a human readable display effect, such as k,MB,G
         eg:  ls -l Display attribute details to simplify writing: ll
         eg:  ls -a Show all including hidden content
         eg:  ls -l -a Show all attribute details including hidden content, and write them simply: ll -a  perhaps ls -la
         eg:  ls -lhS  Display all contents in the current directory and sort them in descending order
         eg:  ls -lhS /etc  Displays the specified directory/etc All the contents under and sort them in descending order
         
         
3. cd :  change directory For short, switch workspaces.
         Note: it is a special instruction, and it is a special instruction shell Built in instructions.
         
         cd  [target directory]
         eg:   cd       get home
         eg:   cd ~     get home
         eg:   cd -    Return to the last position
         eg:   cd /etc   Switch to/etc lower
         eg:   cd ..   Go back to the previous directory(Parent directory)
               cd .  Indicates immobility

4.3 help command

man instructions:
Function: view the help document of the specified command
 Syntax: man  instructions
eg:   man ls
      man pwd
      man cd

help instructions:
Function: view the subject information of the specified command
 Syntax:  help  instructions
 Note: not all instructions have subject information

info instructions:
Function: used to view the details of the command
 Syntax: info instructions

4.4 document processing instructions

4.4.1 touch

Function: used to create an empty file
 Syntax: touch  filename.....
eg:   
[root@localhost etc]# touch file1 file2 file3
[root@localhost etc]# pwd
/etc
[root@localhost etc]# touch ~/file4
[root@localhost etc]# touch ~/{file5,file6}
[root@localhost etc]# ls ~
anaconda-ks.cfg  file1  file2  file3  file4  file5  file6

4.4.2 mkdir

Function: used to create a directory
 Syntax: mkdir [-p]  dirname.....

[root@localhost ~]# mkdir dir1
[root@localhost ~]# mkdir ./dir2 ./dir3
[root@localhost ~]# cd /etc
[root@localhost etc]# mkdir ~/{dir4,dir5}
[root@localhost etc]# mkdir ~/dir6/dir66       #An error will be reported because dir6 does not exist, so dir66 cannot be created
[root@localhost etc]# mkdir -p ~/dir6/dir66    #Represents a multi-level directory creation
[root@localhost etc]# ls -l ~
Total consumption 4
-rw-------. 1 root root 1259 11 September 29-19:03 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 11 September 29-22:32 dir1
drwxr-xr-x. 2 root root    6 11 September 29-22:33 dir2
drwxr-xr-x. 2 root root    6 11 September 29-22:33 dir3
drwxr-xr-x. 2 root root    6 11 September 29-22:33 dir4
drwxr-xr-x. 2 root root    6 11 September 29-22:33 dir5
drwxr-xr-x. 3 root root   19 11 September 29-22:34 dir6
-rw-r--r--. 1 root root    0 11 September 29-22:28 file1
-rw-r--r--. 1 root root    0 11 September 29-22:28 file2
-rw-r--r--. 1 root root    0 11 September 29-22:28 file3
-rw-r--r--. 1 root root    0 11 September 29-22:29 file4
-rw-r--r--. 1 root root    0 11 September 29-22:30 file5
-rw-r--r--. 1 root root    0 11 September 29-22:30 file6
[root@localhost etc]# ls ~/dir6
dir66

4.4.3 rm

Function: delete files or directories
 Syntax: rm [-rf]  filename .....
eg: 
  
[root@localhost ~]# ls
anaconda-ks.cfg  dir1  dir2  dir3  dir4  dir5  dir6  file1  file2  file3  file4  file5  file6
[root@localhost ~]# rm file1
rm: Delete normal empty file "file1"?y
[root@localhost ~]# ls
anaconda-ks.cfg  dir1  dir2  dir3  dir4  dir5  dir6  file2  file3  file4  file5  file6
[root@localhost ~]# rm dir1
rm: Cannot delete"dir1": Is a directory
[root@localhost ~]# rm -f file2
[root@localhost ~]# ls
anaconda-ks.cfg  dir1  dir2  dir3  dir4  dir5  dir6  file3  file4  file5  file6
[root@localhost ~]# rm -r dir1
rm: Delete directory "dir1"?y
[root@localhost ~]# ls
anaconda-ks.cfg  dir2  dir3  dir4  dir5  dir6  file3  file4  file5  file6
[root@localhost ~]#  


Summary: by default, the file is deleted with query. Enter y Indicates deletion, enter n Indicates not to delete
       If you want to force the deletion of files, add-f, But use it with caution.
       
       If you want to delete a directory, you must add-r,Indicates recursive deletion.

4.4.4 mv

Function: move files or directories and rename them
 Syntax: mv [OPTION]... SOURCE... DIRECTORY

eg: 
[root@localhost ~]# ls
anaconda-ks.cfg  dir2  dir3  dir4  dir5  dir6  file3  file4  file5  file6
[root@localhost ~]# mv file3 file4 dir2 dir3    # Move file3 file4 dir2 to dir3
[root@localhost ~]# ls
anaconda-ks.cfg  dir3  dir4  dir5  dir6  file5  file6
[root@localhost ~]# ls dir3
dir2  file3  file4
[root@localhost ~]# mv file6 dir3/file7     #Move file6 to dir3 and rename it file7
[root@localhost ~]# ls dir3
dir2  file3  file4  file7
[root@localhost ~]#

4.4.5 cp

Function: copy files or directories
 Syntax: cp [-r] source....directory

eg:
[root@localhost ~]# rm -rf. / * delete all non hidden files in the current directory
[root@localhost ~]# touch file1 file2 file3
[root@localhost ~]# mkdir dir1 dir2 dir3
[root@localhost ~]# ll
 Total consumption 0
drwxr-xr-x. 2 root root 6 11 September 29-23:04 dir1
drwxr-xr-x. 2 root root 6 11 September 29-23:04 dir2
drwxr-xr-x. 2 root root 6 11 September 29-23:04 dir3
-rw-r--r--. 1 root root 0 11 September 29-23:04 file1
-rw-r--r--. 1 root root 0 11 September 29-23:04 file2
-rw-r--r--. 1 root root 0 11 September 29-23:04 file3
[root@localhost ~]# cp file1 dir1   # Copy file1 to dir1
[root@localhost ~]# ll
 Total consumption 0
drwxr-xr-x. 2 root root 19 11 September 29-23:04 dir1
drwxr-xr-x. 2 root root  6 11 September 29-23:04 dir2
drwxr-xr-x. 2 root root  6 11 September 29-23:04 dir3
-rw-r--r--. 1 root root  0 11 September 29-23:04 file1   #The source file still exists
-rw-r--r--. 1 root root  0 11 September 29-23:04 file2
-rw-r--r--. 1 root root  0 11 September 29-23:04 file3
[root@localhost ~]# ls dir1   # Check the contents in dir1
file1
[root@localhost ~]# echo "helloworld" > file2   #Write some strings into the file2 file
[root@localhost ~]# ll
 Total consumption 4
drwxr-xr-x. 2 root root 19 11 September 29-23:04 dir1
drwxr-xr-x. 2 root root  6 11 September 29-23:04 dir2
drwxr-xr-x. 2 root root  6 11 September 29-23:04 dir3
-rw-r--r--. 1 root root  0 11 September 29-23:04 file1
-rw-r--r--. 1 root root 11 11 September 29-23:05 file2
-rw-r--r--. 1 root root  0 11 September 29-23:04 file3
[root@localhost ~]# cp file2 dir1/file22   # Copy File2 to dir1 and rename it file22
[root@localhost ~]# ll dir1
 Total consumption 4
-rw-r--r--. 1 root root  0 11 September 29-23:04 file1
-rw-r--r--. 1 root root 11 11 September 29-23:05 file22
[root@localhost ~]# cp file3 file4     #Copy and rename
[root@localhost ~]# ll
 Total consumption 4
drwxr-xr-x. 2 root root 33 11 September 29-23:05 dir1
drwxr-xr-x. 2 root root  6 11 September 29-23:04 dir2
drwxr-xr-x. 2 root root  6 11 September 29-23:04 dir3
-rw-r--r--. 1 root root  0 11 September 29-23:04 file1
-rw-r--r--. 1 root root 11 11 September 29-23:05 file2
-rw-r--r--. 1 root root  0 11 September 29-23:04 file3
-rw-r--r--. 1 root root  0 11 September 29-23:07 file4
[root@localhost ~]# cp dir2 dir3    # When copying a directory, the directory will be ignored without the - r parameter
cp: Skip directory"dir2"
[root@localhost ~]# ll dir3
 Total consumption 0
[root@localhost ~]# cp dir1 dir3
cp: Skip directory"dir1"
[root@localhost ~]# ll dir3
 Total consumption 0
[root@localhost ~]# cp -r dir1 dir3   # If you want to copy a directory, you should take the - r parameter, which means recursive copy
[root@localhost ~]# ll dir3
 Total consumption 0
drwxr-xr-x. 2 root root 33 11 September 29-23:08 dir1

4.4.6 ln

Role: used to create linked files
 Syntax: ln [-s] filename newfilename
 Resolution:
    linux There are two types of linked files,
    One is soft link file: soft link file is equivalent to windows Shortcut to
                     Files and directories can have soft links
                     Create syntax:  ln -s filename newfilename
                     
    One is hard link files: files can have hard links, and directories cannot have hard links
    				 Create syntax: ln filename newfilename
    
    
    Summary: soft links, newly opened up a file block and inode
          Hard link is the alias of the source file name

4.4.7 echo

Function: used to display a line of file information
 Syntax:  echo  character string|Environment variable name

[root@localhost ~]# echo you are best     # Print a string of characters to the console
you are best
[root@localhost ~]# echo "you are best"
you are best
[root@localhost ~]# echo $HOME   #Print the value of the HOME variable
/root
[root@localhost ~]# echo $PATH   #Prints the value of the PATH variable
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# echo $HOSTNAME  #Print the value of the HOSTNAME variable
localhost.localdomain

> : Redirecting to a location will overwrite the original content
>>: Redirect to a civilian and append to the original content


[root@localhost ~]# echo "hello world"
hello world

# Input a string of characters into the content.txt file. Note that if the file does not exist, it will be created directly.
[root@localhost ~]# echo "hello world" > content.txt  
[root@localhost ~]# ll
 Total consumption 16
-rw-r--r--. 1 root root 12 11 September 29-23:43 content.txt
[root@localhost ~]# echo "hello" > content.txt   #cover
[root@localhost ~]# ll
 Total consumption 16
-rw-r--r--. 1 root root  6 11 September 29-23:43 content.txt     #Into 6 bytes
[root@localhost ~]# echo "world" >> content.txt  #Add
[root@localhost ~]# ll
 Total consumption 16
-rw-r--r--. 1 root root 12 11 September 29-23:44 content.txt     #Become 12 bytes

4.5 document viewing instructions

4.5.1 cat

Function: view the contents of the entire file
 Syntax:  cat [-An] filename
 Resolution: -A  Show hidden characters
      -n  set number 

4.5.2 more/less

Function: used to view file contents in pages
 Syntax: more filename
 Parsing: view the first page by default
       Space bar/f key    View next page
       enter Key: scroll line by line
       b :Page back
       q|Q: sign out
       
       less and more Same usage

4.5.3 head

Function: view the header information of the file. The default is 10 lines
 Syntax: head [-number] filename
 Parse: if you want to view the specified number of rows, add-number

4.5.4 tail

Function: view the information at the end of the file. By default, view 10 lines
 Syntax: tail [-number] filename
 Parse: if you want to view the specified number of rows, add-number

4.6 document search instruction

4.6.1 find

Function: it can find files or directories in the file system according to the specified type parameters
 Syntax: find Search location criteria
eg:
 
[root@localhost ~]# find /etc -name 'init *' find the file or directory beginning with init by name
/etc/inittab
/etc/sysconfig/init
/etc/sysconfig/network-scripts/init.ipv6-global
/etc/init.d
/etc/rc.d/init.d
/etc/selinux/targeted/active/modules/100/init
/etc/selinux/targeted/contexts/initrc_context
[root@localhost ~]# find /etc -name 'init' according to the file or directory named init
/etc/sysconfig/init
/etc/selinux/targeted/active/modules/100/init
[root@localhost ~]# find /etc -name 'in??'     Find a file or directory that starts with in and has a length of 4 by name
/etc/sysconfig/init
/etc/selinux/targeted/active/modules/100/init
[root@localhost ~]# find /etc -name '?i * 'find the file or directory whose second character is i by name


find /etc -type d    see/etc All directories under, including subdirectories
                d:catalogue   l:Soft links, f: Ordinary file
find /etc -size -1024 
find /etc -size +2K  -size -3k       Company: k,M,G etc.
          
          
          Note: the default unit is one block   One block Equivalent to 512 byte
                If you want to query less than 100 MB Files, 100*1024KB  100*1024*2block
                So: find /etc -size -204800 
                     find /etc -size +1024    View greater than 512 KB File

4.6.2 grep

Function: used to filter the contents of query files
 Syntax: grep [-cinv] 'Search string' filename

-c : Output the number of matching rows (in behavior units, not in occurrences)
-i : Case is ignored, so case is considered the same
-n : Display matching lines and line numbers
-v : Reverse selection to display all lines that do not contain matching text.

eg:
  [root@localhost ~]# Grep - I host. / profile ignores the case and finds the line information where the host is located
  [root@localhost ~]# Grep - CI host. / profile ignores the case to find the number of rows where the host is located
  [root@localhost ~]# Grep - in host. / profile ignores case and finds the line information and line number where the host is located
  [root@localhost ~]# Grep - V HOST. / profile finds information about other rows except the row where HOST is located

The Conduit:  |
Function: pass the result of the previous command to the next command through the pipeline to continue the operation

[root@localhost ~]# grep -i HOST ./profile
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# The results of the previous query are handed over to the next grep for further filtering
[root@localhost ~]# grep -i HOST ./profile  | grep USER 
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

4.6.3 which

Function: used in path Find the location of the command in the value of the variable
 Syntax: which  command

4.6.4 whereis

Function: used to view the location of commands and help files
 Syntax:  whereis  command

4.7 file (DE) compression instruction

4.7.1 gzip/gunzip

Function: compression instruction to compress each file. One file corresponds to one compressed file
 Syntax:  gzip  filename.....
characteristic:  
		- Only compressed files,
		- And the source file disappears
        - Suffix of compressed file name.gz
gzip -d Represents decompression, equivalent to gunzip Role of

4.7.2 bzip2/bunzip2

Function: compression instruction to compress each file. One file corresponds to one compressed file
 Syntax:  bzip2  filename.....
characteristic:  
		- Only compressed files,
		- By default, the source file disappears unless you bring it with you-k Parameter, the source file is retained
        - Suffix of compressed file name.bz2
bzip2 -d Represents decompression, equivalent to bunzip2 Role of

4.7.3 zip

Function: compression instruction, which can compress multiple files or directories into a compressed file.
Syntax: zip -r  compressfilename.zip  file1 file2.... dir1 dir2....
characteristic: 
	- Keep source files
	- Custom compressed file name required
	- If you have a directory to compress, you must add it-r parameter
	
	Tips: zip For compatibility windows Compression tools provided
	
	zip and unzip All need to be installed

4.7.4 tar

Function: packaging instruction, which is used to pack multiple files into a package, that is, a package file
 Syntax: tar -[cxvf] tarfilename.tar  file............

Resolution:  -c  :Indicates packaging, i.e create
       -f  :Used to specify a new file name, which must be next to the new file name
       -x  :Unpack, not with-c coexistence
       -v  :Displays the compression process
       
       eg:  tar -cvf michael.tar file1 file2 dir1 dir2
            tar -xvf michael.tar     Unpacking
 
Tips: 
		- The file size after packaging is the sum before packaging.
		- So, if you want to compress the package file, tar Instructions are usually compressed(decompression )Instructions.
		
		Common combinations:   zcvf Medium z express gzip
		           jcvf Medium j express bzip2
		  Pack and compress: tar -[zcvf] arfilename.tar  file............
				    tar -[jcvf] arfilename.tar  file............
         Unzip and unpack: tar -[zxvf] arfilename.tar
         			tar -[jxvf] arfilename.tar

4.8 time instruction date

Function: view or set the time
reg: 
    date     View the current system time
    Displays the system time in a custom manner:	date +'%Y-%m-%d %H:%M:%S'   

	be careful:+There can be no spaces between and string,And date There should be a space between
	
	Set time
	eg: date  -s  "2015-5-8 19:48:00"
	
	Sync to bios,Restart before continuing to take effect
	eg: hwclock -w

4.9 system shutdown command

1. Restart command
   reboot
   init 6
2. Shutdown command:
	shutdown -h now   Shut down immediately
	shutdown -h 20:30 Timed shutdown
    poweroff
    half
    init 0

4.10 shortcut keys, basename and dirname of Linux

ctrl+c    Terminate foreground program
ctrl+z    Suspend the foreground program,    fg The instruction is used to schedule the suspended program to the foreground
ctrl+l    Clear screen, equivalent to clear

ctrl + a   Go back to the front of the command line
ctrl + e  Go back to the end of the command line
ctrl + w  Delete the word in front of the cursor
ctrl + k  Delete all words after the cursor

basename   /root/profile     Used to display the last name result in the entire path: profile
dirname   /etc/dir1/profile   Displays the entire path before the last name    result:/etc/dir1

(> - <, there are still a lot of things in the first day of big data learning. There are a lot of commands, but they are easy to understand. It takes a period of time to remember. In terms of application, it also needs to cooperate with various special symbols for flexible operation. It is still full of waiting ~ rush!!!)

Keywords: Linux Big Data CentOS

Added by programming.name on Mon, 29 Nov 2021 15:20:28 +0200