Loadkeys gives permission denied for normal user

5,257

You need root capabilities to use loadkeys. It is common to set the setuid permission bit on loadkeys. Setting this bit will cause any processes spawned by executing the loadkeys file to run as the owner of the file (usually root).

For added security, you should change loadkeys's permissions to 750, make a group for it, and add any users that need to use loadkeys to that group.

$ groupadd loadkeys             # you can use any group name 
$ chgrp loadkeys /bin/loadkeys
$ chmod 4750 /bin/loadkeys      # setuid, group- and user-only read and execution
$ gpasswd -a user loadkeys      # add user to the group
Share:
5,257

Related videos on Youtube

stany
Author by

stany

Updated on November 24, 2022

Comments

  • stany
    stany over 1 year

    I am trying to perform loadkeys operation. For normal user, I am getting permission denied error.

    the error is as follows.

    <tim@testps>~% loadkeys mykeys
    Loading /usr/tim/mykeys
    Keymap 0: Permission denied
    Keymap 1: Permission denied
    Keymap 2: Permission denied
    KDSKBENT: Operation not permitted
    loadkeys: could not deallocate keymap 3
    
  • Admin
    Admin about 6 years
    Very nice, though I would like to point out one minor glitch. This may or may not depend on OS, but at least with debian 9 doing chgrp on a file clears the setuid bit on the file so you should reorder the chmod after chgrp or else it wont work. Also I was just wondering if there's any security implications? E.g. could loadkeys be used to install a keylogger?