Linux Archives and Directory management

Source: Internet
Author: User
Tags parent directory

To learn about Linux files and directories, you should first look at relative paths and absolute paths.

Absolute path: The path must be written by the root directory, such as/DEV/SDA.

Relative path: The path is not written by/write (relative to the path of the current directory), for example:./dev.

Several common ways to represent relative paths:

.. /: Parent directory./: Current directory.: represents this layer directory. : Represents a previous level directory

-: Represents the previous working directory ~: The home directory representing the current user's identity ~account: Represents the home directory where the account user resides

Common Directory processing commands:

1) CD: Transform directory

Command format: CD [relative path or absolute path]

EG:CD Vbird representative went to vbid the user's home directory, namely/home/vbird

CD represents the current directory

2) PWD: Show current directory

Command format: PWD [-P]

Common options and Parameters:

-P: Shows the exact path instead of using the link path.

3) mkdir: Create a new directory

Command format: mkdir [-MP]

Common options and Parameters:

-M: Configure permissions for the file. Direct settings, do not need to see the default permissions (Umask) face.

-P: helps you to directly set up the desired directory recursively.

Eg:mkdir-m 711 Test2

Mkdir-p/test1/test2/test3

4) RmDir: Delete an empty directory

Command format: rmdir [-p] Directory name

Common options and Parameters:

-P: Along with the upper empty Directory is also deleted.

5) LS: View of files and directories

LS has a lot of parameters, the most commonly used is the-a,-d,-l these several.

6) CP: Copy files or directories

Command format: CP [-ADFILPRSU] source file destination file

Common options and Parameters:

-I: If the target file already exists, the action will be asked before overwriting.

-P: Copy the past together with the attributes of the archive, not the default properties.

-R: Recursive continuous replication for the replication behavior of the directory.

7) RM: Remove files or directories

Command format: RM [-fir] File or directory

Common options and Parameters:

-F: Ignores files that do not exist and does not appear with warning messages.

-I: Interactive mode that asks the user if the action is active before deleting it.

-r: Recursive delete.

8) MV: Move files and directories, or rename

Command format: MV [-FIU] Source desination

Common options and Parameters:

-F: If the target already exists, no direct overwrite is asked.

-I: If the target file already exists, ask whether to overwrite

-U: If the target file already exists and the source is newer, it will be updated.

9) basename: Get the file name of the path

DIRNM: Gets the directory name of the path

10) access to the contents of the archives:

Cat: Displays the contents of the archive starting from the first line

TAC: Starting from the last line, it can be seen that the TAC is written backwards by Cat.

NL: The output line number when displayed.

MORE: Page-by-page display of file contents

Less: Like more, you can flip ahead.

Head: Just a few lines.

Tail: Just look at the tail a few lines.

OD: Reads the file contents in binary way.

11) Search for script file names:

Which: Finding the execution file

12) Search for file name:

Whereis [-BMSU] file or directory name

Locate [-ir] keyword

Find [PATH] [option][action]

whereis and locate are searched through the database, faster, but the database is built by default once a day, so when your newly created file will tell you that you can't find it. It is possible to update the database with Updaedb

Linux Archives and Directory 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.