I created a directory called folder and took away execute permission.$ mkdir folder$ touch folder/innerFile$ mkdir folder/innerFolder$ chmod -x folderNow if I do$ ls folderit outputs a list of files, but when I do$ ls -l folderI getls: innerFile: Permission deniedls: innerFolder: Permission deniedWhy is that?
What is the difference between 'ls' and 'ls -l' when I don't have execute permission on that directory?
permissions;directory
ls -l on a folder tries to stat its contents, whereas ls doesn't:$ strace ls folder -l...lstat(folder/innerFolder, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0getxattr(folder/innerFolder, system.posix_acl_access, 0x0, 0) = -1 ENODATA (No data available)getxattr(folder/innerFolder, system.posix_acl_default, 0x0, 0) = -1 ENODATA (No data available)lstat(folder/innerFile, {st_mode=S_IFDIR|0755, st_size=40, ...}) = 0getxattr(folder/innerFile, system.posix_acl_access, 0x0, 0) = -1 ENODATA (No data available)getxattr(folder/innerFile, system.posix_acl_default, 0x0, 0) = -1 ENODATA (No data available)...That's why you get a permission denied with ls -l and not with ls.