Right when the beginning--linux Learning Road (i)

Source: Internet
Author: User
Tags joins

Take the first blog to summarize the basic knowledge of Linux learned by previewing the third course, but put it in one piece, the estimated number of words will be too much, feel almost to re-open an article. Let's talk about it before summing it up. As a senior barrel of fake dog excrement, do not understand the basic Linux operation seems a bit unreasonable, after the development of the completion of the server can not operate independently of the update version of the naive. Most importantly, I also heard a somewhat iffy conclusion, that is to have a blog and insist on blogging fake dog excrement | | Siege Lion | | The program ape than no blog or can not insist on blogging salary level is much higher (hope in this is not not blog, but Weibo, DA). Well, the light is also torn, to go to the beginning ~

1. System Partitioning General rules:

/boot 200M

Swap actual memory twice times, but not more than 8G

/All remaining space

Of course, this is only the most basic of a zoning strategy, the actual application can be separated/data, dedicated to store a variety of data, or to the user's home directory separate partition to store user data, the specific situation according to the actual needs of the adjustment.

You can view the partitioning situation by using the following command:

[Email protected]~]# fdisk-l


2. Linked files--hard links and soft connections:

[[Email protected] ~]# ln link File Link file--hard link

[[email protected] ~]# ln-s link file--Soft link

Note: If the link file does not exist, it is automatically generated, if the link file exists, the link fails, the workaround is to use the-f parameter, forcing the link to overwrite the possible link file.

★ The difference between the two:

(1) The link file after the hard link is the same as the inode of the linked file, and the soft connection is different.

(2) After the hard link, the link file is a normal file (i.e. through stat, file, ll and other commands to view the linked file as regular files), and after the soft link, the link file for the symbolic link type, ll will also point to its linked files.

(3) After the hard link, delete the linked file, the link file is used as usual. After the soft connection, delete the linked file, the linked file cannot be used.

(4) Hard links can only be used to link ordinary files, link directory file times wrong:

ln: ' link/': Hard link isn't allowed for directory

Soft joins do not have this limitation and can be used to link directories. It is also important to note that after you have made a soft connection to the directory, you need to be aware of the deletion, such as:

[[email protected] learn]# ln-s./link/test//This can not be test/this directory form

[[email protected] learn]# RM-RF Test//This can not be test/this directory form

If the above test is written as test/this form will give an error. The reason is probably because the file type of the linked file test is symbolic link, not directory.

(5) Hard links cannot be linked across partitions, for example, to link files under the/boot partition to the/root partition, an error will be received:

ln:creating hard link '/test ' = '/boot/test ': Invalid cross-device link

Soft joins do not have this limitation and can be linked across partitions.

Note: A hard link can be simply understood as a CP, but the CP will be the value of the inode together with CP. Using this CP at the same time increases the number of nodes in the link file and the linked file (i.e. the second column value when viewed through the LL command).


3.Linux system tiering and RAID:

User

File system

Raid

Physical hard Disk 1 physical hard disk 2 ...


Among them, the raid is divided into the following types, the role is different;

RAID 0--Increased write speed

RAID 1--mirroring, for security

RAID 3-requires a minimum of three physical hard disks and is an over-version of RAID 5

RAID 5-Requires a minimum of three physical hard disks

After the raid, a few physical hard disks look like a hard disk

RAID 0 If you have two 100G of physical hard disk, then the RAID 0 can use space of 200G

RAID 1 If you have two 100G of physical hard disk, then the RAID 1 can use space of 100G (mirror)

RAID 5 If there are three 100G physical hard drives made, the RAID 5 can use space of 200G (a physical hard disk to take out for parity)

Note: The raid here is a physical raid, not a logical raid when the system is partitioned. Logical RAID is not recommended, physical raid is generally done by the hardware provider, this piece of knowledge to understand the line.


4.Linux system add hard disk and use hard disk:

When adding a new hard disk to a Linux virtual machine:

(1) Hard disk type Select IDE, the path in Linux is/dev/hda (HDB, HDC ... Ordered)

(2) HDD type Select SCSI, the path in Linux is/dev/sda (SDB, SDC ... Ordered)

Note: The experiment found that the CentOS 6.6, whether it is the IDE hard disk or SSCI hard disk, in Linux is/dev/sd* this form, rather than the video said the IDE is/dev/hd*, This may be because the SSCI and the IDE's naming differences have been canceled in CentOS6.6 or earlier versions. After adding a new hard disk to the virtual machine, SSCI in front of the IDE, such as two IDE hard disks at the beginning,/dev/sda and/dev/sdb, and then a SSCI hard drive, when three drives are/DEV/SDA (SSCI),/dev/sdb (IDE),/ DEV/SDC (IDE).

Using a newly added hard drive (also known as a bare device) takes three steps: Partition---format---mount

(1) Partition:

[Email protected] ~]# Fdisk/dev/sdb

Partition based on the information you are prompted to, N--new

P--Main partition for Linux

e--Extended partition 5 Extended

P + E number <= 4, number from 1-4

The extended partition can be re-partitioned, divided into L-and logical partition, the 5-more Linux, the logical partition number from the. After the partition is complete, in command, p to view the partition of the hard disk, q do not save exit, W save exit.

(2) Formatting:

[[email protected] ~]# MKFS.EXT4/DEV/SDB1//The/SDB1 partition under the/DEV/SDB hard drive is formatted as a EXT4 file system with a EXT1,EXT2,EXT3,EXT4 version of the file system, the higher the more stable version, The file systems that are commonly used are now EXT4.

(3) Mount:

[Email protected] ~]# Mkdir/data

[Email protected] ~]# Mount/dev/sdb1/data

You can complete the mount by

[Email protected] ~]# DF-HT

command to see the mount information and usage of the partition, at which point the/DEV/SDB1 partition is mounted in the/data directory. Note that the mount is only temporary and will fail after the system restarts. There are two ways to resolve this. The first type:

[Email protected] ~]# Vim/etc/fstab

Modify the file to add a new line:

/dev/sdb1/data EXT4 Defaults 0 0

Save to exit. The second type:

[[email protected] ~]# vim/etc/rc.d/rc.local//or vim/etc/rc.local, these two files for soft connection,/etc/rc.local for link file,/etc/rc.d/ Rc.local is a linked file. Add a new line:

Mount/dev/sdb1/data

Save to exit. To add, the/etc/rc.local file is the last file that is executed when the system starts, and you can write to the file to help you do everything you want to do after the system starts. Other than that

[Email protected] ~]# fdisk-l

[Email protected] ~]# df-th

Two commands can view the partition, where fdisk-l is primarily partitioned table information, while df-th focuses on the file system that has been formatted and mounted, including capacity size, usage, mount points, and file system types. (df-th does not see swap partition, the swap partition needs to use Fdisk-l, as follows:

Device Boot Start End Blocks ID System

/dev/sda2 287 2097152 Swap/solaris


5. powerful Find command:

Let 's take a look at the stat command before introducing the Find command:

[Email protected] ~]# Stat/tmp/learn/test.log

This command is used to view the details of a file (not specifically, the files in Linux refer to files in a broad sense, including both ordinary and directory files), including file types, inode values, permissions, owning user, Uid, owning user group, Gid, file size, Last access time Atime, last modified time mtime, finally change the time CTime and so on, these three time often with the find command to operate the file, then what is Atime,mtime and CTime, and what command will affect them?

Atime--Access Time VI vim cat head tail more less

Mtime--Modify Time Echo VI, VIM (save exit operation, even if nothing is modified)

CTime--Change time Echo VI, VIM (IBID.) chmod chown chgrp

Note here that when using echo for output redirection or appending content, there is no access to the file , So the atime does not change. Do you think that thels-l command to view the file details also has a time, where the time listed is mtime.

Having finished the stat command and three time, the Find command came in, not too much, to look at some examples first:

(1) Please find the file named Test.log in/directory:

[Email protected] ~]# Find/-name Test.log

(2) Please look for the file with inode number 261132 in the/tmp directory and delete it:

[Email protected] ~]# find/tmp-inum 261132-exec rm-rf {} \;

(3) Look for all files that were modified three days ago in the/root directory, and files with the file name test:

[Email protected] ~]# find/root-mtime +3-name test//or, more broadly

[[email protected] ~]# Find/root-mtime +3 | grep test

(4) Please look for files accessed within 10 minutes of the/var directory:

[Email protected] ~]# find/var-amin-10

(5) Look for files with file type block devices in the/dev directory:

[Email protected] ~]# find/dev-type b//f,d,b,s,c,p,l,d <--file type

The above examples are listed in the Find command to compare commonly used query conditions, such as file name, Inode value, atime,amin,ctime,cmin,mtime,mmin, file type, these conditions can be combined to use the results of the query operation using-EXEC, The format is-exec operation command {} \;.


The first one wrote a lot, but also only summed up a small part, the next time we continue to summarize, see you~~~

This article is from the "barrel of fake dog excrement" blog, please be sure to keep this source http://xitongjiagoushi.blog.51cto.com/9975742/1619923

Right when the beginning--linux Learning Road (i)

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.