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 system status users and limitations of Unix toolbox Note 2

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Linux system hardware Information of Unix toolbox Note 1

Linux system status users and limitations of Unix toolbox Note 2

This series of articles for the author of some personal notes on Unix toolbox, add some personal elements, delete some of the introduction of some commands for freebsd, the contents of the article are verified by the author, rest assured to use.

1.2 display status information

The following command helps to find out which programs are running on the system

# top # display and update the processes that use cpu the most

Note:

Top Tip, after executing the top command, you can click the following keys to achieve different functions 1 (number 1): list all the individual CPU load conditions z:top display colors

P: list the programs in the order of CPU usage M: list the programs in the order of memory usage x: similar to highlighting, the effect is as follows in z display mode:

Top shows Swap utilization. Press the f key after using the top command, then press the p key, and then enter to see the Swap status.

The default refresh time for d:top is 3s. You can customize the refresh time using the d key.

Top is similar to the method of turning pages up and down: top pages on shift are sorted by cpu occupation by default, which can also be modified. Press F (uppercase) to select the corresponding sort, and then enter.

C: displays the full path and parameters of the process command

W: writes the current settings to the ~ / .toprc file. This is the recommended way to write a top configuration file

# mpstat 1 # displays process-related information # vmstat 2 # displays status information of virtual memory # iostat 2 # displays iostat O status information (2 seconds gap) # tail-n 500 / var/log/messages # displays information of the latest 500 kernels / system logs 1.3 user # id # shows the current user and user group's ID # last # lists the current and past login to the system User related information # who # displays the user information currently logged in to the system # groupadd admin # create a new group "admin" and add a new user colin and join the admin user group (Linux/Solaris) # useradd-c "Colin Barschel"-g admin-m colin # userdel colin # Delete user colin (Linux/Solaris) use nologin to temporarily prevent all users from logging in (except root). The information in nologin will be displayed when the user logs in.

# echo "Sorry nologin now" > / etc/nologin # (Linux)

Limit some applications to set the maximum number of files and socket that can be opened (such as proxy server, database). The default limit is usually very low.

Note: about the use of readable IBM documents in ulimit: improving system performance through ulimit the author has previously written an article introduction to file descriptors: file descriptors under Linux

On the nproc restriction of ulimit in RHEL6

Ulimit is used to limit the resources consumed by the shell startup process, supporting the following types of restrictions: the size of kernel files created, the size of process data blocks, the size of files created by Shell processes, the size of memory locks, the size of resident memory sets, the number of open file descriptors, the maximum size of the allocation stack, CPU time, the maximum number of threads per user, and the maximum virtual memory that can be used by Shell processes. At the same time, it supports the limitation of hard resources and soft resources.

As a temporary restriction, ulimit can act on shell sessions logged in by using its commands, ending the restriction when the session terminates, without affecting other shell sessions. For long-term fixed limits, ulimit command statements can be added to files read by login shell, acting on specific shell users.

[root@kumu ~] # ulimit-a / / displays details of all current restrictions

Core file size (blocks,-c) 0

Data seg size (kbytes,-d) unlimited

Scheduling priority (- e) 0

File size (blocks,-f) unlimited

Pending signals (- I) 1829

Max locked memory (kbytes,-l) 64

Max memory size (kbytes,-m) unlimited

Open files (- n) 1024

Pipe size (512 bytes,-p) 8

POSIX message queues (bytes,-Q) 819200

Real-time priority (- r) 0

Stack size (kbytes,-s) 10240

Cpu time (seconds,-t) unlimited

Max user processes (- u) 1024

Virtual memory (kbytes,-v) unlimited

File locks (- x) unlimited

Shell/ script

The limitations of shell are governed by ulimit. Use ulimit-a to view its status information. For example, to change the maximum number of files that can be opened from 1024 to 10240, you can do this:

# ulimit-n 10240 # this is only useful in shell. The ulimit command can be used in a script to change the restrictions on this script.

User / process

Restrictions on login users and applications can be configured in / etc/security/limits.conf. For example:

# cat / etc/security/limits.conf * hard nproc 250 # limit the number of all user processes asterisk hard nofile 409600 # limit the maximum number of files that applications can open at the system level

Use sysctl to set kernel limits. To make it permanent, you can configure it in / etc/sysctl.conf.

# sysctl-a # shows all system limits # sysctl fs.file-max # shows system maximum number of file openings # sysctl fs.file-max=102400 # changes system maximum number of file openings # cat / etc/sysctl.conf fs.file-max=102400 # permanent entry in sysctl.conf # cat / proc/sys/fs/file-nr # number of file handles in use

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