Fifth day record

Source: Internet
Author: User

2016-07-29

Content of the lesson:

File Management

Index node

Hard links and soft links

Redirects and pipelines

User Management


Index node

A node (an index node) is a table item that contains information about the file (metadata), including:

File type, permissions, Uid,gid

Number of links (pointing to the number of path names for this file name)

The size of the file and the different timestamps

Data block pointer to file on disk

Additional data about the file

Inode table

Ls-i

Cp-f: Equivalent to deleting the original file and re-establishing the file, the metadata changes

The inode number is unique within a separate partition, and the file inode number of different partitions may be the same

Hard Links:

ln File File


Number of links = number of file names

Only one copy of the space size of multiple linked files

Hard links cannot be created across partitions

Directory cannot create hard links

Delete the file just delete the file name (inode), the content is not immediately deleted, just mark the block space free to store other content (that is, deleted the file theoretically can also be restored)


Soft Link: (shortcut, and original file different inode, original file deleted, soft link will expire)

Ln-s the absolute or relative path (relative to the soft connection) path path of the original file

Soft links can be created across partitions

A soft link is also a file, the file size is the file name of the guide size

The directory can be

The Inode space has been allocated at the outset and cannot be expanded, and an inode table consumes 1% of the file system disk space.


Standard input and output

Linux provides three I/O devices to Programs

Standard input (STDIN)-0 accepts input from the keyboard by default

Standard output (STDOUT)-1 Default output to terminal window

Standard error (STDERR)-2 default output to terminal window

Redirection is changing the default input and output

>>: Append content

: Overwrite Content

2>: Error output redirection

2>>: Error Output append redirect

&>: Standard output and standard error output, traditional notation:> file 2>&1

(): Merge standard output from multiple programs

(com;com) >/: Multiple command redirection

(date;cal) > A.txt


Standard input commands: Cat, TR

TR "' </etc/issue > F1

Tr

-d ': Delete ' bytes after output

-C: Take complement set

-S: Repeat with one output

TR does not change the original file content, only changes the way the output is displayed


Pipe can only accept standard output (success), cannot accept error output, can implement error output with 2>&1 or |&

2>&1


Set: Valid only in the current shell

-C: Prohibit redirection overrides

+c: Recovery

User Management

admin: Root, 0

Normal Users: 1-65535

System User: 1-499 (CENTOS6), 1-999

Assigning permissions to a daemon to get resources

Login User: (CENTOS6) +, 1000+

Interactive Login

Administrators group: root, 0

Normal Group:

System groups: 1-499, 1-999

General Group: 1000+,

ID User: View user information for users

Profiles for users and groups

/etc/passwd

Root:x:0:0:nihaoma,,2222:/root:/bin/bash

User name: Password: uid:gid: Comments: Home directory: Default Shell

/etc/group

Fedora:x:4007:mandriva

Group name: Password: GID: Users in the group

/etc/shadow

Bin:*:16659:0:99999:7:::

User name: password (generally encrypted with sha512): Password change Date: How many days can be changed: password expiration:: The number of days the password needs to be changed: How many days the password expires: Password expiration Date: retention

/etc/gshadow

Root::

Group name: group password (default is empty): Team list: List of users with this group as additional groups


The first two are to save the user's account and group information, the last two is to save the account and group password information

CHFN: Modifying annotation information

-p:phonenum

-f:fullname

-h:homenum

Finger User: View description information for users

Getent passwd User: View user's passwd information

Getent Shadow User: View user's Shadow information


vipw=vi/etc/passwd

Vifr=vi/etc/gshadow

Pwck

Grpck

Shadow's password location is there! Means no landing.

Usermod

-U: Unlock, reduce one!

-L: Lock


/etc/skel: User Configuration template, each new user, the mate files from here Copy the past

Cat/etc/default/useradd: Default new User's parameter profile

# useradd defaults file

group=100

Home=/home

Inactive=-1

Expire=

Shell=/bin/bash

Skel=/etc/skel

Create_mail_spool=yes



Homework:

1, Daily lessons Summary notes

2, soft and hard link differences

Essential difference: A hard link is a file, a soft link is multiple files

1, the directory does not have a hard link, can have a soft connection

2, hard links can only be created in the sub-region, soft connections across partitions

3, the deletion of hard links does not affect the other linked files, soft links to the original file once deleted, the soft link will expire

3. Preview

4. PDF exercise

5. The contents of the File1 file are: "1 2 3 4 5 6 7 8 9 10" Calculates the sum of all numbers

[[email protected] ~]# echo "1 2 3 4 5 6 7 8 9" > File1 | Cat file1 |tr ' + ' |BC

55

6, processing string "Xt.,l 1 jr#! $mn 2 c*/fe3 uz4", keep only the numbers and spaces

[Email protected] ~]# echo "Xt.,l 1 jr#bcmn2 c*/fe3 uz4" | Tr-d-C ' [: alnum:]\n '

Xtl1jrbcmn2cfe3uz4

7. Display the path variable in a separate row for each directory

[Email protected] ~]# echo $PATH |tr ': ' \ n '

/usr/local/sbin

/usr/local/bin

/usr/sbin

/usr/bin

/root/bin

8. Delete blank lines of the specified file

[[email protected] ~]# cat 11111

Adsadsa



Dsadsa


Sasas



asd2313




12

[[email protected] ~]# tr-s ' \ n ' <11111

Adsadsa

Dsadsa

Sasas

asd2313

12

9. Display each word (letter) in the file in a separate line with no blank lines

[[email protected] ~]# cat 11111

Hello Nihaoma chifanlema Tianqibucuo

[email protected] ~]# cat 11111| Tr ' \ n ' | Tr-s ' \ n '

Hello

Nihaoma

Chifanlema

Tianqibucuo

10, create user Gentoo, additional group is bin and root, the default shell is/BIN/CSH, the annotated message is "Gentoo distribution"

[Email protected] ~]# useradd-s/bin/csh-g bin,root-c "Gentoo distribution" Gentoo

[Email protected] ~]# getent passwd Gentoo

Gentoo:x:4007:4008:gentoo distribution:/home/gentoo:/bin/csh

11. Create the following user, group, and group memberships

Group with the name Admins

User Natasha, using admins as a subordinate group

User Harry, also use admins as a subordinate group

User Sarah, no interactive login system, and not a member of admins, Natasha,harry,sarah password is CentOS

1122 2016-07-30 14:21:18 groupadd Admins

1123 2016-07-30 14:21:37 useradd natasha-g Admins

1124 2016-07-30 14:21:50 useradd harry-g Admins

1125 2016-07-30 14:22:25 useradd sarah-s/sbin/nologin

1135 2016-07-30 14:24:56 Echo ecntos|passwd--stdin Natasha

1135 2016-07-30 14:24:56 Echo ecntos|passwd--stdin Harry

1135 2016-07-30 14:24:56 Echo ecntos|passwd--stdin Sarah


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

Fifth day record

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.