1

I have some flv files and I'm trying to play them in VLC. I keep them in a separate directory owned by root (both directory and the files) to prevent accidentally deletion.

Now the interesting part:

  1. If the file is owned by root, VLC claims cannot open the flv file and stops.

  2. If the file is owned as regular user VLC is playing the file just fine.

The VLC is ran as regular user, just the file is owned by root.

Here's the VLC error: "Your input can't be opened: VLC is unable to open the MRL 'file:///path/test.flv"

And the VLC' log:

main debug: using default timeshift path
main debug: `file:///test.flv' gives access `file' demux `any' path `path/test.flv'
main debug: creating demux: access='file' demux='any' location='path/test.flv' file='path/test.flv'
main debug: looking for access_demux module matching "file": 21 candidates
main debug: no access_demux modules matched
main debug: creating access: file:///path/test.flv
main debug:  (path: path/test.flv)
main debug: looking for access module matching "file": 26 candidates
filesystem error: cannot open file path/test.flv (Permission denied)
main debug: no access modules matched

All the systems, both 16.04 and 18.04 are up to date and all packages are taken from official Ubuntu repos.

Any ideas how to fix this? Thanks!

Edit1: The dir/file permissions are fine:

drwxr-xr-x 2 root root 4096 dec 23 2015 Directory/
-rw-r--r-- 1 root root 12583957 apr 6 2012 test.flv –

What is really strange is that other files in the same dir and with the same permissions BUT *.mpg and *.avi are played fine.

Edit2: Found a solution.

It seems the problem is (on 16.04) the VLC provided by snap (the one I had installed). After removing and installing VLC media player with Ubuntu Software Center (version 2.2.2) now I don't see the issue anymore. Yet the problem with the snap version still remains.

Edit3: The same on 18.04. Removed the snap version, installed the deb version, now everything is OK.

2

First of all, nothing seems to be wrong with your system. But you need to understand Linux file permissions. You also should understand that changing the ownership of a file to root does not prevent data loss, it will reduce the probability of data loss though. Imagine the case your HDD/SSD fails. And there is still the possibility to delete the file accidentally when someone is logged in as root. If you can not risk to lose a file, back it up.

Each file/directory has an owner and a group associated with it. We can set permissions for

  1. owner (the owner of the file)
  2. group (all users who belongs to this group)
  3. other (all other users , they are not the owner of the file nor they belong to group)

For each of them we can set the permissions separately for read-access, write-access or execute-access (rwx). The execute-permission on a directory is a bit special, it allows you to enter the directory and you must have execute-permission on a directory when you want to access files in the directory.

So what do you need in your case?

  1. You need read and execute permissions on your directory.
  2. You need read permission for the file in the directory.

Take a deeper look at the current permissions of your file and it's parent directory with

ls -l /path/to/your/file
ls -ld /path/to/your/directory

The output of these commands will look like this:

-rw-------  1 root root 3495 Sep 23 03:35 file
drwx------  8 root root 4096 Jun  5 03:10 directory

You can see who is the owner of the file, which group is associated with the file and the full set of permissions. In this example only the owner (root) has read and write permissions for the file and read, write and execute permissions for the directory. User who belong to the group and all other users don't have any permissions in this example.

Now we give a user who is not root and doesn't belong to the group root permissions to read the file:

sudo chmod o+rx /path/to/your/directory
sudo chmod o+r /path/to/your/file

This will grant a user the permission to enter the directory and read the file, while owner and group and their permissions remain unchanged. Only root has write access to the file and it's parent directory, so only root could edit or remove the file.

You will find tons of tutorials about Linux permissions in the internet, some are better understandable then others, search the internet a bit to increase your knowledge. In this short answer I can give you only an overview about how permissions in Linux work. You also should take a look at the manuals for the relevant commands:

man chown
man chmod
  • The read permission is correct. The flv file has world read permission and the directory has search permission. The problem here is the VLC is not playing the file when the file owner is root and is playing the file when the owner is regular user. – Florin C Sep 23 '18 at 8:00
  • drwxr-xr-x 2 root root 4096 dec 23 2015 Directory/ -rw-r--r-- 1 root root 12583957 apr 6 2012 test.flv – Florin C Sep 23 '18 at 8:09
  • I can open a file owned by root with VLC (from official repo 18.04) as long as the permissions are correct. Please add your last comment to your question, file permissions are relevant. In your case they look correct too and it should work. For the moment I'm out of ideas... – mook765 Sep 23 '18 at 15:57
  • I think the VLC version is important. I just upgraded another machine from 14.04 to 16.04 having the VLC at 2.2 version and is working fine on 16.04. On my boxes that are not working I have VLC 3.0 – Florin C Sep 23 '18 at 16:52
  • I'm on 18.04 and tested with deb-package (V3.03) installed, I also tried with the snap-package (V3.04), in both cases I can open .flv-files owned by root. I could imagine that your critical file is somehow protected by another mechanism. – mook765 Sep 23 '18 at 16:59

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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