0

When I run os.mkdir(), I can see the folder using ls, but cannot view it with regular nautilus (GNOME file manager, I'm running Ubuntu). In Edit->Preferences, I checked Show hidden and backup files, which didn't help.

However, I discovered that I can view the Python-made folders using sudo nautilus. I'm confused because this would mean Python creates folder that require root permission, but that is conflicted by the fact that I can view them using non-root ls.

Is it possible to make Python let me see the folder using non-root Nautilus, and why is this happening?

Code:

import os

os.mkdir(os.getcwd() + '/myFolder')

ls -l:

manually created folder, can view in Nautilus:

drwxrwxr-x 3 user user 4096 Mar 22 08:58 folder1

Can't view. Is it weird that it has the same file permission as the one above? But this one was created through Python.

drwxrwxr-x 3 user user 4096 Mar 22 08:40 folder2

Another one I can't view, created by root through Python

drwxr-xr-x 3 root root 4096 Mar 22 11:41 folder3

Parent folder:

drwxrwxrwx 21 user user 4096 Mar 23 17:36 parentFolder

onepiece
  • 3,279
  • 8
  • 44
  • 63
  • If a python script creates files you don't own, it is obviously running as an other user (can be root, but also any other). Check who owns the process with the proper tools provided by your OS. – Klaus D. Mar 23 '15 at 21:16
  • @KlausD. how come I can see the files using non-root `ls`? From the same terminal session that I run `nautilus`. – onepiece Mar 23 '15 at 21:19
  • @KlausD. After closer examination, it seems that only the folders require `sudo nautilus` to view, not files. – onepiece Mar 23 '15 at 22:01
  • 1
    what does `ls -l` show? – Jasper Mar 23 '15 at 22:17
  • ls is the list command. The -l argument shows stuff as a table, i.e. including the nice view of the file's properties. And I think that your problem is not Python related. It may be a bug in Nautilus (which happens) (btw, do you update the view before going into the folder, e.g. by pressing F5?) or a permission bug – cleros Mar 23 '15 at 22:35
  • I also assume that nautilus is to blame, perhaps some buffering that is circumvented by python's way to create the file/directory. – Jasper Mar 23 '15 at 22:55
  • can you `cd` into the folder because you need execute permissions on the folder to `cd` into the folder. – jkd Mar 23 '15 at 23:15

0 Answers0