Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

Linux普通用户创建socket失败,报错没有权限如何解决?

1、环境
linux内核版本:

/etc # uname -a
Linux mdm9607-perf 3.18.20 #3 PREEMPT Thu Sep 19 16:05:52 CST 2019 armv7l GNU/Linux
/etc #

2、问题

if ((ossock = socket(ipv6 == 1 ? PF_INET6 : PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)

普通用户(非root)执行上面代码,报错,错误码如下:
错误码: #define EACCES 13 // Permission denied 无权限

这种问题如何解决?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

有权限能切换到root,就切换到root;
没有的话,看下有没有sudo的权限,有的话在命令前加 sudo sudo command
不知道我又没有理解对。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...