Basic Linux Essentials

Source: Internet
Author: User
Tags file copy

################## two file addressing ###########

Absolute path: file in the real location of the system , the file name begins with "/"

relative path: The name of the file relative to the current location of the shorthand , which does not start with/, and the name will automatically add the PWD display value

################ Three file Management #############

# # # # #1 Touch to create a file or modify a file timestamp

Touch file ######## #创建文件

# # # # # #2 mkdir build Directory

mkdir directory ##### #创建目录

-P ##### #上级目录不存在自动建立

# # # # # #3 RM Delete directory or file

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

Rm-r ##### #删除目录

RM-RF|-FR * # # # # #全部删除不提示

# # # # # # #4 vim text Edit file

Vim filename # # # #进入命令模式

Command mode cannot edit file , to edit into insert mode

I # # #进入插入模式

finish editing to exit

ESC # # #退出插入模式; WQ FileName # # #保存退出

Vim filename If the file name does not exist, it will be created automatically

# # # # #5 CD Switch working directory

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

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

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

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

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

# # # # #6 LS lists directory or file information

LS # #如果后面没有目标那么默认目标为当前目录

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

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

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

Ls-ld Directory # #列出目录本身属性

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

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

# # # #7 CP file copy

CP file File1 file2. Directory # # #把file file1 file2 copied to directory

CP File Test # # # #建立test文件模板为file

Cp-r Directory Direcotry1 # # #复制目录

# # # # #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 direcotry # #移动file file1 to Directory

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

MV Westos/linux. # #把westos中的linux移动到当前目录. Represents the current directory

# # # # # # #9 Gedit # #图文方式编辑

gedit filename

############### four Regular expression ############

* # # #匹配0到任意字符

? # # #匹配单个字符

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

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

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

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

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

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

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

{} indicates a nonexistent or existing

{1..9} # # #1-9

{A.. F} # # #a-F

{1,3,5} # # #135

{a,c,e} # # #a c E

{1..3} {A.. C} # # #1a 2a 3a 2a 2b 2c 3a 3b 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 # # #指定的用户家目录

~+ # # #当前目录

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

. # # #当前目录

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

###### Unit 3 #######

############# Mans #####################

Man->>manual ########## #man是手册的缩写

Man Man ######### #查看man命令的帮助

Man passwd ######### #查看passwd命令的帮助

The level of man

1 system commands

2 System interface

3 Function libraries

4 special files, such as devices

5 files

6 games

7 Package for the system

8 System Administration Commands

9 cores

Help for man 5 passwd ######### #查看/etc/passwd file

Man 1 passwd ######### #查看passwd命令的帮助, 1 can omit u

A shortcut to the man page

Up and down keys ######## #向上或向下一行

Pageup|pagedown ######## #向下一个屏幕或者向上一个屏幕

D|u ######## #向下或者向上半个屏幕

G|gg ######### #跳转页面到man最下面或最上面

/keyword ######### #搜索关键字, keywords are highlighted, n is matched, n up

Q ######### #退出帮助页面

########## Unit 4 #########

############### Management input/Output ############

in a Linux system, the correct output number is 1, the error output number is 2

performed in the system with a normal user "Student"

Find/etc-name passwd

because the student user rights issue will have the following output

Find: '/etc/pki/ca/private ': Permission denied # # # #没有进入权力, error

Find: '/etc/pki/rsyslog ': Permission denied

Find: '/etc/audit ': Permission denied

/ETC/PASSWD # # #正确输出

Find/etc-name passwd > File # # # # #重定向正确输出

Find/etc-name passwd 2> File # # # # # #重定向错误输出

Find/etc-name passwd &> File # # # # #重定向所有输出

Note : 2>,&> # #清空file

>file

Will overwrite the source file contents

Find/etc-name passwd >> File # # # # #追加正确输出

Find/etc-name passwd 2>> File # # # # # #追加错误输出

Find/etc-name passwd &>> File # # # # #追加所有输出

Note :>> 2>> &>> does not overwrite the contents of the source file, it will characters the corresponding output word to the end of the file.

| The function of a pipe is to change the output of the previous command into the input of the post-pipeline command.

Ls/bin | Wc-l # #统计ls The number of lines that the/bin command outputs

The wrong output in the system is not available through the pipe

use 2>&1 to change the wrong output number from 2 to 1.

Tee copy output to specified location

Date |tee file |wc-l # # #tee命令复制date命令的输出到file中, and count the number of output rows


This article from the "12106768" blog, reproduced please contact the author!

Basic Linux Essentials

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.