Linux File and directory management

Source: Internet
Author: User

1. Relative Path/absolute path

The absolute path is written from the root directory, like this:/user/share/doc;

The relative path is first for the current position, and the join is now in the/user/share/doc directory, then CD. /man, the implementation jumps to

Under the/user/share/man directory;

2. Directory-related Operations

. //                                     current directory .. //  Upper directory (the previous layer of the root directory or himself) -//  represents the previous working directory  ~ //  
CD                                    // switch directory pwd                                   // show current directory location (absolute path)mkdir test1                           //  Create a test1 directory under the current directory mkdir-p test1/test2/test3            // Create a multilevel directory recursively in the current directory rmdir test1                           // Delete directory test1rmdir-p test1/test2/test3            // Delete Test3, along with parent directory empty also delete

3. System Variable $path

In fact, this should not be unfamiliar, the purpose of $PATH is to make it easier to call the system executable file;

Before the system variable $path, we execute a command that may be required:/bin/ls;

But if we add the/bin to the system path variable $path, then we just need to hit LS, and the system will be automatically to $path

Inside to find there is no **/ls matching execution file, if there is, then execute, if there are multiple, then the first query to the directory under the command.

Path="$PATH":/root                 // add/root to system PATH variable

4. viewing files and directories ls

Last-H to view the size of the file (in units B)

5. Copy, delete, and move

The CP [options] Source destination copies the source files to the target file, listed under parameters [options]:

-P                                      // along with the file's attribute permissions all copy -I                                      // If the target file exists then ask whether to overwrite                                       The meaning of-f//mandatory, Even if the target file is not switched on, delete and try the-s                                      / / Copy as shortcut file- u                                      / / If the destination file is older than the source file is updated -R                                      // recursive operation for copying directories

RM [Potions] File/directory

-I                                       / / Delete Ask -R                                       / / recursive operation for directory deletion- f                                       // does not ask

So you should know how dangerous the RM-RF command is.

MV [options] source destination

-F                                        / / If the destination file already exists, will not ask for direct overwrite- i                                        / / If the target file exists then ask u                                        // the source file is newer before it is updated

6. Document Content Review

For the same file, different output (display) mode, cat for normal layout display

When the file content is very large, you need to turn the page to display:

More                             // One page turn the space---------------------- down one page enter-------------------- scroll down a line /String------------------- query This string on the current page Q------------------------ leave this Moreb or ctrl+ b---------------turn back.

Similar to the less command, it is more resilient:

Space---------------------- PAGE DOWN pagedown----------------- PAGE DOWN PageUp-------------------  Page Up /String------------------- down query string? String------------------- up query string n--------------------- --- repeat the previous query n------------------------ Reverse Repeat the previous query Q------------------------leave less

The above command takes the first two lines and the last two lines respectively.

For non-plain text files, you can use the OD command to look up text content:

od-t [Options] non-plain text files The options parameters are as follows:

A                                    // default character output C                                    //ASCII character output

Linux file 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.