ubuntu 使用 tshark 抓包时出现异常:
Running as user “root” and group “root”. This could be dangerous.
Capturing on ‘enp6s0’
tshark: The file to which the capture would be saved (“file.pcap”) could not be opened: Permission denied.
问题描述:
tshark抓包需要以root身份运行,当前目录是在普通用户下,无法执行。
ls -lst 查看权限如下:
总用量 148
136 -rw------- 1 root root 133965 8月 16 16:43 file.pcap
4 -rwxr-xrwx 1 lingzi lingzi 1103 8月 16 16:10 capturepcap.sh
4 -rwxr-xr-x 1 lingzi lingzi 3303 7月 26 17:35 pcap2csv.py
4 -rwxr-xr-x 1 lingzi lingzi 2760 2月 20 2020 pcap2csv.sh
当前目录的所有者不是root,修改目录权限是的root有写入权限。
chmod o+w capturepcap.sh
由于是多级目录,仅修改最下一级无法解决问题,将路径上的目录权限全部修改。
再次运行。
加粗的一行是修改过后成功运行得到的