In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how linux uses the pgrep command. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
How to use the pgrep command
Syntax:
Pgrep [options] pattern
When called without any option, pgrep displays the pid of all running programs that match the given name. For example, to find the PID of the SSH server, run the following command:
[root@localhost ~] # pgrep ssh85310631589
If you want to end the ssh process, you can use the pkill command
[root@localhost ~] # pkill ssh
Pgrep prints each matching process ID in a line break. The-d option allows you to specify different delimiters. For example, if you want to use spaces as delimiters, run the following command:
[root@localhost] # pgrep ssh-l-d''1654 sssd_ssh2664 sshd1666 sshd
Use the-l option to list the PID and process name:
[root@localhost ~] # pgrep-l ssh1654 sssd_ssh1664 sshd1666 sshd
If you want an exact match, you can use:
[root@localhost ~] # pgrep'^ sshd$'-l1664 sshd1666 sshd
Use the-u option to tell pgrep to display the processes that a given user is running:
[root@localhost] # pgrep-u root-L1 systemd2 kthreadd. 520 xfsaild/dm-0521 kworker/0:1H600 systemd-journal622 lvmetad628 systemd-udevd632 rpciod634 xprtiod659 xfs-buf/sda1
To display processes that do not match a given condition, use the-v option. The following command prints all processes that are not run by the user "root":
[root@localhost] # pgrep-v-u root-l801 dbus-daemon802 rpcbind810 avahi-daemon812 polkitd817 avahi-daemon820 chronyd1282 pickup1283 qmgr
The-c option tells pgrep to print only the number of matching processes
[root@localhost] # pgrep-v-u root-l-c8 Thank you for reading! This is the end of this article on "how to use pgrep commands in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.