Click here to Skip to main content
15,614,138 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The documentary does not explain why one of the smarter then me user did this :

nov25-1@nov251-desktop:~$ getcap !$
 getcap `which hcitool`
 /usr/bin/hcitool = cap_net_admin,cap_net_raw+eip
getcap `which hcitool`
/usr/bin/hcitool cap_net_admin,cap_net_raw=eip
/usr/bin/hcitool cap_net_admin,cap_net_raw=eip
Unknown command - "="


All I want to add
cap_net_admin

So I did this command 

<pre>nov25-1@nov251-desktop:~$ sudo setcap 'cap_net_admin' `which hcitool
> help
> exit
> 

I do not understand the apparent option 

`which hcitool


and  the result indicate I am missing something in the command - perhaps more options? 


And before somebody I know gets bend out of shape

I NEED THIS TO ALLOW MY C++ CODE TO WORK
SO IT IS CODE RELATED/






Perform various network-related operations:

What I have tried:

I did study (RTFM) (see above) this and it did not help

capabilities(7): overview of capabilities - Linux man page[^]
Posted
Updated 27-Dec-22 7:58am
v2

1 solution

Check your script again. There should be two backquotes (`) around the which command. Backquotes denote a sub-shell command, the output of which is inserted into the invoking command. In your case which hcitool probably returns /usr/bin/hcitool, so setcap 'cap_net_admin' `which hcitool` is equivalent to setcap 'cap_net_admin' /usr/bin/hcitool Note that if you're using bash, then sub-shells are more often called using the $( ) usage rather than the backquotes. There are a few reasons for this. Firstly, depending on the font used, backqoutes and single quotes can be hard to distinguish, leading to scripting errors. They're also quite small and easy to miss when reading an example. But mostly, the $( ) usage can be nested, whereas backquotes cannot. This means that with $( ) you can do
Shell
$ cmd1  c1arg1 $(cmd2 $(cmd3 c3arg1 c3arg2) c2arg1 c2arg2) c1arg2
If you were to try this with backquotes you get the following:
Shell
$ cmd1 c1arg1 `cmd2 `cmd3 c3arg1 c3arg2 `c2arg1 c2arg2` c1arg2
In this case, cmd2 gets called in a sub-shell with no arguments, we try to create a sub-shell with the command c2arg1 (which probably fails).
 
Share this answer
 
v2
Comments
Member 14968771 27-Dec-22 11:13am    
This is a error I am trying to eliminate
qt.bluetooth.bluez: Missing CAP_NET_ADMIN permission. Cannot determine whether a found address is of random or public type.

I run sudo which setcap and got this file /usr/sbin/setcap the it ctu and paste thisw command sudo setcap cap_net_admin,cap_net_raw+ep /usr/sbin/setcap and I got "Uninc nno respose " hence command passed. Run the app an still getting the error. Try to read (cat) the /usr/sbin/setcap file , but it is not in humanly readable format. Perhaps I will reboot...and watch for smoke...
Member 14968771 27-Dec-22 11:14am    
I need to write my comments in word
processor ,,,,
Member 14968771 27-Dec-22 13:00pm    
I am looking at this file https://gist.github.com/milesfrain/7d687edc6b1ad644603b3ba10da8243d#file-bluetooth-conf
Is that the file I need to add CAT_NET_ADMIN ? PS I need advise how to read "setcap" file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900