37

I have installed a vlc in centos 6.5. I want to run it as root. But I get the following error,

"VLC is not supposed to be run as root. Sorry. If you need to use real-time priorities and/or privileged TCP ports you can use vlc-wrapper (make sure it is Set-UID root and cannot be run by non-trusted users first)."

0

6 Answers 6

76

This is what worked for me. No compilation required.

sed -i 's/geteuid/getppid/' /usr/bin/vlc

Using VLC media player 2.0.3 Twoflower on a Raspberry Pi.

Explanation: The initialization script check if the UID is equals to zero. Zero is reserved for the root user. Using sed to replace geteuid for getppid fools the initialization script because it is always > 0.

While running the VLC as root is not recommended, it works. Be aware of the risks and obviously do not do it for production environments.

For Freebsd and other finicky unices and macos use the proper full syntax:

sed -i '' 's/geteuid/getppid/' /usr/local/bin/vlc
1
  • 3
    Really appreciate the explanation part. A lot of people skip that, and then its just magical one liner that fixes a problem. Rather then chance to learn.
    – GoTTimw
    Commented Mar 5, 2020 at 11:25
20

One way around this is recompiling. Pass the --enable-run-as-root flag to ./configure and vlc should be able to run as root. The above answer is from here.

5
  • 2
    recompiling is not the only way, just change the call to geteuid to deliver 1. I describe this at linuxintro.org/wiki/Run_vlc_as_root Commented Oct 29, 2014 at 6:56
  • @ThorstenStaerk, thanks for providing me the information.
    – Ramesh
    Commented Oct 29, 2014 at 16:42
  • Could you please mark the question as answered? Commented Oct 31, 2014 at 8:49
  • @ThorstenStaerk : dead link... Commented Dec 16, 2015 at 15:23
  • 1
    @Alexandre Bourlier: works (again) Commented Dec 16, 2015 at 15:33
6

See Run vlc as root - LinuxIntro:

  • backup the VLC binary:

     # cp /usr/bin/vlc /usr/bin/vlc-backup
    
  • find the call to geteuid inside the VLC binary:

     # needle=$(objdump -d /usr/bin/vlc | grep euid | tail -1 | awk '{print "\\x"$2"\\x"$3"\\x"$4"\\x"$5"\\x"$6;}')
    
  • replace the call to just deliver 01:

     # sed -ir "s/$needle/\xb8\x01\x00\x00\x00/" /usr/bin/vlc
    
  • test it

VLC should now run under the root user!

2
  • 1
    That is extremely beautiful. Works like a charm and I am amazed at the cleverness to think this up.
    – LFMekz
    Commented Jan 3, 2023 at 13:40
  • wow, just read this, you made my day!!! Commented Feb 3, 2023 at 13:14
2

You will be able to run VLC as root by modifying the VLC binary, located in /usr/bin

First, you'll need a hex-editor, like Bless:

sudo apt-get install bless

Then, you'll open the VLC binary with the hex-editor:

sudo bless /usr/bin/vlc

Search and change the geteuid string by getppid, save and exit.

You can now launch VLC as root.

2

Kevin in comments of the question suggested using vlc-wrapper. I had troubles finding out how to use it so I'll describe how I made it work:

you need to set your non-privileged user in SUDO_UID: export SUDO_UID=1000

if you don't have a user to run vlc under create one:

useradd -g users vlc
# this will show you the uid of vlc user
id -u vlc

if you want SUDO_UID variable permanent, add it to bashrc:

echo "export SUDO_UID=1000" >> /root/.bashrc

be careful not to write single > instead of >>

then use vlc-wrapper instead of vlc

0

Go to main menu find vlc and set property as:

gksu -u vlc

or simply in terminal type

gksu -u <username(no root)> vlc

For example, if you have abc user your command will be:

gksu -u abc vlc

You must log in to answer this question.

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