Linux common Commands--file management (i)

Source: Internet
Author: User
Tags touch command

one , cat

1, function : View the contents of the file, from the first line to the last line ( for smaller files )

2 Common parameters:

-N is numbered by the first line, so the output line

- B is similar in function to-n, and it does not number blank lines

-S encounters a blank line that is substituted for a row with more than two consecutive lines of blank line

3 Example

1, use the cat–n command to view the/etc/dhcpd.conf file

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/BA/wKioL1WEBMPx4V9vAAVgsz8Z2I4211.jpg "title=" cat- N.jpg "alt=" Wkiol1webmpx4v9vaavgsz8z2i4211.jpg "/>


2 use the cat–b command to view the/etc/dhcpd.conf, comparedwith the above, found that less than five elements.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/BA/wKioL1WEBPbxQW2jAAUsG0VKtC8166.jpg "title=" cat- B.jpg "alt=" Wkiol1webpbxqw2jaausg0vktc8166.jpg "/>


two , chgrp

1. function: Change the owning group of the file or directory

2, common parameters

The-c effect is similar to the-v parameter, but returns only the part of the change

-v Show instruction execution Process

-R Recursive processing, all files and subdirectories under the specified directory are processed together

3. Example

1, Add a user group with the groupadd command

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BD/wKiom1WEA_rQB9o6AAAydSvD7nE986.jpg "title=" Gropadd.jpg "alt=" Wkiom1wea_rqb9o6aaaydsvd7ne986.jpg "/>


use the ll command to view the details of the Dhcpd.log file, and then change its user group with the CHGRP command

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/BD/wKiom1WEBJPwEEKsAAFRBmOLGnM940.jpg "title=" Chgrep 1.jpg "alt=" Wkiom1webjpweeksaafrbmolgnm940.jpg "/>


2 . Use the mkdir command to create a directory in/tmp, Create a file in the new directory with the Touch command, and then use the LL command to view the group that the file and directory belongs to

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BD/wKiom1WEBsbA22fkAAEZ7D2fdNg569.jpg "title=" Chgrep2.jpg "alt=" Wkiom1websba22fkaaez7d2fdng569.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/BA/wKioL1WECKXB90x4AAF1e8e3Pvg283.jpg "title=" Chgrep 3.jpg "alt=" Wkiol1weckxb90x4aaf1e8e3pvg283.jpg "/>


3, use the chgrp-rv command to change the group that the/TMP/ZJC directory file belongs to.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/BD/wKiom1WEB-DiuK5eAAA9hRmpGLg540.jpg "title=" Chgrep 4.jpg "alt=" Wkiom1web-diuk5eaaa9hrmpglg540.jpg "/>


use the ll command to see if the/TMP/ZJC directory and the files inside change the owning group

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/BA/wKioL1WECcHwrW4PAACN0kuuacQ414.jpg "title=" Chgrep 5.jpg "alt=" Wkiol1wecchwrw4paacn0kuuacq414.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/BD/wKiom1WECB-w0prpAAFxq-VzodI117.jpg "title=" Chgrep 6.jpg "alt=" Wkiom1wecb-w0prpaafxq-vzodi117.jpg "/>



Four,chmod

1. function: Change the permissions of a file or directory

2 Additional Instructions

U:user, which is the owner of a file or directory

G:group, which is the owning group of the file or directory,

O:Other, except for files or directories owned by or belonging to the group, other users belong to this scope

A:all, that is, all users, including the owner, the group that belongs to other users.

R: Read permission, the number "4 " represents, that is, 2 of the 2- Time Square

W: Write permission, the number "2 " represents, that is, 2 of the 1- Time Square

X: Execute permission, the number "1 " represents, that is, 2 of the 0- Time Square

-: Without any permission, the number "0" represents

3. Common Parameters

-F does not display error messages

-R Recursive processing, processing all files and subdirectories under the specified directory

< permissions >+< permissions Settings > The permission setting for a file or directory that has permission scope enabled

< permissions >-< permissions settings > close permission settings for a file or directory

< permissions >=< permissions Settings > Specify permission scopes for files or directories that have this permission configured

4, example one

1. Create a directorywith mkdir, touch create file, and ll View Details

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BD/wKiom1WECJLTo3xAAALOMr4RoMQ638.jpg "title=" Chmod1.jpg "alt=" Wkiom1wecjlto3xaaalomr4romq638.jpg "/>


2. Add the data.txt file owner to execute permissions, add Write permission to the owning group

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/BA/wKioL1WECnvAZuxFAAGCh0vVbCQ655.jpg "title=" chmod 2.jpg "alt=" Wkiol1wecnvazuxfaagch0vvbcq655.jpg "/>


3, close so people Read permission to the Data.txt file, give the owner, the person outside the group has Read permission.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/BA/wKioL1WEC87gJDK_AAGtXOE33RY523.jpg "title=" chmoed 4.jpg "alt=" Wkiol1wec87gjdk_aagtxoe33ry523.jpg "/>


4. use the chmod–r command to Add the/TMP/LX directory and the owner of the file inside it to execute permissions

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/BD/wKiom1WECo7izS2aAAKbFV4OXmM632.jpg "title=" chmod- R.jpg "alt=" Wkiom1weco7izs2aaakbfv4oxmm632.jpg "/>


5. example Two

1. Creating directories and Files

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/BA/wKioL1WEDLLS-m2RAALSn9pkODI923.jpg "title=" chmod 6.jpg "alt=" Wkiol1wedlls-m2raalsn9pkodi923.jpg "/>


2, use the chmod command to express the relevant permissions with a number, and recursively assign permissions to directories and files in the directory with Chmod–r

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/BD/wKiom1WEC0TwLMPrAANcpu_2xlY392.jpg "title=" chmod 8.jpg "alt=" Wkiom1wec0twlmpraancpu_2xly392.jpg "/>



Five,chown

1. function: Change the owner or group of the file or directory

2, common parameters

-H changes the file of the symbolic connection without altering any other related files

-R Recursive processing, so that files and subdirectories under the specified directory are processed together

-v Show instruction execution Process

3. Example

1, Create a user with Useradd, and create directories and files with mkdir,touch

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/BE/wKiom1WEC6ORKzImAANZf4omeLg278.jpg "title=" Chown.jpg "alt=" Wkiom1wec6orkzimaanzf4omelg278.jpg "/>


2, use chown to change the owner of the/tmp/chown/centos, using chown-r for recursive changes /tmp/chown The owning group of the files in the directory and directory

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/BA/wKioL1WEDZGRt8lYAANZpaWZc5I933.jpg "title=" Chown1.jpg "alt=" Wkiol1wedzgrt8lyaanzpawzc5i933.jpg "/>


This article is from the "ZJC" blog, make sure to keep this source http://zjclinux.blog.51cto.com/9796061/1663711

Linux common Commands--file management (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.