English 中文(简体)
如何终止与起诉一起进行的进程? Ctrl+ ......
原标题:how to terminate a process which is run with sudo? Ctrl+C do it, but not kill

在我公司,一些指挥员获准与弹道站在一起,如 t。 否则。

I expect run tcpdump for a while, and then stop it. When I run tcpdump, and I could abort that with Ctrl+C

我写了这样一句话:

#!/bin/sh
sudo tcpdump -ieth1 -w ~/dump.bin
sleep 5
kill -2 $!

它确实没有工作。 倾斜过程是根本的,目前的用户是正常的账户。

我的问题是:是否以任何方式在印本上做同样的剪辑?

EDIT:

p.: 作为我的公司的安全政策,我不能把杀人作为根基。

最佳回答

Try the -Z Options to tcpdump。 它指示倾斜,放弃根基特权,并按论点中规定的用户操作。

sudo tcpdump -Z $USER -ieth1 -w ~/dump.bin

Now try killing that process.

问题回答

缩略语 此外:

sudo kill -2 $!

这样,<条码>技能/代码>程序将有幸向一个进程发出信号。

对于没有像<代码>-Z等特殊开关的方案,如果您能够改变诉人档案,这是一个解决办法:

sudo myprogram &
sleep 5
sudo pkill myprogram

我必须做的是,允许使用<条码><<>条码>、pric myprogram/code>密码,并添加这一行文:

myuser ALL=(ALL) NOPASSWD:/bin/pkill myprogram

This is less dangerous that lo let sudo kill any program.

The timeout command also terminates a program after so long. sudo timeout 5 tcpdump -ieth1 -w ~/dump.bin should accomplish the same thing as the script.

sudo tcpdump -Z root -w ~/dump.bin -n -i eth0 -G 300 -W 1

G - Timeout Seconds (After timeout period the comman gets killed automatically) Z - drop root and runs as user privilege W - Number files to be saved (as a splitted file)

sudo tcpdump -ieth1 -w ~/dump.bin 

您的发言将阻碍你们的发言,你们需要将其放在背景中:

sudo tcpdump -ieth1 -w ~/dump.bin &

.

This and the answer from Blagovest should do it.





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签