Linux Directive Daquan (1)

xiaoxiao2021-03-17  216

Cat CD

Chmod chown

CP CUT

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 of TextFile1 and TextFile2 to TEXTFILE3

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 ../ ..

Directive Name: Chmod

Use permission: All users

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

Description: Linux / UNIX file access rights are divided into three levels: file owners, groups, others. Using CHMOD how to control the file is accessed by others.

Tie count:

Mode: Permissions Set strings, formats are as follows: [Ugoa ...] [[ - =] [RWXX] ...] [, ...], where u indicates the owner of the file, G represents The owner of the file belongs to the same group (group), o represents the other people, and 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 Sets 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;

To R-X attribute 4 1 = 7.

example:

CHMOD a = rwx file

with

CHMOD 777 File

Effect

CHMOD UG = RWX, o = X File

with

CHMOD 771 FILE

Effect

If you use CHMOD 4755 FileName, this program has root permissions

Directive Name: Chown

Use permission: root

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

: Linux / UNIX is multi-person multi-work industry, all files 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 authority to change the file owner of others, and there is no authority to be self-confidently file owner to others. Only the system administrator (root) has such permissions.

Tie count:

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 way) - Help: Display Auxiliary Description --Version: Display version

Example:

Set the owner of the file file1.txt to the User Group User Jessie:

Chown Jessie: Users file1.txt

Set all the files in the current directory with the owner of the subdirectories Lamport:

CHMOD -R LAMPORT: USERS *

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.

Put on

-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 to the finished subdirectory:

cp * .c finished

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 test1shell >> Cut -c0-6 example ## print counts the first 6 words

TEST2

THIS I

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 empty 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

Name: Less

Use permission: All users

Use mode:

Less [option] FileName

Description:

The role of Less is very similar to more, can be used to browse the content of the text file, the different is that the LESS allows the user to go back

To browse some parties that have been seen, because LES is not entered into the entire file at the beginning, it will be fast than the general instrument editor (such as vi) when encountering a large file.

example:

Directive Name: LN

Use permission: All users

How to use: 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 and soft links, Hard connection means that a file can have multiple names, while the soft connection is to generate a special file, which is the location of another file. Hard links are in the same archive system, while soft links can span different file 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.

-f: The file will first delete the file with the DIST: Allow the system administrator hard link to your directory -i: When deleting the file with the DIST, I'm inquiry -N: On When the soft link, the Dist is treated as a general file-S: Symbolic link -V: The file name is displayed before the connection - B: Backup of files that will overwrite or deleted during the link - S Suffix: Plus backup files with SUFFIX's word-V Method: Specify the way backup - HELP: Display auxiliary instructions --Version: Display version

Example:

Generate a Symbolic Link: ZZ with the file yy

Ln -s yy zz

Generate a Hard Link: ZZ with the file yy

ln yy xx

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 go deep 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. parameter:

-u

-U

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

-e

will

Exclude outside 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

Except for a specific archive system, for example, we have not reached the tool 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

Specifies the name of the information inventory.

-d

Specify the path to the database

-H

Display auxiliary message

-V

Show more messages

-V

Display program version message example:

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: Establish a database

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). -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

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 Tips, display [Press Space to Continue, Q to Quit.] below the screen, if the user presses the wrong button, [Press H for instructions.] is displayed instead of beep.

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

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

Name: RM

Use permission: All users

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

Description: Delete files and directories.

Put on

-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 program files; ask one by one before deleting confirmation:

Rm -i * .c

Delete all files in the Finished subdirectory and subdirectory:

RM -R finished

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

Name: split

Use permission: All users

How to use: split [option] [INPUT [prefix]]

Description:

Split a file into several files. From the INPUT division output into a fixed-size file, its file name is prefixaa, prefixab ...; prefix preset value `x. If there is no input file or `-, you will be read from the standard input.

匡 兜 

-b, --Bytes = Size

The size value is the size of each output file, and the unit is BYTE.

-C, --Line-bytes = size

In each output, the maximum number of BYTEs in a single line.

-L, --Lines = Number

The Number value is the size of the column size of each output.

-Number

The same as -l Number.

--Verbose

Print the detection information to standard error output before each output file is opened.

--help

Display auxiliary information and then leave.

--Version

Listed by this information and then leave.

Size can join the unit: b represents 512, K represents 1k, M represents 1 meg.

example:

Postgressql Large Data Library Backup and Recycling:

Because Postgres allows the form to have a largest capacity of your system file, it is possible to have problems with table dump to a single file, and Split is used to divide.

% PG_Dump DBNAME | SPLIT -B 1M - FileName.dump.

Reload

% CreatedB DBName

% cat filename.dump. * | PGSQL DBNAME

Name: Touch

Use permission: All users

Use mode:

Touch [-ACFM]

[-r reference-file] [--file = reason "File]

[-t mmddhhmm [[cc] yy] [. ss]]

[-d Time] [--DATE = TIME] [--Time = {Atime, Access, Use, Mtime, Modify}]

[--NO-CREATE] [--HELP] [--Version] file1 [file2 ...]

Description:

Touch command changes the time record of the file. LS -L can display the time record of the file.

parameter:

a Changing the read time record of the file.

m change the modification time record of the file.

C If the purpose file does not exist, it will not establish a new file. Like -No-Create.

F is not used, is to retain to compatibility with other UNIX systems.

r Use the reference file time record, like the effect of thefile.

D Setting time and date, you can use a variety of different formats.

T Time Record of the file is set, the format is the same as the DATE instruction.

--NO-CREATE does not establish a new file.

--Help lists the instruction format.

--Version lists this message.

example:

The simplest way of use, change the file when you record the time. If the file does not exist, a new file will be established.

Touch file

TOUCH file1 file2

Change the time record of File to 18:3:39 on May 6, 2,000 years. Time format can refer to the Date directive, at least you need to enter MMDDHHMM, which is the time of months and minutes.

Touch -c -t 05061803 file

Touch -c -t 050618032000 file

Change the File time record into ReferenceFile.

Touch -R ReferenceFile File

The time record of File is changed to 18:3:36 on May 6, two thousand years old. Time can be used in AM, PM or 24-hour format, and other formats can be used in other formats such as 6 May 2000.

Touch -d "6:03 pm" file

Touch -d "05/06/2000" File

Touch -d "6:03 PM 05/06/2000" File

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

New Post(0)