Basic Linux Learning (II.)

Source: Internet
Author: User

Through the previous study, we initially understand some of the basic Linux commands, this one, we will be more in-depth to understand the Linux system structure, file management and other knowledge.

1.LINUX System Structure

Linux is an inverted tree structure, and everything in Linux is a file. These files are both under the system top-level directory "/" and/or the root directory. /directory Below is a level two directory, the level two directory is installed when the system is automatically built.

We usually use the computer, most people often do not know the system disk under the strange names of the directories are used to do what, the attitude of awe, never dared to move. Let's take a look at what these "strange directories" are for.

The role of the secondary directory:

/bin # #二进制可执行文件也就是系统命令

/sbin # #系统管理命令存放位置

/Boot # #启动分区, responsible for system startup

/Dev # #设备管理文件

/etc # #大多数系统管理文件

/Home # #普通用户的家目录

/lib # #32位系统库文件存放位置

/LIB64 # #64位系统库文件存放位置

/media # #系统临时设备挂载点

/MNT # #系统临时设备挂载点

/run # #系统临时设备挂载点

/OPT # #第三方软件安装位置

/proc # #系统信息

/root # #超级用户家目录

/srv,/var # #系统数据

/sys # #系统管理, mostly about the kernel

/tmp # #系统临时文件存放位置

/usr # #系统用户相关信息数据及用户自定义软件存放位置


2. Addressing and management of documents

To understand file addressing and management, it is important to understand the absolute path and relative path

Absolute path: The file is in the real location of the system and the filename starts with/

Relative path: The name of the file relative to the current location is abbreviated, the name does not start with a/, and the name automatically adds the value of the PWD display

Management of files:

(1) Touch Create file or modify file timestamp

Touch File # #创建文件

(2) mkdir set up a directory (popularly speaking is to create a folder)

mkdir Directory # #创建目录

Mkdir-p Directory # #上级目录不存在时自动建立

(3) RM Delete directory or file

Rm-f # #强行删除不提示

Rm-r # #删除目录

(4) Vim text mode edit file

Vim file enters command mode

Command mode cannot be edited, press "I" or "a" to enter edit mode

When the edit is complete, press ESC to exit edit mode, and then enter ": Wq" to save the exit

(5) CD switch working directory

CD Directory # #切换工作目录到指定目录

CD-# #切换工作目录到之前所在目录

CD ~ # #切换到自己的家目录

CD ~username # #切换到指定用户家目录

Cd.. # #进入到当前目录的上级目录

(6) LS lists directory or file information

LS # #后面没有目标则默认目标为当前目录

LS Directory|filename # #列出目录或文件的内容

ls-d Directory # #列出目录本身

Ls-l Filename|directory # #列出文件或目录里面内容的属性

LS-LD # #列出目录本身属性

Ls-a # #显示目录中所有内容, including with "." Hidden files at the beginning

Ls-r # #递归显示目录中的内容

(7) Copy of CP file

CP file1 file2 file3 ... directory # #把file1 file2 file3 copied into directory

CP File Test # #把file里的文字复制到test中

Cp-r Directory Directory1 # #复制目录directory到directory1中

(8) MV Move or rename

The MV of the same disk is renamed, and the MV of different disks is the copy-delete process

MV File file1 Directory # #移动file file1 into Directory

MV exists file does not exist file # #重命名文件

MV Directory/file.                                                       # #把directory中的file移动到当前目录 (. Represents the current directory)

3. Regular expressions

Sometimes we need to match a file with a series of identical characteristics, and if it is done again and again it is too inefficient, then we need to use regular expressions. Next we list some of the most common regular expressions

* # #匹配0到任意字符

? # #匹配单个字符

[[: Alpha:]] # #匹配单个字母

[[: Lower:] # #匹配单个小写字母

[[: Upper:] # #匹配单个大写字母

[[:d Igit:] # #匹配单个数字

[[: Alnum:] # #匹配单个数字或字母

[[:p UNCT:] # #匹配单个符号

[: Space:] # #匹配单个空格

{1..9} # #1-9

{A.. Z} # #a-Z

{1,3,5} # #1 3 5

{a,c,d,} # #a C D

{1..3} {A.. C} # #1a 2a 3a 1b 2b 3b 1c 2c 3c

[] Indicates the existence of the

[A-c] # #aA BB CC

[A-c] # #aA或者bB或者c

[1-3] # #1或者2或者3

[145] # #1或者4或者5

[^abc]| [!ABC] # #除了a并且除了b并且除了c

~ # #当前用户家目录

~username # #指定的用户家目录

~+ # #当前目录

~-# #当前目录之前所在目录

. # #当前目录

.. # #当前目录的上一级



Basic Linux Learning (II.)

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.