Score:0

Different create file permissions for different commands

us flag

Trying to create file in /opt folder with command:

sudo echo '01' > aaa

Got error -bash: aaa: Permission denied

Works fine if I create file, edit and save with vim

sudo vim aaa

Why I'm getting error while create file with one command while no error with other one?

Score:3
cn flag

The shell performs the redirection as you before sudo starts. You want:

sudo sh -c 'echo "01" > aaa'

so that the "aaa" file is created in the sudo process.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.