I'm trying to run Motion app on a Linux box.

For various security reasons, I'd rather run it as regular user than sudo. However, when I run "service motion start" without the sudo in front, it says:

chown: changing ownership of `/var/run/motion': Operation not permitted 

Googling doesn't seem to yield any results relevant to this situation.


When I've installed motion in the past it's been done so that it's running as its own designated user, typically motion. I'd suggest doing the same thing here for your installation as well.


The OP asked how this was done. I explained that if you install the motion package via either Debian/Ubuntu or Fedodra repos the installation would be done so that everything you needed to run motion as another user, motion in my cases, was done out of the box by default.

If you look at the files that would typically get installed with motion, a SYSV init script is often provided, /etc/init.d/motion. Within this script, on Ubuntu, is a section like this:

case "$1" in
    if check_daemon_enabled ; then
        if ! [ -d /var/run/motion ]; then
                mkdir /var/run/motion
        chown motion:motion /var/run/motion

    log_daemon_msg "Starting $DESC" "$NAME" 
if start-stop-daemon --start --oknodo --exec $DAEMON -b --chuid motion ; then
            log_end_msg 0
            log_end_msg 1

If you look at the start-stop-daemon line you'll notice that when motion is started ($DAEMON) the switch --chuid motion is passed, which will run the motion daemon process as user motion.

Something similar is done on my Fedora & CentOS systems as well in their corresponding /etc/init.d scripts for motion.

  • How do I actually do this? And, per X Tian's point, would there be any side effects/issues down the road? – Uzumaki Naruto Feb 8 '14 at 21:29
  • @UzumakiNaruto - what distro are you doing this on? The motion package is in the Ubuntu & Fedora repositories, when you install from either of those places, you get the motion running as the user motion for free as part of the installation. I do this exact thing on Ubuntu 12.04. – slm Feb 8 '14 at 21:39
  • The Raspberry Pi NOOB distro. :) – Uzumaki Naruto Feb 9 '14 at 21:53
  • @UzumakiNaruto is that the actual name? – slm Feb 9 '14 at 22:02
  • I think it's raspbian wheezy. – Uzumaki Naruto Feb 19 '14 at 1:57

It is trying to change owner of the file /var/run/motion and has insufficient permission.

If the file exists, you can try and change the owner yourself

sudo chown username /var/run/motion

It may then go forward and hit a new issue.

It would be better to reconfigure from default values for motion and then locate these sort of files within your /home/username structure or create a directory you own below /var/run for your runtime application files.


The standard way to handle this is to make a group and assign the user(s) who are going to use the program to the group. Then you chown all of the directories to the new group and chmod them to allow members of the group to read and write there.

groupadd motion_users
vipw  # to update groups for user(s)
chown -R motion_users /var/run/motion  # and anything else
chmod g+rwx /var/run/motion

Now login as the user and it should work as long as the device permissions are there. Note you have to log out and back in for groups to be added to a user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.