This is the sixth day of my participation in the More text Challenge. For details, see more text Challenge

1.vi/vim

1.1 what is

VI is the most common text editor for Unix and Unix-like operating systems.

The VIM editor is a more powerful text editor developed from VI. Can take the initiative to identify the correctness of the font color, convenient program design. VIM is fully compatible with the VI editor.

1.2 General Mode

Open a file in vi/vim and go straight to general mode (this is the default mode)

Common grammar

grammar

Functional description

yy

Copies the current line of the cursor

Digital y y

Copy a paragraph (from line to line)

p

Move the arrow to the destination line and paste

u

Undo previous step

dd

Deletes the current line of the cursor

D digital d

How many lines after the cursor is deleted

x

Cut a letter, equivalent to del

X

Cut a letter, equivalent to Backspace

yw

Copy a word

dw

Delete a word

^

Move to wardrobe

$

Move to the end of the line

1+shift+g

Move to the page header, number

shift+g

Move to the bottom

Digital + shift + g

Move to the target row

1.3 Edit Mode

Common grammar

The keys

function

i

Before the current cursor

a

Behind the current cursor

o

The line next to the current cursor line

I

The cursor is in the first line

A

At the end of the cursor line

O

The line above the current cursor line

1.4 Instruction Mode

Common grammar

The command

function

:w

save

:q

exit

:!

To enforce

/ Words to look up

N goes to the next, n goes up

:noh

Unhighlight

:set nu

According to the line Numbers

:set nonu

Shut down the line Numbers

:%s/old/new/g

Replace content /g Replace all matched content

2. Help command

2.1 man

The basic grammar

Man [command or configuration file] (Function description: get help information)

Show that

information

function

NAME

Name and one-line description of the command

SYNOPSIS

How to Use commands

DESCRIPTION

An in-depth discussion of command functions

EXAMPLES

How to use the command example

SEE ALSO

Related topics (usually man pages)

2.2 help

The basic grammar

Help command (to obtain help information about shell built-in commands)

2.3 type

The basic grammar

Type command (Function description: obtain the type of shell command)

[xxxx@hadoop1 ~]$type CD CD is embedded in the shell. [xxxx@hadoop1 ~]$type ls ls is the difference of 'ls --color=auto'Copy the code

3. File directory class

3.1 the PWD

The basic grammar

PWD (Display the absolute path of the current working directory)

[root@hadoop1 opt]# pwd
/opt
Copy the code

3.2 the ls

The basic grammar

Ls [options] [directory or file]

Option to show

options

function

-a

List all files, together with hidden files (files beginning with.)

-l

Long lists of data, including file attributes and permissions, etc. (often used) equivalent to “ll”

[root@hadoop1 ~]# ll total usage 8-rw-r --r-- 1 root root 2 11月 25 21:22 swappiness~ -rw-r--r-- 1 root root 2 11月 26 10:28 swappinesz~ [root@hadoop1 ~]# ls swappiness~ swappinesz~ [root@hadoop1 ~]# ls -a . .bash_logout .cshrc .mysql_history .ssh .tcshrc .. .bash_profile .history .oracle_jre_usage swappiness~ .viminfo .bash_history .bashrc .lesshst .pki swappinesz~ [root@hadoop1 ~]# ls-al total usage 68 dr-xr-x--.5 root root 4096 4月 7 18:28.dr-xr-x. 20 root root 4096 4月 6 16:03.. -rw-r--r-- 1 root root 6775 4月 6 19:16. Bash_history -rw-r--r-- 1 root root 18 12月 29 2013 Root root 176 dec.29 2013. Bash_profile-rw-r --r--. 1 root root 176 Dec.29 2013. Bashrc-rw-r --r--Copy the code

3.3 CD

The basic grammar

CD [parameter]

Parameters that

parameter

function

CD Absolute path

Switching path

CD Relative path

Switching path

CD ~ or CD

Go back to your home directory

cd –

Go back to the last directory

cd ..

Returns to a directory one level above the current directory

cd -P

Jump to the actual physical path, not the shortcut path

[root@hadoop1 opt]# cd /root/ [root@hadoop1 ~]# cd - /opt [root@hadoop1 opt]# cd .. / [root@hadoop1 /]# cd /root/ [root@hadoop1 ~]# cd ~ [root@hadoop1 ~]# cd .. / [root@hadoop1 /]# cdCopy the code

3.4 the mkdir

The basic grammar

Mkdir [Option] The directory to create

Option to show

options

function

-p

Create multiple levels of directories

[xxxxx@hadoop1 test]$ mkdir qqq
[xxxxx@hadoop1 test]$ mkdir -p qqq/www/eeee
Copy the code

3.5 rmdir

The basic grammar

Rmdir Empty directory to delete

[root@hadoop1 www]$ rmdir eeee
Copy the code

3.6 touch

The basic grammar

Touch file name

[root@hadoop1 qqq]$ touch 1.txt
[root@hadoop1 qqq]$ touch ./www/1.txt
Copy the code

3.7 the cp

The basic grammar

Cp [option] source dest

Option to show

options

function

-r

Recursively copy the entire folder

[root@hadoop1 test]# cp a.txt ./aaa
[root@hadoop1 test]# cp -r aaa aaaa
Copy the code

3.8 the rm

The basic grammar

Rm [option] deleteFile (recursively delete all contents in a directory)

Option to show

options

function

-r

Delete all contents of the directory recursively

-f

Force a delete without prompting for confirmation.

-v

Displays the detailed execution of the instruction

[root@hadoop1 test]# rm a.txt rm: Delete the common file "a.txt"? yes [root@hadoop1 test]# rm -f b.txt [root@hadoop1 test]# rm -rf aaaa/Copy the code

3.9 mv

The basic grammar

Mv oldFile newFile

Mv. /aaa/ BBB/(Function description: move folder)

Mv a.txt aaa/a.txt

[root@hadoop1 aaa]# mv a.txt b.txt [root@hadoop1 aaa]# mv ./b/ .. / [root@hadoop1 aaa]# mv b.txt .. /Copy the code

3.10 the cat

The basic grammar

Cat [option] The file to view

Option to show

options

Functional description

-n

Displays line numbers for all lines, including blank lines.

[root@hadoop1 test]# cat README.txt 
For the latust information about Hadoop, please visit our website at:
 
http://hadoop.apache.org/core/   
[root@hadoop1 test]# cat -n README.txt 
 1	For the latust information about Hadoop, please visit our website at:
 2	
 3	http://hadoop.apache.org/core/
Copy the code

3.11 more

The basic grammar

More File to view

Instructions for

operation

Functional specifications

Blank key (space)

Is for turning down a page;

Enter

Represents down “line”;

q

Leave the more file immediately and the file content is no longer displayed.

Ctrl+F

Scroll down a little bit

Ctrl+B

Return to the previous screen

=

Prints the line number of the current line

:f

Output file name and the line number of the current line

[root@hadoop1 test]# more README.txt
Copy the code

3.12 less

The basic grammar

Less Indicates the file to be viewed

Instructions for

operation

Functional specifications

A blank key

Turn down a page;

[pagedown]

Turn down a page

[pageup]

Turn up a page;

/ string

The ability to search down “strings”; N: Search down. N: Upward search.

? string

The ability to search upwards for “strings”; N: Upward search. N: Search down.

q

Leave less this program;

[root@hadoop1 test]# less README.txt
Copy the code

3.13 the echo

The basic grammar

Echo [options] [Output]

Options:

-e: supports character conversion controlled by backslash

Control characters

role

\ \

Output \ itself

\n

A newline

\t

Tab, Tab key

[root@hadoop1 test]# echo 666 666 [root@hadoop1 test]# echo "4444" 4444 [root@hadoop1 test]# echo -e "666\t666" 666 666 [root@hadoop1 test]# echo -e "\033[34m blue words \033[0m" blue wordsCopy the code

Extension with color output:

Echo -e “\033[word background color; word color m string \033[0m” adds both word background color and word color

Echo -e “\033[text color m string \033[0m” only adds text color

The font color

Echo -e "\033[30m black words \033[0m" echo -e "\033[31m red words \033[0m" echo -e "\033[32m green words \033[0m" echo -e "\033[33m yellow words \ [0 m "echo - e" 033\033 \ [34 m blue word 033 [0 m "echo - e" 033\033 \ [35 m purple word [0 m "echo - e" 033\033 \ [36 m sky blue word [0 m "echo - e" 033 \ [37 m White word \ [0 033 m"Copy the code

Background color

Echo -e "\033[40;37m black background white words \033[0m" echo -e "\033[41;37m red background white words \033[0m" echo -e "\033[42;37m green background white words \033[0m" echo -e "\033[0m] echo -e "\033[43;37m yellow background white words \033[0m" echo-e "\033[44;37m blue background white words \033[0m" echo-e "\033[45;37m purple background white words \033[0m" echo-e "\033[46;37m \033[0m" echo-e "\033[47;30m \033[0m"Copy the code

At the end of the control options description

\33[0m turn off all properties \33[1m set high brightness \33[4m underline \33[5m blink \33[7m backdisplay \33[8m Fade \33[30m - \33[37m set foreground color \33[40m - \33[47m set background color \33[nA cursor up n lines \33[nB cursor down n lines \33[nC cursor right n lines \33[nD cursor left n lines \33[y;xH Set cursor position \33[2J clear screen \33[K Clear from the cursor to the end of the line \33[s Save cursor position \33[u Restore cursor position \33[?25l hide cursor \33[?25h display cursorCopy the code

 

3.14 the head

The basic grammar

Head file (View the first 10 lines of the file)

Head -n 5 file (Function description: View the first five lines of the file. 5 can be any number of lines)

2) Option description

options

function

Line – n < number >

Specifies the number of lines to display header content

[root@hadoop1 test]# head README.txt 
For the latust information about Hadoop, please visit our website at:
   http://hadoop.apache.org/core/
   http://wiki.apache.org/hadoop/
and our wiki, at:
ribution  
[root@hadoop1 test]# head -n 1 README.txt 
For the latust information about Hadoop, please visit our website at:
Copy the code

3.15 tail

The basic grammar

(1) Tail file (Function description: view the 10 lines at the end of the file)

(2) tail -n 5 file (5 can be any number of lines)

(3) Tail -f file (function description: real-time tracking of all updates to the document)

(4) tail -5f file or tail -fn 5 file (function description: view 5 lines at the end of the file, 5 can be any number of lines and track all updates of the document in real time)

2) Option description

options

function

Line – n < number >

Output n lines at the end of the file

-f

Displays the latest content added to files and monitors file changes

[root@hadoop1 test]# tail README.txt 
The following providus more details on the included cryptographic
software:
  Hadoop usus usus the SSL librarius from the Jetty project written 
by mortbay.org.
[root@hadoop1 test]# tail -n 1 README.txt 
by mortbay.org.
[root@hadoop1 test]# tail -fn 2 README.txt 
  Hadoop usus usus the SSL librarius from the Jetty project written 
by mortbay.org.
^C
[root@hadoop1 test]# tail -2f README.txt 
  Hadoop usus usus the SSL librarius from the Jetty project written 
by mortbay.org.
^C
Copy the code

3.16 > and > >

The basic grammar

(1) ls -L > file (Function description: The contents of the list are written to the file A.tb (overwrite))

(2) lS-al >> file (Function description: Append the contents of the list to the end of the file aa.txt)

(3) file 1 > file 2 (function description: overwrite the contents of file 1 to file 2)

(4) Echo Content >> File

[root@hadoop1 test]# ls -l > b.txt 
[root@hadoop1 test]# ls -l >> b.txt 
[root@hadoop1 test]# cat README.txt >> b.txt 
[root@hadoop1 test]# echo "66666" >> b.txt
Copy the code

3.17 ln

The basic grammar

Ln -s [Original file or directory] [Soft link name] (Function description: Create a soft link for the original file)

experience

Delete a soft link: rm -rf soft link name, not RM -rf soft link name /

If you run the rm -rf soft link name/delete command, the content in the real directory corresponding to the soft link is deleted

Query: you can query by ll. The first bit of the list property is L, and there will be a position pointing to the end.

[root@hadoop1 test]# rm -rf a.t XTLN [root@hadoop1 test]# ln -s aaa aaa. Ln [root@hadoop1 test]# ll total dosage 36 drwxrw-rw-2 Root root 4096 Apr 8 09:32 aaa LRWXRWXRWX 1 root root 3 Apr 8 10:13 aaa.ln -> aaaCopy the code

3.18 the history

The basic grammar

History (View history commands that have been executed)

[root@hadoop1 test]# history
    1  2020-11-21 14:20:05 root hostname
Copy the code