A, Linux directory structure:
the CentOS system directory and file data is organized as a directory tree structure, all of the partitions, directories, files, and so has the same position as a starting point - the root of the file or directory Centos positioning system position, separated (different from the Windows system backslash "\") using the slash "/." The entire directory tree structure, the use of a separate "/" represents the root directory, the root directory is the starting point CentOS file system partition called it in the root partition. In the root directory, CentOS system will default to establish a special subdirectory, each with different purposes.
Second, common subdirectories and their role:
1./boot:. This directory is stored in the system kernel, file storage directory is also required when starting the system, such as vmlinuz and initrd.img when installing CentOS, to boot create a directory partition, it is beneficial for system backup.
2./bin:bin is binary acronym. This directory contains the frequently used commands and all users can perform, such as cp, ls and so on.
3./dev: This directory to save the file interface devices, such as / dev / hdal, / dev / cdrom and so on.
4./etc: This directory to save the file on the system setup and management.
5./home: general store all system users default working folder (ie home directory, home directory), such as user accounts "teacher" corresponding home directory located in "/ home / teacher /". If the server needs to be provided to a large number of ordinary users, we recommend the "home" directory is also divided into separate partitions to facilitate the backup user data.
6./root: The directory is the system administrator (superuser) root's home directory, by default only the root user's home directory in the root directory rather than in the "/ home" directory.
7./sbin: the most basic storage system management commands, users have administrator privileges to perform general.
8./usr: storage of other user applications, usually further divided into many sub-directory, used to store different types of applications.
9./var: store some file system needs to be changed frequently, such as system log files, directories and other user's mailbox, in the practical application of the system, "/ var" directory is also commonly divided into separate partitions.
Third, view the file contents:
1, CAT command - displays the contents of files and links.
CAT command could have been used to connect multiple file contents, but in actual use, more used to view the contents of the file. The cat command is the most widely used file content view commands. As shown here, a man named 666.TXT document, we use cat to see it, but you can not flip cat when viewing files.
2, more and less command - Paging view the file contents.
(1) more command
using the more command to view the contents of more than one screen of files, will be split-screen display, and shows the percentage of the current contents of the entire document in the bottom left corner.
As shown we can go split-screen look at the content of the site profile, but to the last page when they can not see the whole and can not look back.
(2) less command.
Paging less command is a command relatively late appearance of the display, providing more early more than the number of extensions, but her husband usage is basically the same. The difference is that with more order, more than one screen to view the contents of files, although split screen display, but does not show the percentage of the current contents of the entire document in the lower left corner, but the display is viewed the file name.
As shown we can go split-screen look at the content of the site profile.
(3) head- part of the beginning of the view files.
You can use "-n" option is specified (n is a specific number of lines) how many lines of content to be displayed, without specifying the number of rows, the default display only ten lines. Figure we execute "head -5 / etc / passwd" command, you can see part of the user account file / etc / passwd beginning of the first row to row 5.
Part of the end (4) tail- view the file.
Tail and head commands the opposite command for viewing the contents of the file at the end of the tail command is usually used to view the system log (because newer log records are always added to the end of the file), in order to observe network access, service commissioning and other related information. When with the "-f" option is used, you can also track the end of the file's contents dynamically updated, real-time changes to facilitate the monitoring of file contents. Figure we execute the "tail -5 / etc / passwd" command to view the user account file / etc / passwd line 5 to the end part of the end.
And we execute or "tail -f / etc / passwd" also can be viewed.
Fourth, statistics, and retrieve the file contents
. 1, wc command - statistics file contents of the number of words, lines, etc. Information
(1) -c: statistics content file byte as / etc / passwd file has 2154 bytes.
(2) -l: row counting content files, as shown in / etc / passwd file has 42 rows.
(3) -W: word counting the number of content files, as / etc / passwd file 42 words.
2, grep- searching, filtering file content.
(1) -i: ignore case when searching. As shown us perform "grep" ftp "/ etc / passwd" command, you can find the line that contains "ftp" string in the account file / etc / passwd in fact the output of information called ftp user account.
(2) -v: reverse lookup, and line output does not match the search criteria. As shown us perform "grep -v" ftp "/ etc / passwd" find lines that do not "ftp" string in the account file / etc / passwd in.
(3) setting the search conditions.
Fifth, compression and decompression tool
1, gzip and bzip2 command.
Use "-9" option can increase the compression ratio, but the files are large needs more time. Figure we use grizp command to compress "666.txt" file.
2, unzip command: gzip -d, bzip2 -d, gunzip , bunzip2.
Figure we use the gunzip command to decompress 666.txt.gz file.
Sixth, archiving and release tool -tar.
常用的选项如下:
-C:创建.tar格式的包文件。
-C:解压时指定释放的目标文件夹。
-f:表示使用归档文件。
-j:调用bzip2程序进行压缩或解压。
-p:打包时保留文件及目录的权限。
-P:打包时保留文件及目录的绝对路径。
-t:列表查看包内的文件。
-v:输出详细信息。
-x:解开.tar格式的包文件。
-z:调用gzip程序进行压缩或解压。
1、制作归档备份文件
如图我们执行“tar czvf 666.tar.gz 666.txt”命令将666.txt进行备份,在当前目录下生成名为666.tar.gz的归档压缩包。
2、从归档文件中恢复数据
如图我们执行“tar zxvf 666.tar.gz -C /opt/”命令将666.tar.gz的归档压缩包恢复到指定目录中。
七、vi文本编辑器.
1、工作模式:
(1)命令模式:启动ⅵ编辑器后默认进入命令模式。在该模式中主要完成如光标移动、字符串查找,以及删除、复制、粘贴文件内容等相关操作。
(2)输入模式:该模式中主要的操作就是录入文件内容,可以对文本文件正文进行修改或者添加新的内容。处于输入模式时,ⅵ编辑器的最后一行会出现“--INSERT---”的状态提示信息。
(3)末行模式:该模式中可以设置ⅵ编辑环境、保存文件、退出编辑器,以及对文件内容进行查找、替换等操作。处于末行模式时,ⅵ编辑器的最后一行会出现冒号“:”提示符。
2, the operating mode switch:
can switch between different modes of operation by different keys. For example, the command mode by a colon ":" key to enter the line mode, and if the press a, i, o, O and the like can enter the key input mode, the input mode, the last line mode can press Esc to return to the command mode . Several common mode switching key role in the machine follows.
① a: Insert after the current cursor position.
② A: Inserts cursor at the end of the line (the line).
③ i: Inserts before the current cursor position.
④ l: Insert at the beginning of the cursor line (first line).
⑤ o: the cursor is located in the back row to insert a new row.
⑥ O: the cursor is located in front of the line to insert a new row.
3, the basic operation command mode:
(1) Move the cursor
FIG we execute ": set nu" to display the line numbers.
(2) copy, paste, delete,
as shown in our implementation of "Ctrl + yy" to copy the current contents of the entire line, and then do "Ctrl + p" to paste the contents of the cursor.
(3) Find the file contents
as shown we execute ": / test" command to find the "test" string,
then we can look to see the results.
(4) the revocation edit and save and exit
4, the basic operation mode of the last line:
(1) Save the file and exit the vi editor,
as shown in our execution ": wq" command to save and exit vi.
(2) Open a new file or read other file contents
(3) replace the contents of the file
as shown in the full text of this we will be replaced there.