LinuxShell script strategy ---- Chapter 9 management responsibility p

Source: Internet
Author: User
Tags addgroup
91 process information Collection 1 process is a running instance of the program, multiple processes running on a computer are assigned a unique identification number called process ID. 2 multiple instances of the same program can run simultaneously, but their process IDs are different.

9.1 collect process information

1. a process is a running instance of a program. multiple processes running on a computer are assigned a unique identifier number called a process ID.

2. multiple instances of the same program can run simultaneously, but their process IDs are different from each other.

3. a process includes multiple attributes, such as the user who owns the process, the memory used by the process, and the CPU occupied by the process.

4 ps is an important tool for collecting process information. It provides information including the user with the process, the start time of the process, the command line path corresponding to the process, and the process ID, the terminal to which the process belongs, the memory used by the process, and the CPU occupied by the process

5. the top command is an extremely important command for the system administrator. by default, the top command outputs a list of processes that consume the most cpu resources.

6 with the help of the ps command, you can find the process ID corresponding to the command name: ps-c command_name

9.2 kill processes and send or respond signals

1. a process-related important concept in a UNIX-like environment is a signal, which is a communication mechanism between processes. it is used to interrupt running processes to execute certain operations.

2. list all available signals: kill-l

3. terminate a process: the kill process_id // kill command sends a term signal by default.

4. the signal we use most often is as follows:

SIGHUP 1 ---- checks pending processes or terminals

SIGINT 2 ---- send this signal when Ctrl + C is pressed

SIGKILL 9 ---- used to forcibly kill a process

SIGTERM 15 ---- used to terminate the process by default

SIGTSTP 20 ---- send this signal when Ctrl + Z is pressed

5 forcibly kill the process

Kill-s SIGKILL process_id or kill-9 process_id

6 killall command: killall process_name

Killall forcibly kills the process: killall-9 process_name

9.3 which/whereis/file/whatis average load

1 which command is used to find the location of an executable program

2. when we enter a command on the terminal, we do not need to know where the corresponding executable file is located. the supervisor will find the command in a group of locations. if it can be found, it will execute the executable file, this group of locations is specified by the environment variable PATH.

3. we can export and add our own command search location: export PATH = $ PATH: /home/chenguolin/bin // add/home/chenguolin/bin to the environment variable PATH

4 The whereis command not only returns the command path, but also prints the location of the corresponding command manual and the path of the command source code.

Example: wheris ls

5. the file command is used to determine the file type.

File FILENAME // The command prints the file FILENAME type.

6 The whatis command will output a brief description of the command as a parameter: whatis ls

9.4 send messages to user terminals

The 1 wall command is used to write messages to terminals of all currently logged-on users. it can send the messages to all currently logged-on users on a server or to users on multiple scattered hosts.

2. send the echo "hello" | wall // command to all logon users ", the wall command is used to receive data from standard input.

9.5 collect system information

1 Print the host name of the current system: hostname or uname-n

2. print the Linux kernel version, hardware structure, and other details: uname-

3. print the kernel release version: uname-r.

4 Print host type: uname-m

5. print CPU information: cat/proc/cpuinfo

6 print the memory details: cat/proc/meninfo

7. list system partition information: cat/proc/partitions or fdisk-l

9.6 User Management

1 useradd

The useradd command can be used to create a new USER. the command syntax is as follows: useradd USER-p PASSWORD

Option-m is used to create the home directory. you can also provide-c FULLNAME to provide the full name of the user.

2 deluser

The deluser command is used to delete users. the command syntax is as follows: deluser user

-- Remove-all-files is used to delete all user-related files, including the home directory.

3. the chsh command is used to modify the USER's default shell. command syntax: chsh USER-s shell

4 passwd

The passwd command is used to modify the USER password. The syntax is as follows: passwd USER

5 addgroup

The addgroup command adds a new user GROUP to the system. the command syntax is as follows: addgroup GROUP

6 delgroup

The delgroup command deletes a user GROUP. The command syntax is as follows: delgroup GROUP

9.7 batch scaling and format conversion of image files

1 convert command is a command used to output image files

2. convert one image format to another: convert file1.jpg file2.png

3. specify the scaling ratio or the width and height of the output image and adjust the image: convert image.png-resize 1024x768 image.png

4. scale by percentage: convert image.png-resize "50%" image.png

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.