Linux common command - Archive directory management

xiaoxiao2021-03-06  66

Archive directory management --LS

Name: LS

Use permission: All users

How to use: ls [-ALRTAFR] [name ...]

Description: Displays the contents of the specified working directory (list the files and subdirectories included in the current working directory).

Parameters:

-a Displays all files and directories (LS demonstrates the file name or directory name "." will not be listed as hidden files.

-L In addition to the file name, the file type, authority, owner, and file size is also detailed.

-r Displays the file in the opposite order (originally in the order of English)

-t lists the priorities of the file according to the establishment time

-A, but not listed "." (Current directory) and ".." (parent directory)

-F adds a symbol after listed by the file name; for example, the executable is added "*", the directory is added "/"

-R If there is a file in the directory, the following files are also listed.

example:

List all the names in the current working directory, the beginning of the beginning, and the more advances are reached:

Ls -ltr S *

List all directories and file details below / bin directory:

Ls -lr / bin

List all files and directories under the current working directory; directory is added later, "/", can perform files after adding "*":

LS -AF

Archive directory management - CD

Name: CD

Use permission: All users

How to use: CD [DIRNAME]

Description: Transform work catalog to Dirname. The DiRName representation can be an absolute path or relative path. If the directory name is omitted, transform to the user's Home Directory (that is, the directory where Login is located).

In addition, "~" is also expressed as HOME DIRECTORY, "." Means the current directory, ".." indicates the current directory of the current directory location.

Example: Jump to / usr / bin /:

CD / usr / bin

Jump to your own home Directory:

CD ~

Jump to the upper two layers of the current directory:

Cd ../ ..

CD - Return to the current directory before entering the current directory

Archive directory management - RMDir

Name: RMDir

Use permissions: All users with appropriate permissions in current directory

How to use: rmdir [-p] DIRNAME

Description: Delete empty directories.

Parameters: -P is that when the subdirector is deleted, it will also be deleted by the way.

example:

Delete the subdirectory named AAA in the working directory:

RMDir AAA

In the BBB directory in the working directory, delete the subdirectory called TEST. If the Test is deleted, the BBB directory is empty, then BBB is also deleted.

RMDIR -P BBB / TEST

Archive Directory Management - RM

Name: RM

Use permission: All users

How to use: rm [options] name ...

Description: Delete files and directories.

parameter:

-i before the deletion, please ask for confirmation one by one. -f even if the original file property is set to read, it is also directly deleted without one by one. -r Detects the directory and below. Example: Delete all C language file files; check one by one before deleting: rm -i * .c Delete all files in the Finished subdirectory and subdirectory: RM -R Finished file directory management - MV

Name: MV

Use permission: All users

Use mode:

MV [Options] Source Dest

MV [Options] Source ... Directory

Description: Move a file to another, or move several files to another. Parameters: -i If the destination already has the same name file, first ask if the old file is overwritten.

example:

Rename the file AAA as BBB:

MV AAA BBB

Move all C language programs to the Finished subdirectory:

mv -i * .c

Archive Directory Management - MORE

Name: more

Use permission: All users

How to use: more [-dlfpcsu] [-num] [ / pattern] [ linenum] [filenames ..]

Description: Similar to CAT, it will make the user's page-by-page reading at a page, and the most basic instruction is displayed in the next page of the blank key (Space). Press the B button to go back (Back) One page shows, and also has the function of searching strings (similar to VI), in use, press H.

Parameters: -num number displayed

-d prompts, display [Press Space to Continue, 'q' to quit.] below the screen, if the user presses the wrong button, [Press 'H' for instructions.] instead of '' sound

-l cancels the function of meeting special character ^ l (paper feed characters)

When calculating the number of lines, the number of rows after the actual line (some single lines will be expanded to two or more lines)

-p does not display each page in a rolling manner, but first cleared the screen and then display the content.

-C is similar to -p, different is to display content and then clear other old materials.

-S When you encounter a blank line with two consecutive lines, it is changed to the blank line of a line.

-u does not display the lower quotation marks (different depending on the termage specified by the environment variable TERM)

/ Search the string (Pattern) before each file is displayed, then start displaying from the string

NUM starts from the Normal line

Filenames can display the file file, can be multiple numbers

example:

More -s testfile Displays the file content of TestFile, if there is a row, the blank line is displayed in a row of blank lines.

More 20 Testfile starts the contents of Testfile from the 20th line.

Archive Catalog Management - MKDIR

Name: mkdir

Use permissions: All users with appropriate permissions in current directory

How to use: mkdir [-p] DIRNAME

Description: Establish a subdirectory named DIRNAME.

Parameters :- Enter the directory name existence, there is no existence.

example:

In the working directory, create a subdirectory called AAA:

Mkdir AAA

In the BBB directory in the working directory, create a subdirectory called TEST. If the BBB directory does not exist, one is created. (Note: If this example does not add -P, and the original BBB directory does not exist, an error is generated.)

MKDIR -P BBB / TEST

Archive Directory Management - Locate

Name: Locate

Use permission: All users

How to use: Locate [-q] [-d] [--Database =]

Locate [-r] [--Regexp =] locate [-qv] [-o] [--output =]

Locate [-e] [-f] <[- l] [-c]

<[- u] [-u]>

Locate [-VH] [--Version] [--help]

Description:

Locate allows users to quickly search for the specified file in the archive system. Its method is to build a database including all file names and paths in the system, and then only query this database when looking for, without having to actually go into the archive system.

In a general distribution, the establishment of the database is placed automatically in the contab. General users use as long as used

# Locate your_file_name

The model is OK. Parameters:

-u

-U

Establish a database, -U will start with the root directory, and -U can specify the starting position.

-e

Will exclude the range of findings.

-L

If it is 1. Start safe mode. In safe mode, the user will not see the file that is not available. This will slow down because Locate must obtain the permission information of the file in the actual archive system.

-f

Exclude a specific archive system, for example, we have not to put the files in the proc archive system in the database.

-Q

Quiet mode does not display any error messages.

NN

At most displayed output.

-r

Use the regular operation to do the conditions for finding.

-o

Specify the name of the data inventory.

-d

Specify the path to the database

-H

Display auxiliary message

-V

Show more messages

-V

Display version of the version of the message:

LOCATE chDRV: Looking for all files called ChDRV

LOCATE-N 100 A.out: Look for all files called A.out, but only 100

Locate -U: Create a database

The locate command can quickly find the file when searching the database, the database is updated by the UpdatedB program, updatedb is built by Cron daemon, the locate command is fast, but more powerful than the entire use of the hard disk information. Is the file found by LOCATE to establish or just renamed, may not be able to find, in the network, updatedb will run once a day, can be modified by modification crontab to update the set value. (ETC / crontab)

Locate Specifies the file to search for eligible, which will store the file and the directory name, find the file or directory of the model conditions, you can use special characters (such as "*" or "?", etc.) Specify the template style, such as the specified model is KCPA * Ner, Locate finds all the start strings to KCPA and ending the file or directory ending for NER, if the name is KCPartner If the directory name is KCPA_NER, the directory will be listed. All files in the subdirectory.

Locate instructions and find findings are similar, but Locate is to create all files and directory information in the hard disk first through the Update program, and then find the index directly when performing LOACTE, and the query speed will be fast, index database is general It is managed by operating system, but it can also be directly updated directly to the index database immediately.

However, the first time I execute Update and then use Locate to find a file that will often fail. At this time, it is necessary to execute the slocate ˉu this command (also executable UpdatedB instructions, the same) to update the slocate database, the command will be under / usr / sbin Generate a Slocate execution file, then look for the information you want to find by Locate to this database.

Archive directory management - LN

Directive Name: LN

Use Permissions: All users use methods: ln [options] Source Dist, where Option is: [-bdfinsvf] [-S backup-suffix] [-V {numbered, existing, simple}] [--help] [ --Version] [-] Description: In the Linux / Unix file system, there is a so-called link, we can treat it as an alias of the file, and the link can be divided into two: hard links (HARD LINK) With Soft Link, the hard link means that a file can have multiple names, while the soft linking method is to generate a special file, the content of the file is to another file. Hard links are in the same archive system, while soft links can span different archive systems. The LN Source Dist is a link (dist) to SOURCE, as for the use of the hard link or soft link, is determined by the parameter. Whether it is a hard link or soft link, it will not copy a copy of the original file, and will only take a very small amount of disk space. Parameters: -f: The link will first delete the file with the DIST: Allow the system administrator hard link to your directory -i: Inquire about the file when deleting the file with the DIST. When performing soft link, the Dist is treated as a general file-S: Symbolic link -V: The file name is displayed before the connection is previously overwritten or deleted. Backup - Suffix: Plus the backup files with a SUFFIX word tail - VMETHOD: Specify the backup method - HELP: Display auxiliary instructions --Version: Display version example: Set the file yy a Symbolic link: zz ln - S YY ZZ generates a Hard Link: ZZ LN YY XX

Archive Directory Management - Find

Name: find

Usage: find

Instructions for use :

List of files that comply with Expression in the archive system. You can refer to a combination of different information such as the name, category, time, size, permissions, etc., only fully matched.

Find determines the Path and Expression on the following rules, first on the command - (), the previous part is PATH, after which is Expression. If PATH is a null string, use the current path, if Expression is the empty string, use -print as the preset expression.

There are more than two or thirty options that can be used in Expression, which only introduces the most commonly used part.

-mount, -xdev: Only check and specify files under the same archive system, avoid listing files in other archives systems.

-AMIN N: Readed in the past N minutes

-anewer file: Archives read later than files File

-Atime N: Files read in N days in the past

-cmin N: Modified in the past N minutes

-cnewer file: file updated than file file

-ctime N: Archives in the past N days

-empty: Empty Archive - GID N or -Group Name: GID is n or group name is Name

-ipath p: -path p: The path name is compliant with the file, IPath will ignore the case

-Name Name, -iname name: The file name is compliant with the file. INAME will ignore cases

-Size N: The file size is N unit, b represents the block of the 512-bit group, c represents the number of words, and k indicates that kilo Bytes, W is two bit yuan groups. -type C: The file type is C file.

D: Directory

C: Dictionary device file

B: Block device file

P: Total list

F: general file

l: Symbol connection

S: socket

-PID N: Process ID is the file

You can use () to separate the arithmetic, and use the following operations.

EXP1 -AND EXP2

! Expr

-Not EXPR

EXP1 -OR EXP2

EXP1, EXP2

example:

List of all extended files in the current directory and its subdirectory is C.

# Find. -Name "* .c"

List all the general files in their underlying directory

# Find. -Ftype f

List all files updated in the current directory and its subdirectory

# Find. -Ctime -20

Find. -name "*" -exec grep xxx {}; -print | morexxx for strings you want to find

Archive Directory Management - CUT

Name: CUT

Use permission: All users

Usage: cut-cnum1-num2 filename

Description: Shows the text that counts Num1 to Num2 from the beginning.

example:

Shell >> Cat Example

TEST2

this is test1

Shell >> Cut -c0-6 example ## print starts the first 6 words

TEST2

THIS I

Cut is actually useful

-C m-n represents the mth font to the nth word of each row. E.g:

--------- File ----------- Liubi 23 14000 --------- File ----------- # CUT -C 3 -9, 12-20 File LiUBI 14000 -F mn represents the display of the M-column to the N-column (separated using Tab). For example: --------- File ----------- Liubi 23 14000 --------- File ----------- # CUT - F 1,3 File Liubi 14000

Archive Directory Management - CP

Name: CP

Use permission: All users

Use mode:

CP [options] Source Dest

CP [Options] Source ... Directory

Description: Copy a file to another, or copy several files to another directory.

parameter:

-a will copy the file status, permissions and other materials as much as possible.

-r If the Source contains a directory name, the files in the directory are also copied to the destination.

-f If the destination already has the same file, it is deleted before the replication is removed.

example:

Copy the file aaa (already existing) and name BBB:

CP AAA BBB

Copy all C language programs to the Finished subdirectory:

cp * .c finished

Archive Directory Management - CHOWN

Directive Name: Chown

Use permission: root

How to use: chmod [-cfhvr] [--help] [--version] user [: group] file ...

Description: Linux / UNIX is a multi-worker operating system, all of which have owners. Use Chown to change the owners of the file. In general, this instruction only is used by the system administrator (root), and the general user has no permissions to change someone else's file owner, and there is no permission to change the owner of its own files to others. Only the system administrator (root) has such permissions.

Parameters:

User: New Archive owner's user IDGroup: New Archive owner's User Group (Group) -c: If the file owner does have changed, the change action is displayed - F: If the owner cannot Do not display the error message - H: only for links (LINK), not the LINK, true pointing file -V: Display owner change - R: All files and subdirectories in current directory Perform the same owner change (ie, changed one by one by one) - Help: Display auxiliary instructions --Version: Display version example: Set the owner of the file file1.txt User Jessie: Chown Jessie : Users file1.txt Sets all the files in the current directory with the owner of the subdirectories Lamport: chmod -r lamport: Users * Archive Directory Management --Chmod

Directive Name: Chmod

Use permission: All users

How to use: chmod [-cfvr] [--help] [--version] mode file ...

Description: Linux / UNIX file adjustment rights is divided into three levels: file owners, groups, others. Use CHMOD how to control how to be called by others.

Parameters:

Mode: Permissions Set strings, formats are as follows: [Ugoa ...] [[ - =] [rwxx] ...] [, ...], where

u Indicates the owner of the file, G indicates that the owner of the file belongs to the same group (group), o represents the other than other people, A means that these are all.

Represents increased permissions, indicates cancellation, = indicates unique setting permissions.

R indicates that readable, W represents written, x represents executable, X represents only when the file is a subdirectory or the file has been set to be executed.

-c: If this file authority does have changed, it will display its change action.

-f: If this file is not changed, do not display an error message.

-v: Details showing permission changes

-R: The same permissions change in the current directory with the subdirectory (ie, changed by one by one)

--help: Display auxiliary instructions

--Version: Display version

Example: Set the file file1.txt to everyone can read:

CHMOD UGO R File1.txt

Setting the file file1.txt can be read:

CHMOD A R File1.txt

Set the file file1.txt and file2.txt to this file owner, which is written with its own same group, but other people cannot be written:

CHMOD UG W, O-W File1.txt File2.txt

Set the ex1.py to only the file owner can perform:

CHMOD u x ex1.py

Set all the files and subdirectories in the current directory to anyone read:

CHMOD -R A R *

In addition, CHMOD can also use numbers to express permissions such as CHMOD 777 file.

Grammatical: chmod abc file

Where A, B, C are each number, which represents USER, Group, and Other permissions. R = 4, w = 2, x = 1 To RWX attribute 4 2 1 = 7; to RW-attribute 4 2 = 6; if the R-X property is 4 1 = 7. Example: chmod a = rwx file and chmod 777 FILE effect The same CHMOD UG = RWX, o = x file and chmod 771 file effects same If you use CHMOD 4755 FileName, this program has root permissions

Archive directory management - Cat

Name: Cat

Use permission: All users

How to use: cat [-abeensttuv] [--help] [--Version] FileName

Description: Connect the file to the basic output (screen or plus> filename to another)

parameter:

-n or --Number is numbered by 1st of all outputs

-b or --Number-nonblank and -n, but not numbered for blank lines

-S or - SQUEEZE-Blank When there is a blank line with two consecutive lines, it is changed to a row of blank lines.

-v or --show-nonprinting

example:

CAT -N TEXTFILE1> TextFile2 Enter the textFile2 file after adding the file content of TextFile1

CAT -B TEXTFILE1 TEXTFILE2 >> TEXTFILE3 adds the contents to TextFile 3 after adding the archive of TextFile1 and TextFile2.

example:

Enter the textfile2 file after adding the file content of TextFile1.

CAT-N TextFile1> TextFile2

Adding the contents of TextFile1 and TextFile2 plus the line number (blank line does not add) to TextFile 3.

CAT -B textFile1 TextFile2 >> TextFile3

CAT / dev / null> /etc/test.txt This is empty /etc/test.txt file content

Cat can also be used to make image file. For example, you want to make a soft disc's image file, put the floppy

CAT / dev / fd0> Outfile

Conversely, if you want to write image file to floppy disc, please

Cat img_file> / dev / fd0

Note:

1. Outfile refers to the output image file name.

2. IMG_FILE refers to image file.

3. If you write from Image File back DEVICE, the device capacity needs to be quite.

4. Usually used in the production of boot magnetic sheets.

DOS compatibility - MDELTREE

Name: MDELTREE

Use permission: All users

Use mode:

MDELTREE [-V] MSDOSDIRECTORY [MSDOSDIRECTORES ...]]

Note: This program can be used to delete the MSDOS format file and directory. MDELTREE will delete all files below the specified directory and directory. If the specified file or directory does not exist, the error message will be returned.

Parameters: -v Displays more messages. Example: McOPY A: MSDOSDIR. Delete the files below the MSDIR directory in the A slot magnel directory and the directory.

DOS compatibility - MLabel

Name: mlabel

Use permission: All users

Use mode:

MLabel [-VCS] Drive: [New_Label]

Description: This program can set the label of the disk (Label). If you set a label on the disk, MLabel will display him to the user. If you do not specify a new tag and do not specify a C or S option, MLabel prompts the user to enter a new label. If you press ENTER directly, you will delete the original label. Parameters: - More messages. -c Clear the original label without prompting messages. -s Displays the current label without prompting messages. Example: Mlabel A: NewLabel. Change the label of the A slot disk to NewLabel. DOS compatibility instructions - MDEL

Name: MDEL

Use permission: All users

Use mode:

MDEL [-V] MSDOSFILE [MSDoSfiles ...]

Description:

This program can be used to delete files in the MSDOS format.

There is a prompt message before removing the only file.

parameter:

-v Displays more messages.

example:

MDEL A: AutoExec.bat. Delete AutoExec.bat in the A slot magnel root directory.

DOS compatibility instructions - McOPY

Name: McOpy

Use permission: All users

Use mode:

Mcopy [-b / ptnvmoqossrra] SourceFile Targetfile

Mcopy [-b / ptnvmoqossrra] Sourcefile [SourceFiles ...] Targetdirectory

Mcopy [-tnvm] msdossourcefile

Description:

This program can be used to copy the MSDOS format file to Linux, or copy the MSDOS file from Linux to the magnetic sheet. McOPY can copy a single file to the specified file name, or copy several files to the specified directory. Source and destination files can be MSDOS or Linux files.

parameter:

b Batch mode. This is an optimized option for a large number of files, but when generating CRASH during the replication file, there is a security issue. / Post back. Contains files included in the directory and its under all subdirectories.

P Maintain the original properties of the file.

Q End the program as soon as the multiple file generates an error.

T Copy the plain text file. Convert Carrge Return / Line Feeds to Line Feeds.

N does not appear alert message when overwriting the Linux file.

o No warning message will appear when you override the MSDOS file.

m maintain the original modification time. When the purpose of the file already exists and uses the -n option, McOPY will ask if you want to overwrite or save the new file.

example:

.

DOS compatibility instruction - MCD

Name: MCD

Use permission: All users

Use mode:

MCD [MSDIRECTORY]

Description: You can change the MTools series instructions currently on the MSDOS disk. Unlike MSDOS's CD, MCD can also change work disc.

parameter:

There is no parameters to pass back the current working directory.

example:

MCD A: EMP Change Current Work Contents to A: EMP.

The MCD is passed back to the current working directory.

DOS compatibility command - Mattrib

Name: Mattrib

Use permission: All users

Use mode:

Mattrib [-A | A] [-H | H] [-r | R] [-S | S] [- /] [-x] MSDOSFILE [MSDoSFiles ...] Description: This program can be used Modify the properties of the MS_DOS file. parameter:

-A / A remove / set backup properties.

-H / H remove / set hidden properties.

-r / r Remove / sets the only attribute.

-S / S remove / set system properties.

- / The handup process contains files in all subdirectories.

-X outputs the result in a shorter format.

example:

MattriB A: Lists the properties of all files on the A slot MSDOS format magnetic sheet.

Mattrib -h -s -r A: Msdos.sys Removes the hidden, system and only-reading properties of the MSDOS.sys file on the A tank magnetic sheet.

Mattrib -r - / a: *. * Remove the only-reading properties of all files in the A-tank magnetic sheet containing subdirectory.

转载请注明原文地址:https://www.9cbs.com/read-84930.html

New Post(0)