10-09-2017, 02:32 AM
(10-07-2017, 03:26 PM)gold_finger link Wrote:Hi [member=16]gold_finger[/member]Moltke Wrote:why root you ask? well, not sure whether or not it has to do with *ls command or that you're working with directories but your non-root user has no permission to perform that action, I think it's harmless, but apparently you're not allowed unless root, maybe someone more experienced than me could explain the why.
There is no need to use sudo or su for the ls command. When you do that you'll end up with problem that the generated file is owned by root instead of regular user. Regular user will be able to read file, but won't be able to make changes or delete it without also being root. Don't know why you experienced a problem with it. Maybe you accidentally mis-typed something. This should work without a problem as regular user:
Code:ls > ls.txt
Also, if you want to get rid of the weird characters generated in output of that command (assuming directories may be part of the output) use this instead:
Code:ls --color=never > ls.txt
The terminal colorizes directory listings to make them stand out from regular files. If you generate a text file from command line above and the output contains directories, you'll see strange characters around those directory listings because text editor can't do colors. For example, generate a text file listing contents of your Home directory, then open it with text editor to see what I'm talking about.
Code:cd ~
ls > home.txt
Now do it again with the "--color=never" option.
Code:ls --color=never > home.txt
Thanks! This is very helpful! I tried ls command again and it worked without asking for root..weird, cause the first time I tried I had to run sudo ls for it to work, but now I didn't have to, have no idea why though. The --color=never option is great too. Thanks again!
Without each others help there ain't no hope for us
Need a translation service? https://www.deepl.com/es/translator
Need a translation service? https://www.deepl.com/es/translator