I have a script running under my own user account that takes care of all sorts of wireless interfaces. It (more or less) intelligently switches wireless LAN off and on and so forth. However, it does so by calling on tools such as iwconfig and hciconfig to bring the devices up and down. But since these require super user privileges I decided to create a copy of these binaries in my personal script folder and set the suid flag (I am the only one who can read and execute that directory). So the permissions on these binaries look like -rwsr-x--- and they belong to root and my own primary group.

However, the suid bit appears to be completely ignored because I get the following result when executing that binary:

me@host:~/scripts/suid$ stat iwconfig
  File: `iwconfig'
  Size: 26968       Blocks: 72         IO Block: 4096   regular file
Device: 15h/21d Inode: 4194732     Links: 1
Access: (4750/-rwsr-x---)  Uid: (    0/    root)   Gid: ( 1000/   me)
Access: 2011-08-24 04:15:39.008148182 +0200
Modify: 2013-02-09 21:25:47.777488386 +0100
Change: 2013-03-12 15:55:20.765681857 +0100
 Birth: -
me@host:~/scripts/suid$ ./iwconfig wlan0 txpower off
Error for wireless request "Set Tx Power" (8B26) :
    SET failed on device wlan0 ; Operation not permitted.

I also tried setting the group to root, the guid bit and making the binaries world executable and readable. With the same outcome.

So, why is that and how can I fix it?

  • iwconfig is deprecated. Use iw instead.
    – BatchyX
    Commented Mar 12, 2013 at 16:05
  • That "script that handles network connections transparently" is called NetworkManager... works out-of-the-box.
    – vonbrand
    Commented Mar 12, 2013 at 16:09
  • @vonbrand: In my case it's not.
    – bitmask
    Commented Mar 12, 2013 at 16:11
  • I suggest you use sudo instead, you can set up a allowing your user to execute iwconfig as root (or, even better, only the particular iwconfig commands you need).
    – derobert
    Commented Mar 12, 2013 at 16:15
  • @derobert: Oh? Without password prompt?
    – bitmask
    Commented Mar 12, 2013 at 16:16

1 Answer 1


Your home directory is probably mounted with the nosuid flag. You can check by looking in /proc/mounts. If you're not sure which filesystem contains your home directory, df ~ will tell you (and then you can use grep to find it easily in /proc/mounts).

A better alternative, though, is to use sudo with the NOPASSWD flag. For example, run (as root) visudo -f /etc/sudoers.d/local-iwconfig and add a line like:

your-user-name ALL=(root) NOPASSWD: /sbin/iwconfig

You can also lock things down more with sudo. For example, you could specify the full command line to be run, including arguments (and then have multiple entries, one per command line). For full details, check the sudoers(5) manual page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .