Common shell command usage (1)

xiaoxiao2021-03-06  41

Bash Hot KeyCtrl P Turn up the previous command Ctrl n Down to the previously used command CTRL A cursor moved to the command line Ctrl E cursor moved to the end of the command line Ctrl D Delete the character under the current cursor Ctrl h removes the character Ctrl F cursor before the current cursor moves a CTRL B cursor forward moving a Ctrl U removes all character Ctrl K before the cursor deletes all character Ctrl w Remove cursor. A word ALT D before it is deleted the current cursor to the other part of the first separator. Esc b jumps left to the left (with a very awkward) Esc f hop to the right (same - on) blank case CTRL D Matches the previous command of the logoutCtrl R actually the command of Emacs

Bash, KSH can set the command line editing method

Set -o Emacs is set to Emacs, so you can use the fastness mentioned above.

Set -O VI is set to vi mode, using the VI command mode Press ESC to enter the row editing state h J k L Move I, A inserts C, R, S Replace / Serach

Kill command

When you need to interrupt a reception process, you are usually using a combination key; but for a background process, it is impossible to solve it. At this time, you must ask for a kill command. This command can terminate the background process. As for the termination of the background process

The reason is a lot, and may be too much CPU occupied by the process; maybe this process has been hanged. In short, this is often happening.

The kill command ends the process by sending a specified signal to the process. If no signal is specified, the default is Term

signal. The TERM signal will terminate all processes that cannot capture the signal. As for those processes that can capture this signal, you may need to use

Kill (9) signal, this signal cannot be captured.

The syntax format of the kill command is simple, and there are roughly below:

Kill [-s signal | -p] [-a] process number ...

Kill -l [signal]

-s Specifies the signal that needs to be sent. Embodiments can also correspond to numbers.

-p Specifies that the kill command is just the PID of the process, and does not really send the end signal.

-l Displays a list of signal names, which can also be found in the /usr/include/linux/signal.h file.

Use of kill command

Let's take a look at the use of the command.

[Example 24] Due to the time excessive time, the process is terminated due to time.

First, you should use the PS command to see the PID corresponding to the process, type PS, display the following:

PID TTY TIME COMMAND

285 1 00:00:00 -Bash

287 3 00:00:00 -Bash

289 5 00:00:00 / sbin / mingetty tty5

290 6 00:00:00 / sbin / mingetty tty6

312 3 00:00:00 Telnet BBS3

341 4 00:00:00 / sbin / mingetty TTY4

345 1 00:00:00 Find / -Name Foxy.jpg

348 1 00:00:00 PS

It can be seen that the PID corresponding to the process is 345, and now use the kill command to terminate the process. Type:

# Kill 345

Use the PS command to see, you can see that the Find process has been killed. [Example 25] Kill the process 11721

# ps

PID TTY TIME COMMAND

11668 p1 00:00:00 -tcsh

11721 p1 00:00:00 Cat

11737 p1 00:00:00 ps

# kill 11721

[1] Terminated Cat

#

Sometimes it may encounter such a situation, a process has been hang or idle, but use the kill command but can't kill. At this time

Signal 9 must be sent, and forcibly turn off this process. Of course, this "barbarism" method is likely to cause the open file error or

An error such as data loss. Therefore, it is not necessary to use a mandatory approach. If the signal 9 does not respond, then it is afraid

Only restart your computer.

Control multiple processes commands

Linux allows users to run multiple processes simultaneously, allowing users or system administrators to control the running process.

Nohup command

In theory, when we usually exit the Linux system, all the programs will be completed, including those background programs. But sometimes,

For example, you are editing a very long program, but you have to get out of the system, then you don't want the system to edit you.

So long procedures end, I hope to exit the system, the program can continue to execute. At this time, we can use the nohup command to make the process

The user will continue after exiting.

Generally, we all let it execute in the background, and the result will be written to the NOHUP.out file in the user's own directory.

(You can also use the output redirection to output it to a specific file). [Example 26]

$ Nohup Sort Sales.dat &

This command tells the sort command to ignore the user has exited the system, it should always run until the process is completed. Use this method,

You can start a process to run for a few days or even weeks, and users don't need to log in when it runs.

The NOHUP command sent all the outputs and error messages of a command to the nohup.out file. If the output is redirected, only errors

The information is placed in the Nohup.out file.

Renic command

The renice command allows users to modify a priority that is running process.

Use the renict command to adjust its priority when the command is executed. The format is as follows:

$ renice -number pid

Where parameter Number is the same as NUMBER's NUMBER.

Note:

(1) Users can only use the renice command to all the processes.

(2) Root users can use the renice command on any process.

(3) Only root users can improve the priority of the process.

Get standard time is: TimeConfig Set the correct time zone ntpdate time.nist.gov and standard time server Synchronization SetClock Setting hardware clock with system time

Run the command uname -a to get the kernel version

Add a user and set user password

Bash-2.05 # UserAdd AliceBash-2.05 # Passwd AliceChanging Password for User Aliceter New Unix Password: Retype New Unix Password: Passwd: All Authentication Tokens Updated SuccessFully

How to use ISO files under Linux

1: Build a MOUNT point first

Bash # MKDIR / MNT / ISO

2: Now we need to put the next /tmp/mandrake80-inst.iso file mount to / mnt / ISO

Bash # mount -t iso9660 -o loop /tmp/mandrake80-inst.iso / mnt / ISO

This way you can see the content in the ISO file.

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

New Post(0)