Learning from Linux for the elder brother Bird (6)--linux Archives and Directory Management

Source: Internet
Author: User

This chapter mainly introduces some instructions for directories, including CD (transform directory), PWD (show current directory), mkdir (new directory), rmdir (delete directory).

MkDir can not build a multi-level directory, if you want to set up a lot of directories, you need to add the parameter p, that is, Mkdir-p 1/2/3, of course, you can set the directory when the directory is given a certain permission, using the M parameter, that is, mkdir-m 711 test.

RmDir cannot delete a non-empty directory, also to delete the multi-level directory, using the parameter p, that is, rmdir-p 1/2/3. If you want to delete everything in the directory, use the RM-R test

$PATH: The variable that executes the file path, can be viewed by the command Echo $PATH, which defines which directories are defined, and if an instruction is stored in/usr/bin, then if the directory exists after Echo, then we can invoke the command, and the first search command executes first.

If you want to add a directive to the path, you can take the path= "$PATH":/root, so that/root is added to the path, we can invoke the command under/root.

The LS instruction is used to show which files exist in the current directory, here are some interesting parameters:

Ls-alf--color=never ~: Indicates that the displayed file does not display color

Ls-al--full-time ~: Indicates the full modification time of the rendered archive

In addition we generally use LL to replace ls-l, can be used to complete the command alias.

Copy file: CP ~/.BASHRC/TMP/BASHRC: Copy the ~/.BASHRC to/TMP/BASHRC. However, some files can not be copied, such as password files and some configuration files, if you must copy, you need to add-a or-p parameters to fully copy the permissions of the file. You can copy multiple data to the same directory in turn, but note that the most important thing is a directory!

Rm-i bashrc*: Delete the file that starts with BASHRC.

Moving files: MV BASHRC mvtest

Get file name: basename/etc/sysyconfig/network, get network

Get directory Name: dirname/etc/sysyconfig/network, get/etc/sysconfig

The following is a brief introduction to the contents of the file query instructions, and do a general description:

1) Cat: Start displaying the contents of the archive from the first line--cat/etc/issue,cat-n/etc/issue: Adding line numbers

2) TAC: The reverse of cat, meaning to start displaying the contents of the archive from the last line--tac/etc/issue

3) NL: Displays the line number when displayed--nl/etc/issue

4) More: One page to display the contents of the file, but can only back page--more/etc/issue, press Q exit more

5) Less: You can flip the page forward compared to more,less--less/etc/issue

6) Head: Only a few lines--head-n 20/etc/issue: Only look at the first 20 lines

7) Tail: Look only after a few lines--tail-n 20/etc/issue: Look only after 20 lines. You can also look at line 10th to 20th, with the instructions Head-n 20/etc/issue | Tail-n 10, of which the | is intercepted, will be introduced later.

Modify the file time or create a new file can use touch, here to note three time:

mtime--time for file content modification

ctime--the time the file state changed (attribute changed)

atime--when the archive content is taken, you can use touch test to create a document with the LS

-L test to view three times of the test document.

The file preset permission is umask, specifies the current user in the establishment of the file or directory permissions default value, the direct input umask will get the default value, assuming the result is 0022, the first 0 we do not consider, the following 022 is the need to cut the permissions, for example, now the permission is 777-022 = 755, that is, the owner is rwx, the group and others are RX.

In fact, in addition to the rwx these three properties, there are hidden properties, with instruction Chattr to manage, the most common one chattr instruction is chattr +i test, that is, give test an I property, so that the document can not be deleted, only input chattr-i Test removes the I attribute before deleting it. If you want to display the properties of the file hidden, you can use LSATTR test to display it.

Observation file type: Files Test

Find files: Which Test,whereis test, locate test, where the next two are all using the database to search for data, so faster, and there is no actual search hard disk, compared to save time.

Of course, one of the most important search commands is find, which lists several common find instruction usages:

Find/-mtime 0: Previously said Mtime is the time of the content modification, here 0 represents the current time, so to find out from now to 24 hours before the content of the file

FIND/ETC-NEWER/ETC/PASSWD: Find new files in/etc in build time than/passwd

Find/home-user JJ: Find files belonging to JJ in home directory

Find/-nouser: Finding files that don't belong to anyone

Find/-name passwd: Locate the file named passwd under the root directory

Find/-size +1000k: Locate the file size larger than 1M in the root directory

Learn from the learning of Linux (6)--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.