Linux directory file Management related commands

Source: Internet
Author: User
Tags create directory sorts

A directory is a file, a path mapping file; a path is a location (hierarchical) from a specified starting point to a destination.

The path is divided into 2 types:

Absolute path: Starting from the root, after subdirectories, double directories, files; example/usr/local

Relative path: The path to the current path;/x/y,./represents the current path, as a parameter can be omitted

# pwd shows the current path

# LS displays all files and directories under the current path

Options:

-L denotes long format, complete information, information content:

File format

-: Normal file

D: Catalog file

B: Block device files

C: Character device file

L: Symbolic Link file (soft connection file), link file can be understood as a shortcut on Windows,

P: Command Pipeline file

S: Kit Word file

File permissions: 9-bit, every 3-bit 1-group, rwx (read, write, executable), no use-Indicates

Number of file hard links, inode node number of links

The owner of the file

Group of files

File size, per byte

Timestamp (timestamp), this is the last time modified, each file has 3 timestamps:

Last Accessed time: Access

Last modified: Modify, Modified content

Recently changed time: Change metadata, changed attributes (meta data)

Filename

-h do byte-sized unit conversions

-a displays all files, including the. Hidden files at the beginning

. Represents the current directory

.. Represents the top-level directory of the current directory, the parent directory

-a displays all files included with the. The opening of the hidden file, but not displayed. And..

-D Displays the directory itself

-I displays the inode number, and each file has a file identifier (index Node,inode), in addition to the filename

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7B/48/wKioL1bKoezSbXXcAABMi7BUnSg280.png "title=" Qq20160222134933.png "alt=" Wkiol1bkoezsbxxcaabmi7bunsg280.png "/>

# LL is the alias of Ls-l--color

# CD Switch current directory

CD does not add parameters, will switch home directory

CD ~username switch to the home directory of the specified user

CD-Switch back and forth between the previous directory and the current directory

# mkdir Creating a Directory

Options:

-M,--mode=mode set permissions

-P,--Parents can be a path name that does not exist when some directory in the path is not present and automatically creates a nonexistent directory

-V Create new directory display information

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7B/54/wKiom1bLuNuS5zLUAAAktjstVmg041.png "title=" Qq20160222134933.png "alt=" Wkiom1blunus5zluaaaktjstvmg041.png "/>

# Tree View directory tree

Options:

-D Show only directories

-F Show All paths

-l Specifies the directory structure that displays the maximum depth in the current directory

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7B/54/wKiom1bLvVOyYhFVAAAY6gLc3o4419.png "title=" Qq20160222134933.png "alt=" Wkiom1blvvoyyhfvaaay6glc3o4419.png "/>

# rmdir Delete Empty directory

-p Example: Rmdir-p a/b/c similar to rmdir a/b/c A/b



There are 2 types of data in the file

Own data

Attribute data (meta data)

# file identifies the format of the file by viewing the file's header information, the format Elf refers to the executable, the type of file that can be linked

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7C/6B/wKiom1bQDEzzzAxmAAAf5s0GoxA060.png "title=" Qq20160226135102.png "alt=" wkiom1bqdezzzaxmaaaf5s0goxa060.png "/> Option:

-B does not display the file name when the result is displayed

-C Displays the instruction execution process, usually with the-m option

-F Displays file types for file names contained in files

-Z Try to view the contents of the compressed file

# Touch Changes the timestamp of the file, can also be used to create the file (timestamp is the file's properties, can change the access time and modification time, cannot change the change time)

Options:

-A Change access time

-M Change Modification time

-T [[[CC]YY]MMDDHHMM[.SS] Specify time

-C do not create a new file

# STAT displays file or file system status

Options:

-L If it is a link, get the source file information

-F Displays the status of the file system where the file resides

-c format defines output formats

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7C/AA/wKioL1bVUyHD5mJ3AAAmzFvy8qQ060.png "title=" Qq20160301162802.png "alt=" Wkiol1bvuyhd5mj3aaamzfvy8qq060.png "/>

Show access, modify, change time

# RM Delete files and directories

Options:

-I. Interactive

-F forcibly removed

-R Recursive Delete directory

The RM command, when used, is an alias of Rm-i, # \RM (with \ In front of the alias command, indicating its own command)

# CP Copy files and directories (if the destination file exists, then empty the contents of the destination file, and then copy the source file contents into the destination file)

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7D/68/wKioL1bnyDyhhTE9AAAf3yYgL9I943.png "title=" Qq20160315162804.png "alt=" Wkiol1bnydyhhte9aaaf3yygl9i943.png "/>

CP Source DEST (only the last one is the target, before the source)

Copy a file to a file, multiple files to a directory; When the CP link is copied, the linked file is duplicated, not the link

# Cp/etc/passwd/tmp/test has the following three conditions:

1,/tmp/without test, copy passwd to/tmp/and rename to test

2, if Test,test is a directory, copy passwd to/tmp/test/and name it passwd

3, Test,test is a file, copy passwd to/tmp/, overwrite test file contents

Cannot copy directory to destination for file

Options:

-A archive

-B,--Backup destination file

-F,--force to copy files or directories

-L,--link to create a hard-link file

-P,--Preserve preserve the properties of the source file or directory

--parents keep the path to the source file or directory

-R,-R,--recursive recursive replication

-S established as symbolic connection

-S backing up the word tail string

-U,--update is only copied when the source file is modified more than the destination file or the destination file does not exist

# mv Move or rename files, directories

Options:

-B destination file exists to back up the destination file, directory

-F Force Move files, directories

-U,--update only moves when the source file is modified more than the destination file or the destination file does not exist

# Install copy files, create directories, set properties (if the target file exists, delete the target file, and then copy the source file to the target file; commonly used in program makefile)

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/84/wKioL1bqIiaA3JXxAAAoyCosIt8711.png "title=" QQ picture 20160317111619.png "alt=" Wkiol1bqiiaa3jxxaaaoycosit8711.png "/>

Options:

-B,--Backup backups

-D Create directory similar to mkdir-p supports recursive creation of directories

-D recursively create the destination directory, and then copy the files

-G,--group designation genus

-O,--owner designation Master

-M,--mode specify pattern

# du shows the size of a file or directory

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7D/8D/wKiom1bqadyiKrb1AAAcCaPyfaU932.png "title=" Qq2016031716240511.png "alt=" Wkiom1bqadyikrb1aaaccapyfau932.png "/>

Options:

-A,--all displays the size of all files and directories under the directory

-b Specifies the size of the data block

-B Display units in bytes

-C, Total displays the directories and the sum

-D Show the source file size of the symbolic link

-H in K,M,G units

-l Duplicate hardware linked files

-l Display the source file size of the symbolic link

-S,--summarize show totals only



Text View related commands

# Cat View file content, display standard output, no split screen display

can achieve: 1, display the entire file at once

2. Create a file from the keyboard, # cat > FileName

3. Merge multiple files to display or merge into one file

Options:

-N Displays line numbers (including blank lines)

-B Displays line numbers (not including blank lines)

-E each line ends in $

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7D/9E/wKioL1brwAXDonsvAAAaagUsGfc180.png "title=" Qq20160318164212.png "alt=" Wkiol1brwaxdonsvaaaaagusgfc180.png "/>

# More pagination shows the contents of the file, cannot page forward

Options:

+n starting from Nth line

Display actions:

Ctrl+b Back to previous screen

V Call VI Editor

Q Exit More

# Less page shows the contents of the file, you can browse the file freely

# Head View the contents of the first few lines of the file

Options:

-V Show file name

-C Displays the contents of the specified number of bytes

-N Displays the contents of the specified number of rows

#tail view the last few lines of a file

Options:

-C Displays the contents of the specified number of bytes

-N Displays the contents of the specified number of rows

-F Display does not exit, continue to display the contents of subsequent files added

--pid with-F, terminate process Id,pid dead

-V Show More information

-S,--sleep-interval=s with-F, which means sleep s seconds at each repetition interval



Text-processing-related commands

# Cut cuts sections from each line of text to standard output, only good at working with "one character interval" text content

Options:

-B,--bytes=list Select the specified number of bytes

-C,--characters=list Select the specified character

-D,--Delimiter=delim defining separators

-F,--Fields=lst Select the specified range

-N with-B, without separating multibyte characters

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7D/D9/wKioL1bxB6XS3SSRAAAygSIftmk747.png "title=" Qq20160322164901.png "alt=" Wkiol1bxb6xs3ssraaaygsiftmk747.png "/>

# Sort sorts the lines of a text file

Options:

-B ignores whitespace characters at the beginning of each line

-D sorting, only English letters, numbers, and whitespace characters are processed

-f Sort, lowercase letters as uppercase

-M merges several sorted files

-M sorts the initials of the first 3 letters of the installation month for each line

-N Install numeric size sorting

-O to deposit the sorted result in the specified file

-R Reverse Sort

-t specifies the field separator character

-K sorts which field to use for the keyword

-U sorts the same rows only once (only the adjacent and identical rows are considered duplicates, and the nonadjacent rows are not considered duplicates if they are identical)

-C Check whether the input is sorted

# Uniq report or delete repeated rows (only adjacent and exactly the same as the repeating row, not adjacent, even if it is exactly the same.)

Options:

-C at the beginning of each line plus the number of times the bank appears in the file

-U displays only the rows that are not duplicated in the file

-D displays only duplicate rows

# WC shows the number of rows, characters, and bytes of the file content

Options:

-C Display of bytes (with spaces)

-m display number of characters

-l display number of rows

-L Displays the maximum number of characters for the longest line

-W Display number of words

# tr convert or delete characters

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7D/EA/wKioL1bzQgHBBwEXAAAajn9sfTg554.png "title=" Qq20160324092230.png "alt=" Wkiol1bzqghbbwexaaaajn9sftg554.png "/>

String 1 is used for queries, and string 2 is used to handle various conversions

Options:

-C matches all other characters except string 1

-D Delete string 1 matching characters

-S removes all occurrences of a character, leaving only the first















Linux directory file Management related commands

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.