Write to file forbidden

Nils Kassube kassube at gmx.net
Sun Mar 15 14:30:57 UTC 2009


GaryT wrote:
> To obtain a recursive listing of all files, I'll use the command
> 	ls -s -S -R
> from the root directory.

That would be nearly all files - hidden files would stay hidden. If you 
want to see ALL files, add the -A option.

> BUT
> When attempting to capture that list by saving it to a text file, I
> get "permission denied"
> 	e.g.	ls -s -S -R >files.txt

You are not allowed to write to "/files.txt".

> adding sudo makes no difference

No, it doesn't because sudo then only works for the ls command, not for 
the output redirection. Try

sudo ls -sSR / >~/files.txt

which will give you a list of all files but place the output in your 
home directory.

> using gksudo also makes no difference.

There is no big difference between sudo and gksudo in this case because, 
like sudo, it operates on the ls command not on the output redirection.


Nils




More information about the ubuntu-users mailing list