Linux Common Commands Daquan 2

Source: Internet
Author: User
Tags set time time and date word wrap

Linux Common Commands Daquan 2

Iv. commands for shutting down and viewing system information

Commands for shutting down and viewing system information

/tr>

command

Description

Shutdown

Normal shutdown

Reboot

Restart Computer

PS

View Current program execution

Top

View current program execution scenarios and memory usage

Kill

Terminate a process

Date

Change or view current date

Cal

Show Calendar and annual calendar

4.1 Shutdown command

To use this command, the root user must be guaranteed, otherwise the SU command will be used to change to the root user. The command format is as follows:

shutdown– (option)

Options

Function

-K

Not a real shutdown, just a warning order.

-R

Restart after shutdown

-T

Shut down within the specified time

Join to shut down within 2min, enter command:

Shutdown–t 2

If this is a reboot after shutdown, enter the command:

Shutdown–r

4.2 Reboot Command

This command is also a shutdown command, only input, without any parameters, the system will be the fastest speed shutdown, and do not write memory or buffer contents back to the hard disk.

Options

Function

-D

Do not write the records in the/var/log/wtmp file (-n This parameter contains-D)

-F

Forced re-boot, no call to shutdown this command

-N

Do not write the memory data back to the hard drive before rebooting

-W

Doesn't really reboot, just writes the records to the/var/log/wtmp file.

4.3 PS command

The PS command is used to see what programs are in progress in the computer system and how they are executed. This is a fairly powerful command that can be used to find out all the process IDs and names. In addition, the PS command can be used to list all programs that use memory. Use the following:

PS – (option)

Options

Function

-L

List in long format

-U

List the name and usage time of the consumer

-M

List the memory distribution situation

-R

Only the foreground programs that are being executed are listed, and no additional information is listed

-X

List all programs, including those with no terminals

4.4 Top Command

The top command can view the current program's execution scenarios and memory usage. It is similar to PS, however, it updates the system state for a few seconds and is easy to track. To get out of this program, press CTRL + C key to do it.

4.5 Kill command

The KILL command is used to terminate a process that is executing. If a program fails during execution, you can terminate the program to avoid remaining in memory and consuming system resources. However, its practical significance is to send a signal to the executing program, calling it suicide. Can send a lot of signals to these programs, also can let them receive signal after doing a lot of things. Standard usage:

kill– (option) PID

Before the KILL command is executed. You can use the PS command to check the PID of a program that is down, and then remove a program by using kill. For example, to terminate a program with PID 90:

Kill 90

Options

Function

-L

List all available signal names

-P

The printed PID does not send a signal

-signal

The available signals are HUP (1), KILL (9), term (15), respectively, representing the re-run, chop off, and end

Cut down the stroke of the PID 323 (Kill):

Kill-9 323

To re-run the 456-PID Stroke (restart):

Kill-hup 456

4.6 Date Command

The date command is used to display, set, and modify the current time and date. Standard usage:

date– (option) Display time format (beginning with +, plus format)
Date set time format

Options

Function

-U

Use GMT

-R

Last time the file was modified

-S

Set the time

Several commonly used time formats are shown in the following table:

Format

Description

%a

Abbreviations for the day of the week, such as one, two or three

%A

Full name of the day of the week, e.g. Monday, Tuesday

%d

Date (mm/dd/yy format)

%T

Display time format, 24-hour (HH:MM:SS)

%x

Format of the display date (MM/DD/YY)

%y

The last two digits of the year

%Y

Years (e.g. 2007, 2008)

%r

Time (Hh:mm:ss morning or afternoon)

%p

Show morning or afternoon

If you enter a command:

Date "+%x,%r"

The system returns the following information:

March 26, 2010, 18:06 P.M. 49 seconds

4.7 cal Command

The CAL command has two functions: a monthly calendar and a calendar.

The direct Input CAL command displays a monthly calendar for the current month.

To display a year's annual calendar, you can add a 4-digit year of A.D. to the Cal command. For example, to display a 2008 year calendar, you must enter:

Cal 2008

If you enter Cal 08, the Year 8 calendar is most displayed.

To view only a January calendar for a given year, you can enter: Cal month AD year. For example, enter: "Cal 12 2004".


V. Management of users and command to establish authority

Manage users and commands for setting up permissions

Command

Description

Command

Description

chmod

Used to change permissions

Useradd

Used to increase the user

Su

Used to modify a user

5.1 chmod command

The chmod command is used to change license permissions. Read, write, and execute are the three main settings in the license permissions. Because users are programmed into a group when their account is created, they can also specify that the group can read, write, or execute a file. which

R-Files can be read
W-Files can be written
X-Files can be executed if the file is a program

You can use the LS command with-l to carefully view many details of a file.

The chmod command is used to set permissions on a file. Standard usage:

chmod (+,-, =) permission name (r,w,x) file for user (u,g,o,a) of the file

User of the file

Description

Permissions

Description

Changes

Description

U

The user who owns the file

R

Read Right

+

Add permissions

G

The group where the owner resides

W

Write right

-

Delete permissions

O

The others

X

Executive power

=

is what it calls unique permissions

A

All (U,g and O)

To delete all permissions for a file, enter a command:

chmod a-rwx Test.txt

To add permissions to the file owner, enter the command:

chmod u+rwx Test

You can also use numbers to indicate permissions: 4--read, 2--write, and execute. The following two commands are equivalent:

chmod 751 filename
chmod u+rwx,g=rx,0=x filename

5.2 su Command

The SU command is used to modify the user. This is a very important command that allows an ordinary user to have access to superuser or other users. However, this command must have a superuser or other user's password to become a superuser or other user. If you want to leave, you can enter exit. Standard usage:

SU user name (default to root if no user name is entered)

For example, assuming that the current user User01 and want to transition to USER02, enter the command:

Su User02

System returns:

Password

At this point, enter the USER02 instruction and it will become user02.

5.3 Useradd Command

The Useradd command is used to increase the user, only the root user can increase the user. If you are not logged in as the root user, enter Su, and then enter the root password.

To add a user, enter a command:

Useradd User Name

Then, follow the prompts to enter a password for the new user.


Six, the command of the line query

Commands for online queries

Command

Function

Mans

Query and explain how a command is used, as well as a description of the command

Locate

Locating files and directories

Whatis

Look for the meaning of a command

6.1 Man Command

The man command is used to query and interpret the use of a command and the considerations for this command. This query query is available on every Linux. Typically, the user simply enters the command man and the name of the command shell will list a complete description. Standard usage:

Name of the man command

To query the description page of the LS command, enter the command:

Mans LS

To flip through the manual page, you can use the page UP and PAGE DOWN keys, or use the spacebar to turn back one page and use B to flip forward. To exit the manual page, enter the command Q. To search for keywords in the manuals page, enter a command/and keyword or phrase to search for, and then press ENTER. All keywords appearing on the manuals page are highlighted, allowing you to quickly read the keywords in the context.

6.2 Locate Command

The main function of the Locate command is to locate files and directories. Sometimes, you can use locate to locate files and directories only if you know that a file or directory exists, but you don't know where it is. Using the Locate command, you will see each file and directory that includes the search field. For example, if you want to search for a file with the word test, enter the command:

Locate test

The locate command uses a database to locate a file or directory with the word test.

6.3 Whatis Command

The Whatis command is used to query the meaning of a command. The use of simple, and do not need any parameters, directly after the Whatis command to add the command to query can be, but it is very practical.

To query the meaning of the MV command, enter the command:

Whatis MV


Vii. commands for reading documents

Commands for reading files

Command

Function

Head

View the beginning of a file

Tail

View 10 lines at the end of a file

Less

Less is a paging tool that allows a page-by-page (or screen-by-screen) view of information

More

More is a paging tool that allows page-by-page (or a screen-by-screen) view of information

7.1 Head Command

The head command can be used to view the beginning of a file. The format of this command is:

Head file name

The default setting, which only looks at the first 10 lines of the file. However, you can change the number of rows to display by specifying a number option, with the following command:

HEAD–20 file name

This command will look at the first 20 lines of the file.

7.2 Tail Command

The tail command is the opposite of the head command. With the tail command, you can view 10 lines at the end of a file. This helps you view the last 10 lines of the log file to read important system information. You can also use tail to observe the process of log file updates. With the-f option, tail automatically displays new information from the open file to the screen in real time. For example, to actively observe/var/log/messages, enter the following command under the shell as root user:

Tail–f/var/log/messages

7.3 Less command

The less command is similar to the more command.

7.4 More commands

The main difference between the more and less is that less allows you to use arrows to move back and forth, while more uses the SPACEBAR and the B key to move forward and backward. Use LS and more to enumerate the contents of the/etc directory:

ls–al/etc | More

To use more to search for a keyword in a text file, press the/key and enter the command to search for the entry:

/foo

Use the SPACEBAR to scroll through the page numbers before. Press the Q key to exit.

The more command standard format is:

more [options] [FileNames]

Options

Meaning

-num

Number of rows displayed at one time

-D

Prompt the user, below the screen display [press space to continue, Q to quit.] If the user presses the wrong key, the press h for instructions will be displayed. Not the beep.

-L

The feature that pauses when meeting special character ^l (paper feed characters) is canceled

-F

Number of rows, in actual number of rows, rather than lines after word wrap (some single-line words that are too long are extended to two or more lines)

-P

Do not scroll to display each page, but first clear the screen and then display the content

-C

Similar to-p, the difference is to display the content before clearing other old data

-S

A blank line that is substituted for a row when it encounters a blank line that has more than two consecutive lines

-U

Do not display quotation marks (varies according to the terminal specified by the term of the environment variable)

+/

Search for the string (pattern) before each file is displayed, and then start displaying it after the string

+num

Show starting from Num line

FileNames

To display the contents of the file, can be the number of complex numbers

For example:

More-s testfile Displays the file contents of the Testfile pages by page, if there are two consecutive lines or more blank lines are displayed in a row of blank lines.
More +20 testfile from line 20th to display the contents of the Testfile file.

Linux Common Commands Daquan 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.