Linux Learning Basics---The first part

Source: Internet
Author: User
Tags file copy

1. What is Linux?

Linux is a free-to-use and free-to-propagate Unix-like operating system that is a POSIX and Unix-based multiuser, multitasking, multi-threaded and multi-CPU operating system. It can run major UNIX working software, applications and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the design idea of Unix as the core of network, and is a stable multi-user network operating system.

2. What is a shell?

In computer science, the shell is commonly known as a shell (used to differentiate itself from the kernel) and refers to the "user Interface" software (command parser). It is similar to Dos commang.com and later cmd.exe. It receives the user command and then invokes the appropriate application.
Chinese name: Shell
Foreign name: Shell
Nature: Command Parser
Purpose: Accept user commands

Terms
It is also a programming language. As a command language, it interactively interprets and executes user-entered commands or automatically interprets and executes a series of pre-designed commands, and as a programming language, it defines variables and parameters and provides many control structures in high-level languages, including loops and branches.

3.Linux runs at the row prompt
[[Email protected] desktop]$ (line prompt)
Meaning:
Kiosk: User
@: Delimiter
Foundaton0: Host short name
Desktop: The location of your system
$: User identity, $ for ordinary users (grass people), #为超级用户 (the Son of Heaven).

4. Virtual Machine Management Commands:
Rht-vmctl Start Desktop/server Open
Rht-vmctl Poweroff Desktop/server off
Rht-vmctl View Desktop/server Display
Rht-vmctl Reset Desktop/server Reset

开启后,进行显示

Virtual Machine Login:

1. Normal User Login

Click Student user can, and then do password password input;

2. For ease of operation, change it to super user

(1) Click Not listed?

(2) Enter root in username (super user)

![](http://i2.51cto.com/images/blog/201808/02/7090ec5038e1d2ab764d004a92e5251d.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)(3)登陆password,输入内容分为页面正下方图标后Redhat

To enter the virtual machine

5.LINUX System Structure

(1) Linux system is a inverted tree system;

(2) The role of level two directories:

 /bin                   #二进制文件,系统的常规命令(如data...) /boot                 #系统启动分区,系统启动时读取的文件 /dev                  #设备文件 /etc                   #大多数配置文件 /home              #普通用户的家目录 /lib                    #32位函数库 /lib64               #64位函数库 /media             #手动临时挂载点  (linux为用户准备了两个手动临时挂载点) /mnt                 #手动临时挂载点 /opt                      #第三方软件安装位置

/proc #进程信息及硬件信息
/root #超级用户家目录
/run #临时设备的默认挂载点 (for example, if you do not manually arrange mount points, run/media/sdb1 in this directory)
/sbin #系统管理命令
/srv #数据
/var #数据
/sys #内核相关信息
/tmp #临时文件
/usr #用户相关设定

File management under 6.Linux

(1) Document creation

  touch file                        #建立空文件,或修改文件的时间戳    ![](http://i2.51cto.com/images/blog/201808/02/9ec03df29cfa06de4c69a61d3e5695ca.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)  touch file1 file2    ![](http://i2.51cto.com/images/blog/201808/02/0344a36fd07e2302086ffb369466eb1f.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

(2) Create a directory

  mkdir                          #建立单目录![](http://i2.51cto.com/images/blog/201808/02/cfdfeb6e9753a5d0b15e83f49f9151e2.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)        mkdir -p                     #建立多层目录![](http://i2.51cto.com/images/blog/201808/02/14617492428a1db14e84be2820111bd9.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

(3) Deletion of files

  rm -f file(file为删除的文件名)强行删除文件file        (如果不加-f会提示是否删除)        注释:

-f-r-r-f-rf-fr function is the same as delete this directory and internal content and do not prompt
-F: Prompt-r: Recursive

    ![](http://i2.51cto.com/images/blog/201808/02/a1c3caa2e95420022c7e55a8efadc9af.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)        rm -fr dir (dir为删除的目录名)强行删除目录本身及里面内容    ![](http://i2.51cto.com/images/blog/201808/02/0d5a0cee1bcd8ad67704f7252b651559.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

(4) Editing of documents

  Vim file is browse mode and cannot be edited after it is entered. [] (http://i2.51cto.com/images/blog/201808/02/e8d2995a409e5799b658f36247f71040.png?x-oss-process=image/  watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) Input <i> Enter the insert mode characters (at this point the lower left shows insert,<i> is the key I lowercase, below <esc> same)![] (Http://i2.51cto.com/images/blog/201808/02/7b9e923fca109d73fd2d7073016fbc51.png?x-oss-process=image/watermark, size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) Press < when finished writing Esc> Exit Insert mode! [] (http://i2.51cto.com/images/blog/201808/02/12b1af6266115ccde32f851300d12027.png?x-oss-process=image/  watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) Input: Wq complete file editing. W means write, q exits! [] (http://i2.51cto.com/images/blog/201808/02/2c7b59d7255a447692bbfd71a6e1ef54.png?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) Click on file to view! [] (http://i2.51cto.com/images/blog/201808/02/99ee596287aecd04e0dc67e1e381074b.png?x-oss-process=image/ watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=)

Tips for using 7.Vim

在浏览模式

(1) Large character management
YY #复制一整行
YL #复制一个字母
YW #复制一个单词
P #粘贴

DD #删除一整行
DL #删除一个字母
DW #删除一个单词

CC #剪掉整行
CL #剪掉一个字母
CW #剪掉一个单词
Attention:
When the cutter is cut, vim goes into insert mode,
If you want to paste you need to press <esc> exit Insert mode and then paste

 ![](http://i2.51cto.com/images/blog/201808/02/01a9f94944d6f17cab20a432f9c366b2.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ![](http://i2.51cto.com/images/blog/201808/02/e79cfa693b0dd052ddb23005355e051e.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ![](http://i2.51cto.com/images/blog/201808/02/0f0f359c6036aebcc6b6adee84129d06.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

U # #撤销
Ctrl+r # #恢复

(2) batch processing of characters
Ctrl + V # #进入可视化模式, you can select characters in bulk and manipulate them in visual mode

How to bulk Add characters
1) Move the cursor to the column where you want to add the character

2) Ctrl + V into visual mode

3) Select the column you want to add characters to (use the arrow keys to select the gray)

4) Press <I> to enter insert mode and write the characters to be added,<i> here i is uppercase I

5) Press <ESC> batch add end

6) How to batch Modify
:%s/original character/modified character/g

: 1,5s/original character/modified character/g (1,5) represents one to five elements change

Here s represents the row, G represents the column, if no g, then the changed information only the first occurrence of each row of the column changes;

(3) How to edit multiple files at the same time
Vim file
: SP file1

Attention:
The cursor is the file that is operated by default in that file.
Ctrl+w Press to move the cursor in the window

![](http://i2.51cto.com/images/blog/201808/02/44b20c478186a2fd521f5b507d8511e2.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)

(4) Normal Exit method

     Normal Exit Method: Q # #当文件没有做任何修改是可用: q! # #当文件修改但不行保存修改时可用! [] (http://i2.51cto.com/images/blog/201808/02/63ca3e9e8fa0058d7fd1c29d4e009520.png?x-oss-process=image/        watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) Open the modified file! [] (http://i2.51cto.com/images/blog/201808/02/e800358ecb7244bd4fe681377b0a32a2.png?x-oss-process=image/  watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) : Wq # #退出保存! [] (http://i2.51cto.com/images/blog/201808/02/2c65bbb80acc890247084a0d8adb7112.png?x-oss-process=image/        watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=) Open the modified file! [] (http://i2.51cto.com/images/blog/201808/02/af32d39049eb8099735c26be8219f75d.png?x-oss-process=image/  watermark,size_16,text_qduxq1rp5y2a5a6i,color_ffffff,t_100,g_se,x_10,y_10,shadow_90,type_zmfuz3pozw5nagvpdgk=)  : wq! # #当文件be available for yourself or when the user is root (6) Abnormal exit when there is no normal exit, but the direct click on the upper corner of the fork, there will be an abnormal exit when Vim is not properly exited will produce. filename.swap file when this file appears, VIM works abnormally 

Found a swap file by the name ". File.swp" <<< exception exits unsaved data
Owned By:root dated:wed 1 02:59:25 2018
Me: ~root/desktop/file
Modified:yes
User Name:root host Name:localhost
Process id:2046
H swap file by the name ". File.swp"
Owned By:root dated:wed 1 02:59:25 2018
Ile opening file "file"

Swap file ". File.swp" Already exists!
[O]pen read-only, (E) dit anyway, (R) Ecover, (D) elete it, (Q) uit, (A) Bort:

Workaround: Select an option to
[O]pen read-only, (E) dit anyway, (R) Ecover, (D) elete it, (Q) uit, (A) Bort:

[O]pen read-only read-only Open
(E) dit anyway discard unsaved data into the file
(R) Ecover recovery
(D) elete it delete. swp files
(Q) uit (A) bort exit

8. File View
Cat File # #输出文件的所有内容

Cat-b File # #输出文件所有内容并加入行号, just add the serial number in the Display page, will not modify the original

Cat-b file > File1 # #把file文件中的数据添加行号并复制给file1新文件

Less file # #分页浏览file文件

< up >|< down > # #向上 | Move one line down
<pgup>|<pgdn> # #向上 | Move down one page

Input/keyword # #高亮显示关键字, n matches n up

Q # #退出

Tail File # #显示文件file的后十行 (default)
Tail-n File # #显示文件file的后n行

Head File # #显示文件file的前十行 (default)
Head-n File # #显示文件file的前n行

9. File copy
CP sourcefile DestFile # #把原文件复制一份命名为目标文件

At this point the desktop

CP sourcefile1 Sourcefile2 destdir/# #复制多个文件到目录中
First mkdir Create a directory!!!!

Cp-r SourceDir destdir/# #复制原目录及内部的文件到目标目录 (used here with-R, if not added, only empty directories can be copied)

10. Movement of files
Comments:
If you move the file to the current directory file1, rename
MV SourceFile DestFile # #重名命

The contents of file!

File1 's content!

Output y after move indicates yes

The last file1 content

MV SourceFile Destdir # #移动原文件到destdir目录
!! Create a directory with mkdir first

MV SourceDir Destdir # #移动原目录到destdir目录

MV test/ . # #将当前test目录下的所有文件移动到当面目录下 (current directory is desktop) "." Represents the current directory, representing all;

11. File path
(1) Relative path
A name for the file relative to the current system location shorthand
The file name omits the value of the current path #例: Desktop/hello/file
Available only when you are currently in this directory
File name does not start with/
The file name is automatically added to the path #在shell中输入pwd会显示当前所在目录的绝对 the ' pwd ' display in the word match either

(2) Absolute path
is the real location of the file in the system
The name of a file can be accurately represented at any time #例:/root/desktop
File name starts with/

12. Commands on the path
PWD # #显示当前工作目录

CD # #切换当前工作家目录

CD/MNT # #切换到 The/mnt directory

CD-# #进入当前目录之前所在目录中

CD ~student # #进入到student用户家目录

Linux Learning Basics---The first part

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.