Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux instruction Collection

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "Linux instruction Daquan". In daily operation, I believe many people have doubts about Linux instruction Daquan. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "Linux instruction Daquan". Next, please follow the editor to study!

Name: cat

Permissions: all users

Usage: cat [- AbeEnstTuv] [--help] [--version] fileName

Description: connect the file string to the basic output (screen or add > fileName to another file)

Parameters:

-n or-- number numbers all output lines starting with 1

-b or-- number-nonblank is similar to-n, except that blank lines are not numbered

When-s or-- squeeze-blank encounters blank lines with more than two consecutive lines, replace them with blank lines of one line

-v or-- show-nonprinting

Example:

Cat-n textfile1 > textfile2 enter the contents of the textfile1 file with a line number into the textfile2 file

Cat-b textfile1 textfile2 > > textfile3 appends the contents of textfile1 and textfile2 files to textfile3 after adding line numbers (blank lines are not added)

Name: cd

Permissions: all users

Usage: cd [dirName]

Description: change the working directory to dirName. The dirName representation can be an absolute path or a relative path. If the directory name is omitted, change to the user's home directory (that is, the directory where the login was just located).

In addition, "~" also means "home directory." Indicates the directory in which it is currently located, ".." Represents the directory above the current directory location.

Example: skip to / usr/bin/:

Cd / usr/bin

Jump to your own home directory:

Cd ~

Skip to the top two layers of the current directory:

Cd.. /..

Instruction name: chmod

Permissions: all users

Usage: chmod [- cfvR] [--help] [--version] mode file...

Description: the file access authority of Linux/Unix is divided into three levels: file owner, group and others. Chmod can be used to control how files are accessed by others.

Set up a plan:

Mode: permission setting string, in the following format: [ugoa...] [[+-=] [rwxX]...] [,...], where u indicates the owner of the file, g indicates that the owner belongs to the same group (group) as the owner of the file, o indicates other people, and an indicates all three.

+ means to increase permissions,-to cancel permissions, and = to set permissions uniquely.

R indicates readable, w indicates writable, x indicates executable, and X indicates only if the file is a subdirectory or if the file has been set to executable.

-c: if the permission of the file has indeed been changed, the change action will be displayed.

-f: do not display an error message if the file permissions cannot be changed

-v: displays the details of permission changes

-R: make the same permission changes for all files in the current directory as well as subdirectories (that is, change them one by one recursively)

-- help: displays auxiliary instructions

-- version: display version

Example: set the file file1.txt to be accessible to everyone:

Chmod ugo+r file1.txt

Set the file file1.txt to be accessible to everyone:

Chmod Aguilr file1.txt

Set the file file1.txt and file2.txt as the owner of the file, which can be written by those who belong to the same group, but not by others:

Chmod ug+w,o-w file1.txt file2.txt

Set ex1.py to be executed only by the owner of the file:

Chmod upright x ex1.py

Make all files and subdirectories in the current directory readable by anyone:

Chmod-R aquir *

In addition, chmod can also use numbers to represent permissions, such as chmod 777 file

Syntax is: chmod abc file

There is a number for User, Group, and Other respectively.

Renew4, want2, 2, 3, 1, 2, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4

If you want the rwx property, then 4, 2, 1, 7.

If you want the rw- property, then 4 / 2 / 6

If you want the rmurx attribute, then 4, 1, 7.

Example:

Chmod a=rwx file

And

Chmod 777 file

The effect is the same

Chmod ug=rwx,o=x file

And

Chmod 771 file

The effect is the same

If you use chmod 4755 filename, you can make this program have the permission of root

Instruction name: chown

Permission: root

Usage: chmod [- cfhvR] [--help] [--version] user [: group] file...

Description: Linux/Unix is a multi-person multi-work system, all files have owners. With chown, the owner of the file can be changed. Generally speaking, this directive is only used by the system administrator (root). The average user does not have the permission to change someone else's file owner, nor does he have the permission to change his own file owner to someone else. Only the system administrator (root) has such permissions.

Set up a plan:

User: the user of the new file owner IDgroup: the user group of the new file owner (group)-c: show the change action only if the file owner has indeed changed-f: do not display an error message if the file owner cannot be changed-h: change only for the link Instead of the file that the link really points to-v: shows the details of the owner's changes-R: make the same owner changes to all files and subdirectories in the current directory (that is, change them one by one by recursion)-- help: display auxiliary instructions-- version: display version

Example:

Set the owner of the file file1.txt as the user jessie of the users community:

Chown jessie:users file1.txt

Set the owner of all files and subdirectories under the current directory to the user lamport of the users group:

Chmod-R lamport:users *

Name: cp

Permissions: all users

Mode of use:

Cp [options] source dest

Cp [options] source... Directory

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

Count 

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

-r if the directory name is included in the source, all the files in the directory will be copied to the destination in order.

-f if a file with the same file name already exists at the destination, delete it before copying it.

Example:

Copy the archive aaa (already exists) and name it bbb:

Cp aaa bbb

Copy all C programs to the Finished subdirectory:

Cp * .c Finished

Name: cut

Permissions: all users

Usage: cut-cnum1-num2 filename

Description: displays the text of each line from num1 to num2 from the beginning.

Example:

Shell > > cat example

Test2

This is test1

Shell > > cut-c0-6 example # # print starts with the first six characters

Test2

This i

Name: find

Usage: find

Instructions for use:

List the expression-compliant files in the file system. You can refer to the combination of different information such as the name, category, time, size, permission, and so on, of the file you want. Only those that match exactly will be listed.

Find judges path and expression according to the following rules, the first-(), on the command line! The first part is path, followed by expression. The current path is used if path is an empty string, and-print is used as the default expression  if expression is an empty string

There are as many as 20 or 30 options available in expression, and only the most commonly used ones are introduced here.

-mount,-xdev: only check and specify files under the same file system to avoid listing files in other file systems.

-amin n: read in the past n minutes

-anewer file: files that have been read later than the file file

-atime n: read files in the past n days

-cmin n: modified in the past n minutes

-cnewer file: files that are newer than file file

-ctime n: modified files in the past n days

-empty: empty file-gid n or-group name: is gid n or group name name

-ipath p,-path p: files whose path names match p. Ipath ignores case.

-name name,-iname name: files whose names match name. Iname ignores case

-size n: the file size is n units, b represents a block of 512 bytes, c represents the number of characters, and k indicates that kilo bytes,w is two bytes. -type c: files of type c.

D: directory

C: font device file

B: block device file

P: named storage column

F: general archives

L: symbolic link

S: socket

-pid n: process id is the file of n

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

Exp1-and exp2

! Expr

-not expr

Exp1-or exp2

Exp1, exp2

Example:

List all files with the extension name c in the current directory and its subdirectories.

# find. -name "* .c"

List all general files in its subdirectories of the current directory

# find. -ftype f

List all files that have been updated in the last 20 minutes under the current directory and its subdirectories

# find. -ctime-20

Name: less

Permissions: all users

Mode of use:

Less [Option] filename

Description:

The function of less is very similar to that of more, which can be used to browse the contents of text files, except that less allows users to scroll back

To browse the parts you have already seen, and because less does not read the entire file in the first place, it will be faster than ordinary document editors (such as vi) when opening large files.

Example:

Instruction name: ln

Permissions: all users

Usage: ln [options] source dist, where the format of option is:

[- bdfinsvF] [- S backup-suffix] [- V {numbered,existing,simple}]

[- help] [--version] [- -]

Description: Linux/Unix file system, there are so-called link (link), we can regard it as an alias for the file, and links can be divided into two types: hard link (hard link) and soft link (symbolic link), hard link means that a file can have multiple names, while the way of soft link is to generate a special file, the content of the file points to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.

Ln source dist generates a dist to source, while the use of hard or soft links is determined by parameters.

Neither hard link nor soft link will make a copy of the original file and will only take up a very small amount of disk space.

-f: delete files with the same name as dist when linking-d: allow system administrators to hard-link their own directories-I: ask before deleting files with the same name as dist-n: when soft links are made Think of dist as a general file-s: soft link (symbolic link)-v: show its file name before the link-b: back up the files that will be overwritten or deleted at the time of the link-S SUFFIX: add the suffix SUFFIX-V METHOD: specify the backup method-help: display auxiliary instructions-version: display version

Example:

Generate a symbolic link: zz from the file yy

Ln-s yy zz

Generate a hard link: zz from the file yy

Ln yy xx

Name: locate

Permissions: all users

Usage: locate [- Q] [- d] [--database=]

Locate [- r] [--regexp=]

Locate [- qv] [- o] [--output=]

Locate [- e] [- f]

Locate [- Vh] [--version] [--help]

Description:

Locate allows users to quickly search for specified files in the file system. The method is to first create a database that includes all the file names and paths in the system, and then when looking for it, you only need to query the database without actually going deep into the file system.

In a general distribution, the creation of a database is automatically performed in contab. Ordinary users only need to use

# locate your_file_name

The style will be fine. Parameters:

-u

-U

To create a database,-u starts from the root directory, and-U can specify where to start.

-e

Set

Excluded from the scope of the search.

-l

If it is 1. Then start safe mode. In safe mode, users do not see files that cannot be seen by permissions. This starts to slow down because locate must go to the actual file system to obtain file permission data.

-f

Exclude specific file systems, for example, we are not reasonable to put the files in the proc file system in the database.

-Q

Quiet mode does not display any error messages.

-n

Display at most one output.

-r

Use the regular expression to do the search condition.

-o

Specifies the name of the data inventory.

-d

Specify the path to the database

-h

Display auxiliary messages

-v

Show more information

-V

Show an example of the version message of the program:

Locate chdrv: find all the files called chdrv

Locate-n 100 a.out: find all files called a.out, but only show a maximum of 100

Locate-u: build a database

Name: ls

Permissions: all users

Usage: ls [- alrtAFR] [name...]

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

-a displays all files and directories (ls internally starts the file name or directory name with "." As a hidden file and will not be listed)

-l in addition to the file name, the file type, permissions, owner, file size and other information are also listed in detail.

-r display the files in reverse order (originally in alphabetical order)

-t list the files in the order of their establishment

-An is the same as-a, but not listed "." (current catalogue) and ".." (parent directory)

-F add a symbol to the listed file name; for example, the executable file adds "*" and the directory adds "/"

-R if there are files in the directory, the following files are also listed in sequence.

Example:

List all files whose names begin with s in the current working directory, and the newer files will be excluded later:

Ls-ltr s*

List all the following directories and file details in the / bin directory:

Ls-lR / bin

List all files and directories under the current working directory; add "/" to the name of the directory, and "*" after the name:

Ls-AF

Name: more

Permissions: all users

Usage: more [- dlfpcsu] [- num] [+ / pattern] [+ linenum] [fileNames..]

Description: similar to cat, but will be page by page display to facilitate users to read, and the most basic instruction is to press the blank key (space) to the next page display, press the b key will go back to (back) a page display, and there is a search string function (similar to vi), in use of the description document, please press h.

Parameter:-number of rows displayed by num at a time

-d prompt the user to display [Press space to continue, q to quit.] at the bottom of the screen. If the user presses the wrong key, it will display [Press h for instructions.] Not the beep.

-l cancel the function that will be paused when a special character ^ L (feed character) is encountered

-f when calculating the number of lines, it is based on the actual number of lines, not the number of lines after the automatic line wrap (some lines that are too long will be expanded to two or more lines)

-p does not display each page as a scroll, but clears the screen before displaying the content

-c is similar to-p, except that the content is displayed first and then other old materials are cleared.

-s when you encounter more than two consecutive blank lines, replace them with blank lines of one line

-u does not show lower quotation marks (depending on the terminal specified by the environment variable TERM)

+ / search for the string (pattern) before each file is displayed, and then display it after the string

+ num displays from line num

The files that fileNames wants to display can be plural.

Example:

More-s testfile displays the contents of the testfile file page by page. If there are two consecutive lines with white lines above, it will be displayed as a blank line.

More + 20 testfile displays the contents of the testfile file starting at line 20.

Name: mv

Permissions: all users

Mode of use:

Mv [options] source dest

Mv [options] source... Directory

Description: move one file to another, or move several files to another directory.

Parameter:-I if the destination already has a file with the same name, ask whether to overwrite the old file first.

Example:

Rename the archive aaa to bbb:

Mv aaa bbb

Move all C programs to the Finished subdirectory:

Mv-I * .c

Name: rm

Permissions: all users

Usage: rm [options] name...

Description: delete files and directories.

Count 

-I ask for confirmation one by one before deletion.

-f even if the original file attribute is set to read-only, it will be deleted directly without confirmation one by one.

-r delete the directory and the following files one by one.

Example:

Delete all C program files; ask for confirmation one by one before deletion:

Rm-I * .c

Delete the Finished subdirectory and all files in the subdirectory:

Rm-r Finished

Name: rmdir

Permissions: all users with appropriate permissions in the current directory

Usage: rmdir [- p] dirName

Description: delete empty directories.

Parameter:-p is deleted if the subdirectory is also empty after it is deleted.

Example:

Delete the subdirectory named AAA under the working directory:

Rmdir AAA

In the BBB directory under the working directory, delete the subdirectory named Test. If the BBB directory becomes empty after the Test is deleted, the BBB will also be deleted.

Rmdir-p BBB/Test

Name: split

Permissions: all users

Usage: split [OPTION] [INPUT [PREFIX]]

Description:

Divide a file into several. On the other hand, the file is split from INPUT to a fixed-size file whose name is PREFIXaa and the default value of PREFIXab...;PREFIX is `x. If there is no INPUT file or `-, the data is read from the standard input.

Kuang Dou 

-b,-- bytes=SIZE

The SIZE value is the size of each output file, in byte.

-C,-- line-bytes=SIZE

The maximum number of byte per line in each output file.

-l,-- lines=NUMBER

The NUMBER value is the number of columns per output file.

-NUMBER

Same as-l NUMBER.

-- verbose

Before each output file is opened, the debugging information is printed to the standard error output.

-- help

Display auxiliary information and leave.

-- version

List the version information and leave.

SIZE can be added to the unit: B for 512, k for 1K, m for 1 Meg.

Example:

Backup and save back of PostgresSQL large database:

Because Postgres allows forms to be larger than the maximum capacity of your system files, it may be problematic to dump forms to a single file. Use split for file segmentation.

% pg_dump dbname | split-b 1m-filename.dump.

Reload

% createdb dbname

% cat filename.dump.* | pgsql dbname

Name: touch

Permissions: all users

Mode of use:

Touch [- acfm]

[- r reference-file] [--file=reference-file]

[- t MMDDhhmm [[CC] YY] [.ss]]

[- d time] [--date=time] [--time= {atime,access,use,mtime,modify}]

[--no-create] [--help] [--version]

File1 [file2...]

Description:

The touch instruction changes the time record of the file. Ls-l can display the time record of the archive.

Parameters:

A change the reading time record of the file.

M change the modification time record of the file.

C if the destination file does not exist, no new file will be created. It has the same effect as-- no-create.

F is not used and is reserved for compatibility with other unix systems.

R use the time record of the reference file, which is the same as-- file.

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

T sets the time record of the file in the same format as the date instruction.

-- no-create will not create new files.

-- help lists instruction formats.

-- version lists version messages.

Example:

The easiest way to use it is to change the record of the file to the current time. If the file does not exist, the system will create a new file.

Touch file

Touch file1 file2

The time record of file was changed to 18:03 on May 6, AD 2000. The format of time can refer to the date instruction, at least enter MMDDHHmm, that is, the day of the month, hours and minutes.

Touch-c-t 05061803 file

Touch-c-t 050618032000 file

Change the time record of file to the same as referencefile.

Touch-r referencefile file

Change the time record of file to 18:03 on May 6th, AD 2000. The time can be in am, pm or 24-hour format, and the date can be in another format such as 6 May 2000.

Touch-d "6:03pm" file

Touch-d "05Compact 06ax 2000" file

Touch-d "6:03pm 05amp 06ax 2000" file

A complete Collection of Linux instructions (1)

Cat cd

Chmod chown

Cp cut

Name: cat

Permissions: all users

Usage: cat [- AbeEnstTuv] [--help] [--version] fileName

Description: connect the file string to the basic output (screen or add > fileName to another file)

Parameters:

-n or-- number numbers all output lines starting with 1

-b or-- number-nonblank is similar to-n, except that blank lines are not numbered

When-s or-- squeeze-blank encounters blank lines with more than two consecutive lines, replace them with blank lines of one line

-v or-- show-nonprinting

Example:

Cat-n textfile1 > textfile2 enter the contents of the textfile1 file with a line number into the textfile2 file

Cat-b textfile1 textfile2 > > textfile3 appends the contents of textfile1 and textfile2 files to textfile3 after adding line numbers (blank lines are not added)

Name: cd

Permissions: all users

Usage: cd [dirName]

Description: change the working directory to dirName. The dirName representation can be an absolute path or a relative path. If the directory name is omitted, change to the user's home directory (that is, the directory where the login was just located).

In addition, "~" also means "home directory." Indicates the directory in which it is currently located, ".." Represents the directory above the current directory location.

Example: skip to / usr/bin/:

Cd / usr/bin

Jump to your own home directory:

Cd ~

Skip to the top two layers of the current directory:

Cd.. /..

Instruction name: chmod

Permissions: all users

Usage: chmod [- cfvR] [--help] [--version] mode file...

Description: the file access authority of Linux/Unix is divided into three levels: file owner, group and others. Chmod can be used to control how files are accessed by others.

Set up a plan:

Mode: permission setting string, in the following format: [ugoa...] [[+-=] [rwxX]...] [,...], where u indicates the owner of the file, g indicates that the owner belongs to the same group (group) as the owner of the file, o indicates other people, and an indicates all three.

+ means to increase permissions,-to cancel permissions, and = to set permissions uniquely.

R indicates readable, w indicates writable, x indicates executable, and X indicates only if the file is a subdirectory or if the file has been set to executable.

-c: if the permission of the file has indeed been changed, the change action will be displayed.

-f: do not display an error message if the file permissions cannot be changed

-v: displays the details of permission changes

-R: make the same permission changes for all files in the current directory as well as subdirectories (that is, change them one by one recursively)

-- help: displays auxiliary instructions

-- version: display version

Example: set the file file1.txt to be accessible to everyone:

Chmod ugo+r file1.txt

Set the file file1.txt to be accessible to everyone:

Chmod Aguilr file1.txt

Set the file file1.txt and file2.txt as the owner of the file, which can be written by those who belong to the same group, but not by others:

Chmod ug+w,o-w file1.txt file2.txt

Set ex1.py to be executed only by the owner of the file:

Chmod upright x ex1.py

Make all files and subdirectories in the current directory readable by anyone:

Chmod-R aquir *

In addition, chmod can also use numbers to represent permissions, such as chmod 777 file

Syntax is: chmod abc file

There is a number for User, Group, and Other respectively.

Renew4, want2, 2, 3, 1, 2, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4

If you want the rwx property, then 4, 2, 1, 7.

If you want the rw- property, then 4 / 2 / 6

If you want the rmurx attribute, then 4, 1, 7.

Example:

Chmod a=rwx file

And

Chmod 777 file

The effect is the same

Chmod ug=rwx,o=x file

And

Chmod 771 file

The effect is the same

If you use chmod 4755 filename, you can make this program have the permission of root

Instruction name: chown

Permission: root

Usage: chmod [- cfhvR] [--help] [--version] user [: group] file...

Description: Linux/Unix is a multi-person multi-work system, all files have owners. With chown, the owner of the file can be changed. Generally speaking, this directive is only used by the system administrator (root). The average user does not have the permission to change someone else's file owner, nor does he have the permission to change his own file owner to someone else. Only the system administrator (root) has such permissions.

Set up a plan:

User: the user of the new file owner IDgroup: the user group of the new file owner (group)-c: show the change action only if the file owner has indeed changed-f: do not display an error message if the file owner cannot be changed-h: change only for the link Instead of the file that the link really points to-v: shows the details of the owner's changes-R: make the same owner changes to all files and subdirectories in the current directory (that is, change them one by one by recursion)-- help: display auxiliary instructions-- version: display version

Example:

Set the owner of the file file1.txt as the user jessie of the users community:

Chown jessie:users file1.txt

Set the owner of all files and subdirectories under the current directory to the user lamport of the users group:

Chmod-R lamport:users *

Name: cp

Permissions: all users

Mode of use:

Cp [options] source dest

Cp [options] source... Directory

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

Count 

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

-r if the directory name is included in the source, all the files in the directory will be copied to the destination in order.

-f if a file with the same file name already exists at the destination, delete it before copying it.

Example:

Copy the archive aaa (already exists) and name it bbb:

Cp aaa bbb

Copy all C programs to the Finished subdirectory:

Cp * .c Finished

Name: cut

Permissions: all users

Usage: cut-cnum1-num2 filename

Description: displays the text of each line from num1 to num2 from the beginning.

Example:

Shell > > cat example

Test2

This is test1

Shell > > cut-c0-6 example # # print starts with the first six characters

Test2

This i

Name: find

Usage: find

Instructions for use:

List the expression-compliant files in the file system. You can refer to the combination of different information such as the name, category, time, size, permission, and so on, of the file you want. Only those that match exactly will be listed.

Find judges path and expression according to the following rules, the first-(), on the command line! The first part is path, followed by expression. The current path is used if path is an empty string, and-print is used as the default expression  if expression is an empty string

There are as many as 20 or 30 options available in expression, and only the most commonly used ones are introduced here.

-mount,-xdev: only check and specify files under the same file system to avoid listing files in other file systems.

-amin n: read in the past n minutes

-anewer file: files that have been read later than the file file

-atime n: read files in the past n days

-cmin n: modified in the past n minutes

-cnewer file: files that are newer than file file

-ctime n: modified files in the past n days

-empty: empty file-gid n or-group name: is gid n or group name name

-ipath p,-path p: files whose path names match p. Ipath ignores case.

-name name,-iname name: files whose names match name. Iname ignores case

-size n: the file size is n units, b represents a block of 512 bytes, c represents the number of characters, and k indicates that kilo bytes,w is two bytes. -type c: files of type c.

D: directory

C: font device file

B: block device file

P: named storage column

F: general archives

L: symbolic link

S: socket

-pid n: process id is the file of n

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

Exp1-and exp2

! Expr

-not expr

Exp1-or exp2

Exp1, exp2

Example:

List all files with the extension name c in the current directory and its subdirectories.

# find. -name "* .c"

List all general files in its subdirectories of the current directory

# find. -ftype f

List all files that have been updated in the last 20 minutes under the current directory and its subdirectories

# find. -ctime-20

Name: less

Permissions: all users

Mode of use:

Less [Option] filename

Description:

The function of less is very similar to that of more, which can be used to browse the contents of text files, except that less allows users to scroll back

To browse the parts you have already seen, and because less does not read the entire file in the first place, it will be faster than ordinary document editors (such as vi) when opening large files.

Example:

Instruction name: ln

Permissions: all users

Usage: ln [options] source dist, where the format of option is:

[- bdfinsvF] [- S backup-suffix] [- V {numbered,existing,simple}]

[- help] [--version] [- -]

Description: Linux/Unix file system, there are so-called link (link), we can regard it as an alias for the file, and links can be divided into two types: hard link (hard link) and soft link (symbolic link), hard link means that a file can have multiple names, while the way of soft link is to generate a special file, the content of the file points to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.

Ln source dist generates a dist to source, while the use of hard or soft links is determined by parameters.

Neither hard link nor soft link will make a copy of the original file and will only take up a very small amount of disk space.

-f: delete files with the same name as dist when linking-d: allow system administrators to hard-link their own directories-I: ask before deleting files with the same name as dist-n: when soft links are made Think of dist as a general file-s: soft link (symbolic link)-v: show its file name before the link-b: back up the files that will be overwritten or deleted at the time of the link-S SUFFIX: add the suffix SUFFIX-V METHOD: specify the backup method-help: display auxiliary instructions-version: display version

Example:

Generate a symbolic link: zz from the file yy

Ln-s yy zz

Generate a hard link: zz from the file yy

Ln yy xx

Name: locate

Permissions: all users

Usage: locate [- Q] [- d] [--database=]

Locate [- r] [--regexp=]

Locate [- qv] [- o] [--output=]

Locate [- e] [- f]

Locate [- Vh] [--version] [--help]

Description:

Locate allows users to quickly search for specified files in the file system. The method is to first create a database that includes all the file names and paths in the system, and then when looking for it, you only need to query the database without actually going deep into the file system.

In a general distribution, the creation of a database is automatically performed in contab. Ordinary users only need to use

# locate your_file_name

The style will be fine. Parameters:

-u

-U

To create a database,-u starts from the root directory, and-U can specify where to start.

-e

Set

Excluded from the scope of the search.

-l

If it is 1. Then start safe mode. In safe mode, users do not see files that cannot be seen by permissions. This starts to slow down because locate must go to the actual file system to obtain file permission data.

-f

Exclude specific file systems, for example, we are not reasonable to put the files in the proc file system in the database.

-Q

Quiet mode does not display any error messages.

-n

Display at most one output.

-r

Use the regular expression to do the search condition.

-o

Specifies the name of the data inventory.

-d

Specify the path to the database

-h

Display auxiliary messages

-v

Show more information

-V

Show an example of the version message of the program:

Locate chdrv: find all the files called chdrv

Locate-n 100 a.out: find all files called a.out, but only show a maximum of 100

Locate-u: build a database

Name: ls

Permissions: all users

Usage: ls [- alrtAFR] [name...]

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

-a displays all files and directories (ls internally starts the file name or directory name with "." As a hidden file and will not be listed)

-l in addition to the file name, the file type, permissions, owner, file size and other information are also listed in detail.

-r display the files in reverse order (originally in alphabetical order)

-t list the files in the order of their establishment

-An is the same as-a, but not listed "." (current catalogue) and ".." (parent directory)

-F add a symbol to the listed file name; for example, the executable file adds "*" and the directory adds "/"

-R if there are files in the directory, the following files are also listed in sequence.

Example:

List all files whose names begin with s in the current working directory, and the newer files will be excluded later:

Ls-ltr s*

List all the following directories and file details in the / bin directory:

Ls-lR / bin

List all files and directories under the current working directory; add "/" to the name of the directory, and "*" after the name:

Ls-AF

Name: more

Permissions: all users

Usage: more [- dlfpcsu] [- num] [+ / pattern] [+ linenum] [fileNames..]

Description: similar to cat, but will be page by page display to facilitate users to read, and the most basic instruction is to press the blank key (space) to the next page display, press the b key will go back to (back) a page display, and there is a search string function (similar to vi), in use of the description document, please press h.

Parameter:-number of rows displayed by num at a time

-d prompt the user to display [Press space to continue, q to quit.] at the bottom of the screen. If the user presses the wrong key, it will display [Press h for instructions.] Not the beep.

-l cancel the function that will be paused when a special character ^ L (feed character) is encountered

-f when calculating the number of lines, it is based on the actual number of lines, not the number of lines after the automatic line wrap (some lines that are too long will be expanded to two or more lines)

-p does not display each page as a scroll, but clears the screen before displaying the content

-c is similar to-p, except that the content is displayed first and then other old materials are cleared.

-s when you encounter more than two consecutive blank lines, replace them with blank lines of one line

-u does not show lower quotation marks (depending on the terminal specified by the environment variable TERM)

+ / search for the string (pattern) before each file is displayed, and then display it after the string

+ num displays from line num

The files that fileNames wants to display can be plural.

Example:

More-s testfile displays the contents of the testfile file page by page. If there are two consecutive lines with white lines above, it will be displayed as a blank line.

More + 20 testfile displays the contents of the testfile file starting at line 20.

Name: mv

Permissions: all users

Mode of use:

Mv [options] source dest

Mv [options] source... Directory

Description: move one file to another, or move several files to another directory.

Parameter:-I if the destination already has a file with the same name, ask whether to overwrite the old file first.

Example:

Rename the archive aaa to bbb:

Mv aaa bbb

Move all C programs to the Finished subdirectory:

Mv-I * .c

Name: rm

Permissions: all users

Usage: rm [options] name...

Description: delete files and directories.

Count 

-I ask for confirmation one by one before deletion.

-f even if the original file attribute is set to read-only, it will be deleted directly without confirmation one by one.

-r delete the directory and the following files one by one.

Example:

Delete all C program files; ask for confirmation one by one before deletion:

Rm-I * .c

Delete the Finished subdirectory and all files in the subdirectory:

Rm-r Finished

Name: rmdir

Permissions: all users with appropriate permissions in the current directory

Usage: rmdir [- p] dirName

Description: delete empty directories.

Parameter:-p is deleted if the subdirectory is also empty after it is deleted.

Example:

Delete the subdirectory named AAA under the working directory:

Rmdir AAA

In the BBB directory under the working directory, delete the subdirectory named Test. If the BBB directory becomes empty after the Test is deleted, the BBB will also be deleted.

Rmdir-p BBB/Test

Name: split

Permissions: all users

Usage: split [OPTION] [INPUT [PREFIX]]

Description:

Divide a file into several. On the other hand, the file is split from INPUT to a fixed-size file whose name is PREFIXaa and the default value of PREFIXab...;PREFIX is `x. If there is no INPUT file or `-, the data is read from the standard input.

Kuang Dou 

-b,-- bytes=SIZE

The SIZE value is the size of each output file, in byte.

-C,-- line-bytes=SIZE

The maximum number of byte per line in each output file.

-l,-- lines=NUMBER

The NUMBER value is the number of columns per output file.

-NUMBER

Same as-l NUMBER.

-- verbose

Before each output file is opened, the debugging information is printed to the standard error output.

-- help

Display auxiliary information and leave.

-- version

List the version information and leave.

SIZE can be added to the unit: B for 512, k for 1K, m for 1 Meg.

Example:

Backup and save back of PostgresSQL large database:

Because Postgres allows forms to be larger than the maximum capacity of your system files, it may be problematic to dump forms to a single file. Use split for file segmentation.

% pg_dump dbname | split-b 1m-filename.dump.

Reload

% createdb dbname

% cat filename.dump.* | pgsql dbname

Name: touch

Permissions: all users

Mode of use:

Touch [- acfm]

[- r reference-file] [--file=reference-file]

[- t MMDDhhmm [[CC] YY] [.ss]]

[- d time] [--date=time] [--time= {atime,access,use,mtime,modify}]

[--no-create] [--help] [--version]

File1 [file2...]

Description:

The touch instruction changes the time record of the file. Ls-l can display the time record of the archive.

Parameters:

A change the reading time record of the file.

M change the modification time record of the file.

C if the destination file does not exist, no new file will be created. It has the same effect as-- no-create.

F is not used and is reserved for compatibility with other unix systems.

R use the time record of the reference file, which is the same as-- file.

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

T sets the time record of the file in the same format as the date instruction.

-- no-create will not create new files.

-- help lists instruction formats.

-- version lists version messages.

Example:

The easiest way to use it is to change the record of the file to the current time. If the file does not exist, the system will create a new file.

Touch file

Touch file1 file2

The time record of file was changed to 18:03 on May 6, AD 2000. The format of time can refer to the date instruction, at least enter MMDDHHmm, that is, the day of the month, hours and minutes.

Touch-c-t 05061803 file

Touch-c-t 050618032000 file

Change the time record of file to the same as referencefile.

Touch-r referencefile file

Change the time record of file to 18:03 on May 6th, AD 2000. The time can be in am, pm or 24-hour format, and the date can be in another format such as 6 May 2000.

Touch-d "6:03pm" file

Touch-d "05Compact 06ax 2000" file

Touch-d "6:03pm 05amp 06ax 2000" file "

A complete Collection of Linux instructions (2)

Name: at

Permissions: all users

Usage: at-V [- Q queue] [- f file] [- mldbv] TIME

Description: at allows users to specify the execution of a program or instruction at this specific time of TIME. The format of TIME is HH:MM, where HH is hour and MM is minute. You can even specify colloquial words such as am, pm, midnight, noon, teatime (that is, 4: 00 p.m.).

If you want to specify more than a day, you can use the format of MMDDYY or MM/DD/YY, where MM is the minute, DD is the day, and YY is the year. In addition, users can even use intervals such as now + to flexibly specify time, where the interval can be minutes, hours, days, weeks 

In addition, the user can also specify today or tomorrow to represent today or tomorrow. When the time is specified and enter is pressed, at will enter chat mode and ask for instructions or programs. When you have finished typing, press ctrl+D to complete all actions, and the results of the execution will be sent back to your account.

Set up a plan:

-V: print the version number

-Q: use the specified Queue to store the at data in the so-called queue. Users can use multiple queue at the same time, and the queue numbers are a, b, c. Z and A, B,. A total of 52 Z

-m: send a letter to the user even if there is no output after the execution of the program / instruction

-f file: read in the pre-written command file. Users do not have to use conversation mode to enter, they can first write all the assignments to the file and then read them again.

-l: list all the assignments (users can also use atq directly instead of at-l)

-d: delete the assignment (users can also use atrm directly instead of at-d)

-v: lists all assignments that have been completed but not yet deleted

Example:

Execute at 5: 00 p.m. Three days later / bin/ls:

At 5pm + 3 days / bin/ls

Execute at 5: 00 p.m. Three weeks later / bin/ls:

At 5pm + 2 weeks / bin/ls

Tomorrow's 17:20 execution / bin/date:

At 17:20 tomorrow / bin/date

Print the end of world at the last minute of the last day of 1999!

At 23:59 12/31/1999 echo the end of world!

Name: cal

Permissions: all users

Usage: cal [- mjy] [month [year]]

Description:

Displays the calendar. If there is only one parameter, it represents the year (1-9999) and displays the calendar for that year. The year must be written in full: ``cal 89 will not be the calendar showing 1989. If two parameters are used, the month and year are represented. If there are no parameters, the calendar of this month is displayed.

The Western new calendar was used on September 3, 1752, because most countries adopted the new calendar and 10 days were removed, so the monthly calendar of that month was somewhat different. Before that, it was the Western calendar.

Kuang Dou 

-m: displayed on Monday as the first day of the week.

-J: as shown in the Caesar calendar, that is, the number of days from January 1.

-y: displays this year's calendar.

Example:

Cal: displays the calendar for this month.

[root@mylinux / root] # date

Tue Aug 15 08:00:18 CST 2000

[root@mylinux / root] # cal

August 2000

Su Mo Tu We Th Fr Sa

1 2 3 4 5

6 7 8 9 10 11 12

13 14 15 16 17 18 19

20 21 22 23 24 25 26

27 28 29 30 31

[root@mylinux / root] #

Cal 2001: displays the calendar of the year 2001.

[root@mylinux / root] # cal 2001

2001

January February March

Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa

1 2 3 4 5 6 1 2 3 1 2 3

7 8 9 10 11 12 13 4 5 6 7 8 9 10 4 5 6 7 8 9 10

14 15 16 17 18 19 20 11 12 13 14 15 16 17 11 12 13 14 15 16 17

21 22 23 24 25 26 27 18 19 20 21 22 23 24 18 19 20 21 22 23 24

28 29 30 31 25 26 27 28 25 26 27 28 29 30 31

April May June

Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa

1 2 3 4 5 6 7 1 2 3 4 5 1 2

8 9 10 11 12 13 14 6 7 8 9 10 11 12 3 4 5 6 7 8 9

15 16 17 18 19 20 21 13 14 15 16 17 18 19 10 11 12 13 14 15 16

22 23 24 25 26 27 28 20 21 22 23 24 25 26 17 18 19 20 21 22 23

29 30 27 28 29 30 31 24 25 26 27 28 29 30

July August September

Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa

1 2 3 4 5 6 7 1 2 3 4 1

8 9 10 11 12 13 14 5 6 7 8 9 10 11 2 3 4 5 6 7 8

15 16 17 18 19 20 21 12 13 14 15 16 17 18 9 10 11 12 13 14 15

22 23 24 25 26 27 28 19 20 21 22 23 24 25 16 17 18 19 20 21 22

29 30 31 26 27 28 29 30 31 23 24 25 26 27 28 29

thirty

October November December

Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa

1 2 3 4 5 6 1 2 3 1

7 8 9 10 11 12 13 4 5 6 7 8 9 10 2 3 4 5 6 7 8

14 15 16 17 18 19 20 11 12 13 14 15 16 17 9 10 11 12 13 14 15

21 22 23 24 25 26 27 18 19 20 21 22 23 24 16 17 18 19 20 21 22

28 29 30 31 25 26 27 28 29 30 23 24 25 26 27 28 29

30 31

[root@mylinux / root] #

Cal 5 2001: displays the May 2001 calendar.

[root@mylinux / root] # cal 5 2001

May 2001

Su Mo Tu We Th Fr Sa

1 2 3 4 5

6 7 8 9 10 11 12

13 14 15 16 17 18 19

20 21 22 23 24 25 26

27 28 29 30 31

[root@mylinux / root] #

Cal-m: displays the calendar of the month on Monday as the first day of the week.

[root@mylinux / root] # cal-m

August 2000

Mo Tu We Th Fr Sa Su

1 2 3 4 5 6

7 8 9 10 11 12 13

14 15 16 17 18 19 20

21 22 23 24 25 26 27

28 29 30 31

[root@mylinux / root] #

Cal-jy: displays this year's calendar by the number of days from January 1st.

[root@mylinux / root] # cal-jy

2000

January February

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat

1 32 33 34 35 36

2 3 4 5 6 7 8 37 38 39 40 41 42 43

9 10 11 12 13 14 15 44 45 46 47 48 49 50

16 17 18 19 20 21 22 51 52 53 54 55 56 57

23 24 25 26 27 28 29 58 59 60

30 31

March April

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat

61 62 63 64 92

65 66 67 68 69 70 71 93 94 95 96 97 98 99

72 73 74 75 76 77 78 100 101 102 103 104 105 106

79 80 81 82 83 84 85 107 108 109 110 111 112 113

86 87 88 89 90 91 114 115 116 117 118 119 120

one hundred and twenty one

May June

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat

122 123 124 125 126 127 153 154 155

128 129 130 131 132 133 134 156 157 158 159 160 161 162

135 136 137 138 139 140 141 163 164 165 166 167 168 169

142 143 144 145 146 147 148 170 171 172 173 174 175 176

149 150 151 152 177 178 179 180 181 182

July August

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat

183 214 215 216 217 218

184 185 186 187 188 189 190 219 220 221 222 223 224 225

191 192 193 194 195 196 197 226 227 228 229 230 231 232

198 199 200 201 202 203 204 233 234 235 236 237 238 239

205 206 207 208 209 210 211 240 241 242 243 244

212 213

September October

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat

245 246 275 276 277 278 279 280 281

247 248 249 250 251 252 253 282 283 284 285 286 287 288

254 255 256 257 258 259 260 289 290 291 292 293 294 295

261 262 263 264 265 266 267 296 297 298 299 300 301 302

268 269 270 271 272 273 274 303 304 305

November December

Sun Mon Tue Wed Thu Fri Sat Sun Mon Tue Wed Thu Fri Sat

306 307 308 309 336 337

310 311 312 313 314 315 316 338 339 340 341 342 343 344

317 318 319 320 321 322 323 345 346 347 348 349 350 351

324 325 326 327 328 329 330 352 353 354 355 356 357 358

331 332 333 334 335 359 360 361 362 363 364 365

three hundred and sixty six

[root@mylinux / root] #

Name: crontab

Permissions: all users

Mode of use:

Crontab [- u user] filecrontab [- u user] {- l |-r |-e}

Description:

Crontab is used to allow users to run programs at fixed times or at regular intervals, in other words, similar to the user's schedule. -u user means to set a schedule that specifies user, which requires that you have permission (such as root) to specify someone else's schedule. If you don't use-u user, it means to set your own schedule.

Number of meals:

-e: execute a text editor to set the schedule. The internal text editor is VI. If you want to use another text editor, please set the VISUAL environment variable to specify which text editor to use (for example, setenv VISUAL joe).

-r: delete the current schedule

-l: list the current schedule

The format of the schedule is as follows:

F1 f2 f3 f4 f5 program

Where F1 represents minutes, f2 represents hours, f3 represents the day of a month, f4 represents a month, and f5 represents the day of a week. Program represents the program to run.

When F1 is *, it means that every minute will be run. If program,f2 is *, the program will be run every hour, and so on.

When F1 is aMub, it will be executed from minute a to minute b, and when f2 is amelb, it will be executed from a to b, and so on.

When F1 is * / n, it is executed every n minutes, f2 is * / n, it is executed every n hours, and so on.

When F1 is a, b, c. It means a, b, c, etc. Minutes to be executed, f2 is a, b, c. It means a, b, c. 3 hours to execute, other analogies

Users can also store all the settings in the file file and set the schedule in the way of crontab file.

Example:

Execute / bin/ls once a month at the 0th minute of every hour:

0 7 * / bin/ls

/ usr/bin/backup is performed every 20 minutes from 6 a.m. to 12:00 every December:

0 6-12 beat 3 * 12 * / usr/bin/backup

Send a letter to alex@domain.name at 5:00 every day from Monday to Friday:

0 17 * * 1-5 mail-s "hi" alex@domain.name / dev/null 2 > & 1 is fine.

Name: date

Permissions: all users

Mode of use:

Date [- u] [- d datestr] [- s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+ FORMAT] [MMDDhhmm [[CC] YY] [.ss]]

Description:

Date can be used to display or set the date and time of the system. In terms of display, users can set the format they want to display. The format is set to a plus sign followed by several tags. The list of available tags is as follows:

In terms of time:

%: print%

% n: next line

% t: tabbed

% H: hours (00.23)

% I: hours (01.. 12)

% k: hour (0.23)

% l: hour (1.. 12)

% M: minutes (00.59)

% p: show local AM or PM

% r: direct display time (12-hour format in hh:mm:ss [AP] M)

% s: seconds since 00:00:00 UTC on January 1, 1970

% S: seconds (00.61)

% T: direct display time (24-hour system)

% X: equivalent to% H:%M:%S

% Z: show time zone

In terms of date:

% a: what day of the week (Sun..Sat)

% A: what day of the week (Sunday..Saturday)

% b: month (Jan..Dec)

% B: month (January..December)

% c: display date and time directly

% d: day (01.31)

% D: direct display date (mm/dd/yy)

% h: same as% b

% j: day of the year (001. 366)

% m: month (01.. 12)

% U: week ordinal of the year (00.53) (with Sunday as the first day of the week)

% w: day of the week (0.6)

% W: week ordinal of the year (00.53) (with Monday as the first day of the week)

% x: direct display date (mm/dd/yy)

% y: last two digits of the year (00.99)

% Y: full year (000.9999)

If you do not start with a plus sign, the time format is MMDDhhmm [[CC] YY] [.ss], where MM is the month, DD is the day, hh is the hour, mm is the minute, CC is the first two digits of the year, YY is the last two digits of the year, and ss is the number of seconds

Set up a plan:

-d datestr: displays the time set in datestr (non-system time)

-- help: displays auxiliary messages

-s datestr: sets the system time to the time set in datestr

-u: displays the current Greenwich mean time

-- version: displays the version number

Example:

Jump the line after the time is displayed, and then display the current date:

Date +% T%n%D

Show months and days:

Date + B d

Display date and set time (12:34:56):

Date-- date 12:34:56

Note:

When you do not want meaningless zeros (such as 1999-03-07), you can insert a-symbol in the tag, such as date +%-H:%-M:%-S will remove the meaningless zeros in minutes and seconds, such as the original 08:09:04 will become 8:9:4. In addition, only those who have obtained the rights (such as root) can set the system time.

When you change the system time as root, please remember to write the system time into CMOS with clock-w, so that the system time will keep the latest correct value the next time you reboot.

Name: sleep

Permissions: all users

Usage: sleep [--help] [--version] number [smhd]

Description: sleep can be used to delay the current action for a period of time.

Parameter description:

-- help: displays auxiliary messages

-- version: displays the version number

Number: length of time, followed by s, m, h, or d

Where s is seconds, m is minutes, h is hours, and d is days.

Example:

Delay 1 minute after displaying the current time, and then display the time again:

Date;sleep 1mdate

Name: time

Permissions: all users

Usage: time [options] COMMAND [arguments]

Description: the purpose of the time instruction is to measure the time and system resources required for the execution of specific instructions. Such as CPU time, memory, input and output, and so on. It is important to pay special attention to the fact that some of the information cannot be displayed on Linux. This is because some of the resource allocation functions on Linux are different from those preset by the time instruction, so that the time instruction cannot get the data.

Count 

-o or-- output=FILE

Set the result output file. This option writes the output of time to the specified file. If the file already exists, the system will overwrite its contents.

-an or-- append

With-o, the result is written to the end of the file without overwriting the original content.

-f FORMAT or-- format=FORMAT

Set the display mode with the FORMAT string. When this option is not set, the default format is used. However, you can use the environment variable time to set this format, so you don't have to set it every time you log in to the system.

In general settings, you can use

T

Means to jump the bar, or use the

N

Indicates a line break. % should be used as a lead for each item of information. If you want to use a percentage symbol in a string, use it. (people who have learned the C language will probably find it very familiar.)

There are four major resources that can be displayed by the time directive, which are:

Time resources

Memory resources

IO resources

Command info

The details are as follows:

Time Resources

E the time it takes to execute an instruction in the format: [hour]: minute:second. Please note that this number does not represent the actual CPU time.

E the time in seconds it takes to execute an instruction. Please note that this number does not represent the actual CPU time.

The time, in seconds, spent in core mode (kernel mode) when the S instruction is executed.

The time, in seconds, spent in user mode (user mode) when the U instruction is executed.

P the proportion of CPU when the instruction is executed. In fact, this number is the core mode plus the user mode CPU time divided by the total time.

Memory Resources

The maximum amount of physical memory occupied by M during execution. The unit is KB

The average amount of physical memory occupied by t execution, in KB

K the average size of the total memory occupied by the executing program (stack+data+text), in KB

The average size of the own data area (unshared data area) of the executor, in KB

P the average size of the own stack (unshared stack) of the executor, in KB

X average of content shared between programs (shared text) in KB

The size of the memory page of the Z system, in byte. It's a constant for the same system.

IO Resources

F the number of main memory page errors in this program. The so-called main memory page error means that a memory page has been replaced in the replacement file (swap file) and has been assigned to other programs. At this point, the contents of the page must be read again from the replacement file.

R the number of secondary memory page errors in this program. The so-called secondary memory page error means that although a memory page has been replaced in the replacement file, it has not been assigned to other programs. At this time, the content of the page has not been destroyed and does not have to be read from the replacement file.

W the number of times this program has been swapped to the replacement file

C the number of times this program has been forced to interrupt (such as running out of allocated CPU time)

W the number of times this program has been interrupted voluntarily (such as waiting for a certain Imax O to finish execution, such as disk reading, etc.)

I the number of files entered by this program

O the number of files output by this program

R Socket Message received by this program

S the Socket Message sent by this program

K the number of signals (Signal) received by this program

Command Info

Parameters and instruction names when C executes

The end code of the x instruction (Exit Status)

-por-- portability

This option automatically sets the display format to:

Real e

User U

Sys% S

The purpose of this is to be compatible with the POSIX specification.

-v or-- verbose

This option lists all the resources used in the program, not only in general English sentences, but also in instructions. It's useful for people who don't want to take the time to familiarize themselves with formatting or are just beginning to get started with this instruction.

Example:

Use the following instructions

Time-v ps-aux

We can get the results of executing ps-aux and the system resources spent. As listed below:

USER PID CPU MEM VSZ RSS TTY STAT START TIME COMMAND

Root 1 0.0 0.4 1096 472? S Apr19 0:04 init

Root 2 0.0 0.0 0 0? SW Apr19 0:00 [kflushd]

Root 3 0.0 0.0 0 0? SW Apr19 0:00 [kpiod]

.

Root 24269 0.01.0 2692 996 pts/3 R 12:16 0:00 ps-aux

Command being timed: "ps-aux"

User time (seconds): 0.05

System time (seconds): 0.06

Percent of CPU this job got: 68%

Elapsed (wall clock) time (h:mm:ss or m:ss): 0virtual 00.16

Average shared text size (kbytes): 0

Average unshared data size (kbytes): 0

Average stack size (kbytes): 0

Average total size (kbytes): 0

Maximum resident set size (kbytes): 0

Average resident set size (kbytes): 0

Major (requiring Imax O) page faults: 238

Minor (reclaiming a frame) page faults: 46

Voluntary context switches: 0

Involuntary context switches: 0

Swaps: 0

File system inputs: 0

File system outputs: 0

Socket messages sent: 0

Socket messages received: 0

Signals delivered: 0

Page size (bytes): 4096

Exit status: 0

Name: uptime

Permissions: all users

Usage: uptime [- V]

Description: uptime provides users with the following information, no other parameters are required:

The time now

The elapsed time between the startup and operation of the system

Number of connected users

The last one minute, five minutes and fifteen minutes of system load

Parameter:-V displays version information.

Example: uptime

The result is:

10:41am up 5 days, 10 min, 1 users, load average: 0.00, 0.00, 1.99

Name: chfn

Permissions: all users

Usage: shell > > chfn

Description: provide users with personal information about changes, for finger and mail username

Example:

Shell > > chfn

Changing finger information for user

Password: [del]

Name []: Johnney Huang # data when providing finger

Office []: NCCU

Office Phone []: [del]

Home Phone []: [del]

Name: chsh

Permissions: all users

Usage: shell > > chsh

Description: change user shell settings

Example:

Shell > > chsh

Changing fihanging shell for user1

Password: [del]

New shell [/ bin/tcsh]: # [shell is currently used]

[del]

Shell > > chsh-l # Show / etc/shells file content

/ bin/bash

/ bin/sh

/ bin/ash

/ bin/bsh

/ bin/tcsh

/ bin/csh

"finger [return]

Name: finger

Permissions: all users

Usage: finger [options] user [@ address]

Description: finger allows users to query the data of other users. The information that will be listed are:

Login Name

User Name

Home directory

Shell

Login status

Mail status

.plan

.project

.forward

Among them, .plan, .project and .forward are the data in the .plan, .project and .forward files of the user in his Home Directory. If not, no. Finger instructions are not limited to querying on the same server, but can also find users on a remote server. Just give me an address like E-mail address.

Count 

-l

Multi-line display.

S

Single-line display. This option only displays login name, real name, terminal name, idle time, login time, office number and phone number. This option is not valid if the user you are querying is a user of a remote server.

Example: the following instructions can query the information of the local administrator:

Finger root

The results are as follows:

Login: root Name: root

Directory: / root Shell: / bin/bash

Never logged in.

No mail.

No Plan.

Name: last

Permissions: all users

How to use: shell > > last [options]

Description: displays the information of those who logged in from the beginning of each month since the system was started.

Count 

-R omits the hostname field

-num before num presentation

Username displays login messages of username

Tty restriction login message includes terminal code

Example:

Shell > > last-R-2

Johnney pts/1 Mon Aug 14 20:42 still logged in

Johnney pts/0 Mon Aug 14 19:59 still logged in

Wtmp begins Tue Aug 1 09:01:10 2000 # / var/log/wtmp

Shell > > last-2 minery

Minery pts/0 140.119.217.115 Mon Aug 14 18:37-18:40 (00:03)

Minery pts/0 140.119.217.115 Mon Aug 14 17:22-17:24 (00:02)

Wtmp begins Tue Aug 1 09:01:10 2000

Name: login

If you don't know this order, don't do it! Hehe, I'm not here to waste your beautiful youth ^ _ ^

Name: passwd

Permissions: all users

Usage: passwd [- k] [- l] [- u [- f]] [- d] [- S] [username]

Description: used to change the user's password

Parameters:

-k

-l

-u

-f

-d turn off the password authentication function of the user, the user will not have to enter the password when logging in, and only users with root permission can use it.

-S displays the password authentication type of the specified user, which can only be used by users with root permission.

[username] specify the account name.

Name: who

Right of use line: available to all users

Usage: who-[husfV] [user]

Description: show which users are in the system, and the data displayed include the user ID, the terminal used, the connection from there, online time, sluggish time, CPU usage, actions, and so on.

Set up a plan:

-h: do not display the title column

-u: do not display the user's actions / work

-s: display in a short format

-f: do not display the online location of the user

-V: show program version "

Complete Collection of Linux instructions (3)

Name: / etc/aliases

Permissions: system administrator

How to use: please update the database with newaliases

Description:

Sendmail uses a file in / etc/aliases to convert the user name. When sendmail receives a letter to xxx, it sends it to another user based on the contents of the aliases file. This feature can create a user who is effective only within the mail system. For example, mailinglist uses this feature. In mailinglist, we might create a mailinglist called redlinux@link.ece.uci.edu, but there is actually no user named redlinux. The content of the actual aliases file is to send all messages to the user to the mailing list processor for delivery.

/ etc/aliases is a text-mode file, sendmail requires a binary format of / etc/aliases.db. The function of newaliases is to convert / etc/aliases into a database that sendmail can understand. Example:

# newaliases

The following command will do the same thing

# sendmail-bi

Related commands:

Mail, mailq, newaliases, sendmail

"mail [return]

Name: mail

Permissions: all users

Usage: mail [- iInv] [- s subject] [- c cc-addr] [- b bcc-addr] user1 [user 2...]

Description:

Mail is not only a command, but mail is also an email program, but very few people use mail to read letters. Mail is very useful for system managers, because managers can write script in mail and send memos regularly to remind users of the system.

Parameters:

I ignore the interrupt signal of tty. (interrupt)

I forced to set it to interactive mode. (Interactive)

V print out messages, such as location, status, etc. (verbose)

N do not read the mail.rc profile.

S message title.

C cc email address.

B bcc email address.

Example:

Send the letter to one or more e-mail addresses, because there is no other option, the user must enter the title and the contents of the letter, etc. If user2 does not have a host location, it will be sent to the user2 user of the mail server.

Mail user1@email.address

Mail user1@email.address user2

Send the contents of mail.txt to user2 and cc to user1. If you set this command to cronjob, you can send the memo to the system user on a regular basis.

Mail-s title-c user1 user2 > expr length "this is a test"

fourteen

# Digital Quotient

Shell > > expr 14 9

five

# grab the string from the location

Shell > > expr substr "this is a test" 3 5

Is is

# Digital string only the first character

Shell > > expr index "testforthegame" e

two

# Real string reproduction

Shell > > expr quote thisisatestformela

Thisisatestformela

Name: tr

# 1. For example, to change all uppercase file names in the directory to lowercase file names?

There seem to be many ways, and "tr" is one of them:

#! / bin/sh

Dir= "/ tmp/testdir"

Files= `find $dir-type f`

For i in $files

Do

Dir_name= `dirname $i`

Ori_filename= `basename $i`

New_filename= `echo $ori_filename | tr [: upper:] [: lower:] `> / dev/null

# echo $new_filename

Mv $dir_name/$ori_filename $dir_name/$new_filename

Done

# 2. In my own experiment. Lowercase to uppercase

Tr abcdef... [del] ABCDE... [del]

Tr Amurz Amurz

Tr [: lower:] [: upper:]

Shell > > echo "this is a test" | tr Amurz Amurz > www

Shell > > cat www

THIS IS A TEST

# 3. Remove unwanted strings

Shell > > tr-d this # remove information about t.e.s.t

This

Man

Man

Test

E

# 4. Replace the string

Shell > > tr-s "this"TEST"

This

TEST

Th

TE

Instruction: clear

Purpose: for clearing the screen.

How to use: enter clear on console.

Name: reset, tset

Usage: tset [- IQqrs] [-] [- e ch] [- I ch] [- k ch] [- m mapping] [terminal]

Instructions for use:

Reset is actually the same command as tset, and its purpose is to set the state of the terminal. In general, this command automatically determines the current terminal type from the environment variable, command line, or other configuration file. What if the specified type is? If so, the program will ask the user to enter the type of terminal.

Because this program will set the terminal back to its original state, in addition to being used in login, when the system terminal enters some strange state because the program does not run properly, you can also use it to reset the terminal o for example, accidentally enter the binary file into the terminal with cat instructions, and there will often be terminals that no longer respond to keyboard input or respond to strange character questions. At this point, you can use reset to restore the terminal to its original state. Option description:

-p

Display the terminal category on the screen, but do not set the action. This command can be used to get the type of the current terminal.

-e ch

Set the erase character to ch

-I ch

Set the interrupt character to ch

-k ch

Set the character of the deleted line to ch

-I

Do not do the set action, if you do not use the option-Q, the current values of erase, break, and delete characters will still be sent to the screen.

-Q

Do not display the values of erase, break and delete characters on the screen.

-r

Print the terminal category on the screen.

S

Send commands for setting TERM to the terminal in the form of a string, usually in .login or .profile

Example:

Let the user enter a terminal type and set the terminal to the preset state of that type.

# reset?

Set erase characters to control-h

# reset-e ^ B

Display the setting string on the screen

# reset-s

Erase is control-B (^ B).

Kill is control-U (^ U).

Interrupt is control-C (^ C).

TERM=xterm

Name: compress

Permissions: all users

Usage: compress [- dfvcV] [- b maxbits] [file.]

Description:

Compress is a rather old unix file compression directive, compressed files will be added a .Z extension to distinguish uncompressed files, compressed files can be decompressed with uncompress. If you want to compress several files into one compressed file, you must first tar the files and then compress them. As gzip can produce a better compression ratio, most people have changed to gzip as a file compression tool.

Parameters:

C output the result to the standard output device (usually on the screen)

F forced to write to the file, if the destination file already exists, it will be overwritten (force)

V print the message executed by the program on the screen (verbose)

B sets the upper limit on the number of common strings, which can be set between 9 and 16 bits in bits. Since the higher the value, the more common strings can be used and the greater the compression ratio, the default value is 16 bits (bits).

D decompress the compressed file

V list version message

Example:

Compress the source.dat into source.dat.Z. If the source.dat.Z already exists, the content will be overwritten by the zip file.

Compress-f source.dat

Compress source.dat into source.dat.Z and print out the compression ratio.

-v and-f can be used together.

Compress-vf source.dat

You can change the compressed file name by outputting the compressed data and then importing it into target.dat.Z.

Compress-c source.dat > target.dat.Z

The higher the value of-b, the greater the compression ratio, which ranges from 9 to 16, with a default value of 16.

Compress-b 12 source.dat

Extract the source.dat.Z to source.dat. If the file already exists, the user presses y to confirm that the file is overwritten. If you use the-df program, the file will be overwritten automatically. Because the system automatically adds .Z as the extension file name, source.dat is automatically treated as source.dat.Z.

Compress-d source.dat

Compress-d source.dat.Z

Name: lpd

Permissions: all users

Usage: lpd [- l] [# port]

Lpd is a resident printer manager that manages local or remote printers based on the contents of / etc/printcap. Each printer defined in / etc/printcap must have a corresponding directory in / var/lpd, where files starting with cf represent a printer job waiting to be sent to the appropriate device. This file is usually generated by lpr.

Lpr and lpd make up a system that works offline, and when you use lpr, the printer doesn't need to be available immediately, or even exist. Lpd automatically monitors the condition of the printer and sends the file for processing as soon as the printer is online. All applications do not have to wait for the printer to complete the previous work.

Parameters:

-l: displays some debugging messages on standard output.

# port: in general, lpd uses getservbyname to get the appropriate TCP/IP port, and you can use this parameter to force lpd to use the specified port.

Example:

This program is usually run by a program in / etc/rc.d during the system startup phase.

Name lpq

-- display the usage of unfinished work in the stored column of the listing machine

Lpq [l] [P] [user]

Description

Lpq displays outstanding items in the list machine storage column managed by lpd.

Example

Example 1. Show all work in the lp Lister storage column

# lpq-PlpRank Owner Job Files Total Size1st root 238 (standard input) 1428646 bytes

Correlation function

Lpr,lpc,lpd

Name: lpr

Permissions: all users

Usage: lpr [- P printer]

Send the file or data sent in by standard input to the printer, and the printer manager lpd will later send the file to the appropriate program or device for processing. Lpr can be used to send materials to local or remote hosts for processing.

Parameters:

-p Printer: sends the data to the specified printer Printer, with a default value of lp.

Example:

Send www.c and kkk.c to the printer lp.

Lpr-Plp www.c kkk.c

Name: lprm

Remove usage of a job from the printer storage column

/ usr/bin/lprm [P] [file...]

Description

Unfinished printer work is placed in the printer storage column, and this command can be used to cancel work that is often not sent to the printer. Since each printer has a separate storage column, you can use the-P command to set the printer you want to work. If not set, the printer preset by the system will be used.

This command checks whether the user has sufficient permission to delete the specified file, which is generally available only to the owner of the file or the system administrator.

Example

Remove work 1123 from the printer hpprinter

Lprm-Phpprinter 1123

Remove work 1011 from the preset printer

Lprm 1011

Name: fdformat

Permissions: all users

Usage: fdformat [- n] device

Instructions for use:

Low-level formatting of the specified floppy drive device. When using this instruction to format a floppy disk, it is best to specify devices such as the following:

/ dev/fd0d360 drive A:, disk is 360KB disk

/ dev/fd0h2440 drive A:, disk is 1.4MB disk

/ dev/fd1h2200 drive B:, disk is 1.2MB disk

If you use a device such as / dev/fd0, if the disk inside is not standard capacity, the formatting may fail. In this case, the user can use the setfdprm instruction to specify the necessary parameters first.

Parameters:

-n turn off the confirmation function. This option closes the confirmation step after formatting.

Example:

Fdformat-n / dev/fd0h2440

Format the disk of drive An into the disk of 1.4MB. And omit the step of confirmation.

Name: mformat

Permissions: all users

Mode of use:

Mformat [- t cylinders] [- h heads] [- s sectors] [- l volume_label] [- F] [- I fsVer-sion] [- S sizecode] [- 2 sectors_on_track_0] [- M software_sector_size] [- a] [- X] [- C] [- H hidden_sectors] [- r root_sectors] [- B boot_sector] [- 0 rate_on_track_0] [ -A rate_on_other_tracks] [- 1] [- k] drive:

Build a DOS file system on a disk that has been formatted at a low level. If you turn on the parameters of USE_2M when compiling mtools, some of the parameters related to the 2m format will take effect. Otherwise, these parameters (such as Smage2pl 1M) will not work.

Parameters:

-t magnetic column (synlider) number

-h head (head) number

-s number of sectors per track

-l label

-F formats the disk into FAT32 format, but this parameter is still being tested.

-I sets the version number in FAT32. This is, of course, still in the experiment.

-S sector size code, calculated as sector = 2 ^ (size code + 7)

-the number of sectors of the magnetic cluster (cluster). If the given number causes the number of magnetic clusters to exceed the limit of the FAT table, mformat automatically magnifies the number of sectors.

S

-M software sector size. This number is the size of the sector returned by the system. It's usually the same size as the actual size.

-an if you add this parameter, mformat will generate a set of Atari system serial numbers to the floppy disk.

-X formats the floppy disk into XDF format. The floppy disk must be formatted at a low level with the xdfcopy command before use.

-C produces a disk image file (disk image) that can install the MS-DOS file system. Of course, this parameter does not make sense for a physical disk drive.

-H the number of hidden sectors. This usually applies when formatting a partition of a hard drive, because there is usually a partition table in front of a partition. This parameter has not been tested, so you don't have to use it.

-n disk serial number

The size of the root directory in the number of sectors. This parameter is valid only for FAT12 and FAT16.

-B uses the boot sector of the specified file or device as the boot sector of this disk or partition. Of course, the hardware parameters will be changed accordingly.

-k try to keep the original boot sector.

-0 data transfer rate of track 0

-A data transfer rate other than track 0

-2 use 2m format

-1 does not use 2m format

Example:

Mformat a:

This will format the disk in a: (that is / dev/fd0) with the default value.

Name: mkdosfs

Permissions: all users

Usage: mkdosfs [- c |-l filename]

[- f number_of_FATs]

[- F FAT_size]

[- I volume_id]

[- m message_file]

[- n volume_name]

[- r root_dir_entry]

[- s sector_per_cluster]

[- v]

Device

[block_count]

Description: establish DOS file system. Device refers to the device code for which you want to set up a DOS file system. Like / dev/hda1 and so on. Block_count is the number of chunks you want to configure. If block_count is not specified, the system will automatically calculate the number of blocks that match the size of the device for you.

Parameters:

-C check for bad tracks before setting up a file system.

-l read the bad track record from the determined file.

-f specifies the number of archive configuration tables (FAT, File Allocation Table). The default value is 2. Currently, Linux's FAT file system does not support more than 2 FAT tables. Usually this doesn't need to be changed.

-F specifies the size of the FAT table, usually 12 or 16 bytes. 12-byte is commonly used for disks, and 16-byte is used for the partition of a general hard disk, which is called FAT16 format. This value is usually selected by the system itself. Using FAT16 on a disk usually doesn't work, and vice versa, using FAT12 on a hard disk.

-I specifies the Volume ID. It is usually a 4-byte number, such as 2e203a47. If not, the system will generate it on its own.

-m when the user tries to boot with this disk or partition and there is no operating system on it, the system will give the user a warning message. This parameter is used to change this message. You can edit it with the file first, and then specify it with this parameter, or use the

-m-

In this way, the system will ask you to enter this text directly. It is important to note that the string length in the file should not exceed 418 words, including the expanded jump symbol (TAB) and the newline symbol (the newline symbol counts as two characters under the DOS! )

-n specifies Volume Name, which is the disk label. Just like the format instruction under DOS, you can give it or not. There is no default value.

-r specifies the maximum number of files under the root directory. The so-called number of files here includes directories. The default value is 112 or 224 on the floppy disk and 512 on the hard disk. It's okay. Don't change this number.

-s the number of sectors per cluster. Must be to the power of 2. But don't give this value unless you know what you're doing.

-v provide additional information

Example:

Mkdosfs-n Tester / dev/fd0 formats the disk in slot An into DOS format and sets the label to Tester "

At this point, the study of "Linux instruction Collection" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report