Linux basic commands-Directory management-file management

Source: Internet
Author: User

⑴, directory view command ls

LS: Displays files in the current directory

-L: Lists the files in the current directory and displays their related properties

-A: Displays all files in the current directory that contain hidden files

-A: Displays the current directory in addition to. and. All directories outside the directory

-H: Displays the file size by units of K or M.

-R: Reverse Display

-R: Recursive Display of directories

⑵, System time view and modify command clock, Hwclock, date

Clock: Show System time

Hwclock: Displays the hardware time of the system.

HWCLOCK-W: Synchronizing the system time to the hardware

Hwclock-s: Synchronizing hardware time to the system

Date modification Time

The date month, day, day, and every minute (yearly). seconds

⑶, directories, file creation and deletion commands Mkdir,touch, RmDir, RM

mkdir: Creating an empty Directory

Mkdir-p: Creating a directory recursively

Touch: Create a file

Touch-c: The file is not created when it exists

RmDir: Delete an empty directory

Rmdir-p: Recursively Delete a directory

RM: Deleting files

Rm-i: Interactive Delete

RM-F: Violent deletion

Rm-r: Recursively Delete a directory

RM-RF:

Another use of touch: Modify Timestamp

-A: Change access time only

-M: Change the modification time only

-T: Self-built time (month and day)--with a, m with use! )

Stat: Displays the timestamp of the file

⑷, file, directory copy command CP

cp/etc/passwd/tmp/: Copy to directory and save the original file name

Cp/etc/passwd/tmp/test:test directory exists, meaning as above, otherwise copy and rename to test

-r: Recursive copy Directory

-I: Interactive display of information

-F: Forced override

-P: Preserve the properties of the original file

-A: Preserves all properties of a file

Cp-p: When copying linked files, directly copy the link (CP link file is the default copy of the link pointing to the file)

⑸, the move of the directory file, the MV of the rename command

MV SRC (source) DEST (target)

MV AB BC

⑹, text File View commands cat, more, less, head

Cat: Link and display all the contents of a file

-N: Display line number when displayed

-E: Displays the terminator of each line

-T: Show tabs

TAC: Reverse Display

MORE: Much the same as cat's usage, just provides a page-forward paging to display. Show to last Auto exit

Less: Similar to more, only displays the last required input Q to exit the display

Head: Displays the first n rows of a text file

-N: Top N rows

Tail: View the following n lines of text, default is 10

-N: After n rows

Special usage of tail:

-F: View the end of the file, and do not exit, waiting for the display of new additions;

⑺, Text Processing command cut, sort, WC, tr

Cut: Used to cut data and display

-D: Knows the field delimiter. Default is empty, cut-d:-f7 whitespace cut-d "

-F: Develop the field to select

Sort: Commands for text sorting

-N: Sort by numeric size

-R: Descending sort

-U: The same line is displayed once

-F: Ignore case

WC: Text Statistics command

-L: Show only the number of rows

-W: Displays only the number of words

-C: Show only the number of bytes

-L: Indicates how many characters are displayed for the longest line

TR: for converting or deleting characters

Tar ab AB: Conversion

tar-d: Delete occurrences of characters

⑻, Directory Rights Management

1, Chown: Modify the file owner-(only administrators have this permission)

Chown USERNAME file .... (Change the directory itself only)

-R: Recursive modification (owner of modified directory and its internal files)

--reference=/path/to/somefile file: Sets the owner of the file to be the same as the owner of the Somefile (no need to specify the owner)

Chown username:grpname Fiel ... Change both the owner and the group

Hown:groupname Fiel .... Modify Genus Group

2, modified files belong to group: chgrp: Modify the file group-only the administrator can use

Basic attachment parameters are the same as Chown

Chgrp GROUPNAME file .... (Change the directory itself only)

-R: Recursive modification

--reference=/path/to/somefile file ... Set the owner of the file to be the same as the genus of the somefile (you do not need to specify a group)

3. Modify file Permissions: chmod

chmod 755 File: directly specifies the 2 binary of the permission.

Modify a user or some class user rights (U, G, O, a)

chmod user category =mode Fiel.

Modify a user of a certain class or some bit permissions mode (WRX)

chmod user Category [-/+]mode fiel:


This article is from the "ZQSLZR" blog, make sure to keep this source http://zqslzr.blog.51cto.com/3522364/1789987

Linux basic commands-Directory management-file management

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.