Linux Administration catalog File command summary

Source: Internet
Author: User
Tags unpack

I. Common commands for file and directory management

Directory operation commands:pwd,cd,ls,mkdir,du,

File Operations Command:

Touch,file,cp,RM,MV,which,find,Ln

File Content Operations Command:

Cat,more,less,head,tail,WC,grep

Archive and Compress commands:

Gzip,bzip2,tar

because the directory belongs to a special file in a Linux system, many commands that operate on the file also apply to the directory.

Ii. specific usage of the order

1.pwd Command

Purpose: View working directory

How to use: enter PWD directly at the command line . The PWD command is generally used alone, without paying special attention to the command format.

2.CD Command

Purpose: Switch working directory

format:CD [ directory location ]

The directory location (file location) can use an absolute path, or you can use a relative path.

The CD command specifies "-" as a parameter, which means switching to the same directory as the previous step

3.ls command

Purpose: List displays directory contents

format:ls[ option ] ... [ directory or file name ]

Common Command options:
-L: Display in long format

-A: Displays information about all subdirectories and files, including hidden files

-D: Displays the properties of the directory itself

-a: similar to "-a", but not realistic ". "and". the information for the directory

-H: Display informationin more readable byte units (K,M , etc.)

-r: The contents of thefirst return display

--color: Distinguish different types of files by color

4.mkdir Command

Purpose: Create a new directory

format:mkdir[-p] [ path ] directory name

the mkdir command is used to create a new empty directory, and you can create multiple directories at the same time

The-p option creates a nested multi-tiered directory structure that can only be created in a directory that already exists if you do not use the-P option.

5.du command

Usage: Statistical catalogue and space occupancy of documents

format:du [ options ] ... [ directory or file name ]

Common Command options:

-A: All files are included in the statistics, not just the statistics directory

-H: Display informationin more readable byte units (K,M , etc.)

-S: Counts the total amount of space occupied by each parameter

The "-s""-H" option of the du command istypically used together to count the total size of the specified file

6.Touch Command

Purpose: Create a new empty folder, or update the file time stamp

format:touch file name ...

7.File command

Purpose: View File types

format:file file name ...

8.CP Command

Purpose: Copy files or directories

format:CP [ options ] ...   source file or directory ... destination file or directory

Common Command Options

-R: Copy entire directory tree first

-P: Keep the properties of the source file unchanged

-F: Force overwrite the target file or directory with the same name

-I: reminders when files or directories need to be overwritten

9.RM Command

Purpose: Delete files or directories

format:rm [ options ] ... file or directory

Common Command Options

-F: Forcibly deleting files or directories without reminders

-I: Remind users to confirm when deleting files or directories

-R: Recursively delete entire directory tree

RM-RF(Universe Invincible First delete command) when this command executes without any hint, delete the file or the entire directory tree directly, you should use it carefully

Ten,MV command

Purpose: Move a file or directory (if the target location and source file location is the same, the equivalent of renaming

format:mv [ options ] ...  source file or directory ... destination folder or directory

If you need to move multiple files or directories, the target must be a directory

One,which command

Purpose: Find the linux command file and display the location (the search scope is specified by the PATH environment variable)

format:which command or program name

perform "echo $PATH" To see what the PATH variable specifies

Thefind command

Purpose: Used to find files or directories

format:find [ look in] [ find criteria ]

Common search criteria:
-name: Find by file name

-size: Find by File size

-user: Search by file owner

-type: Find by File type

The current directory is used as the lookup scope when the default lookup range

Find by name: keyword "-name", based on the target file part name lookup, allow the use of * and? Wildcard characters

Find by file size: The keyword is "-size", based on the part of the target file name lookup, generally use the "+","-" number set to more than or less than the specified size as the search criteria. Common capacity units include K(note is lowercase). M,G

TheHead command

Purpose: View part of the beginning of the file (default is ten lines)

format:head-n file name

Tail command

Purpose: View a small portion of the end of a file (default is ten lines)

format:tail-n file name

Tail-f file name

WC command

Purpose: Statistics The number of words in the file and other information

format:WC [ options ] ... target file ...

Common Command options:

-L: Count rows

-W: Count the number of words

-C: Statistics of bytes

The.grep Command

Purpose: Finds and displays the line containing the specified string in the file

format:grep [ options ] ...   Find Criteria target file

Common Command options:

-I: Ignore case when finding

-V: Reverse lookup, output rows that do not match the lookup criteria

Find conditional settings

The string to find is enclosed in double quotation marks.

"^..." indicates that ..... Beginning, "... $"means to ... End

"^$" indicates a blank line

bZIP,gzip command,

Purpose: Make compressed files, unpack compressed files

format:gzip [-9] file name ...

bZIP [-9] file name ...

gzip-d. GZ format for compressed files

bzip2-d compressed files in *.bz2 format

Common Command Options

-9: High compression ratio, more when creating a compressed package

-D: Used to unlock files that have been compressed

Tar command

Purpose: Make compressed files, unpack compressed files

Purpose: Make archive files, release archive files

format: tar [ options ] ...  Archive file name source file or directory

tar [ options ] ...  Archive file name [-C target directory ]

Common Command Options

-c(lowercase): Create A package file in . tar format

-X: Unpack package files in . tar format

-V: Output details

-F: Indicates the use of an archive file

-P(uppercase): Preserve the permissions of Yuanshi files and directories while packaging

-T: List view files in package

-P(lowercase) keeps the properties of the original file unchanged

-C (uppercase): Specifies the target folder to release when unpacking

-Z: Call the GZIP program for compression or decompression

-j: Call bzip2 program for compression or decompression


This article is from the "Forward Linux Notes" blog, so be sure to keep this source http://momodeqianxing.blog.51cto.com/9041985/1426718

Related Article

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.