Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Lets say I feel like reducing my screen brightness. However, rather than the laborious task of taking my fingers off the home row and pressing a button, I would rather type a sentence like this.
For the first case, it's your current, unprivileged shell that is trying to open that path for output. For the second case, "su" starts a privileged shell and it that that shell that is doing the open. If you want to do it in a single line try
Code:
sudo sh -c 'echo 8 > /sys/class/i2c-adaptor/i2c-7/device/backlight/acpi_video0/brightness'
Looks to me like a good spot for an alias if you're doing that often.
Lets say I feel like reducing my screen brightness. However, rather than the laborious task of taking my fingers off the home row and pressing a button, I would rather type a sentence like this.
actually, this doesn't work. It should, but I get a permission denied. However
Code:
su
echo 8 < /sys/class/i2c-adaptor/i2c-7/device/backlight/acpi_video0/brightness
exit
if I invoke su rather than sudo it works.
typing a complicated sentence isn't a problem but those extra 6 characters and carrige returns are killing me. What gives??
To me it's logical. If root allows you to execute certain command(s) with higher privileges it doesn't mean at the same time that you are allowed to write to any of his files.
To me it's logical. If root allows you to execute certain command(s) with higher privileges it doesn't mean at the same time that you are allowed to write to any of his files.
As others have said, you are running the echo as root but the redirection as the user. No one has said how to do it the other way round, which is to use tee.
echo 8 | sudo tee sys/class/i2c-adaptor/i2c-7/device/backlight/acpi_video0/brightness
This has the added benefit of avoiding the embarrassment of getting your redirection symbols the wrong way round ;-)
As others have said, you are running the echo as root but the redirection as the user. No one has said how to do it the other way round, which is to use tee.
echo 8 | sudo tee sys/class/i2c-adaptor/i2c-7/device/backlight/acpi_video0/brightness
This has the added benefit of avoiding the embarrassment of getting your redirection symbols the wrong way round ;-)
Maybe but I never seemed to misunderstand where an arrow is pointing. A good rule of thumb is to teach ones self that the direction of those input/output redirectors is from the larger side to the point. I'm not sure one benefits by avoiding use of > and <
Lets say I feel like reducing my screen brightness. However, rather than the laborious task of taking my fingers off the home row and pressing a button, I would rather type a sentence like this.
actually, this doesn't work. It should, but I get a permission denied. However
Code:
su
echo 8 < /sys/class/i2c-adaptor/i2c-7/device/backlight/acpi_video0/brightness
exit
if I invoke su rather than sudo it works.
typing a complicated sentence isn't a problem but those extra 6 characters and carrige returns are killing me. What gives??
Now that your sudo problem is explained, if the number of keystrokes is an issue, why not just use tools that make it even easier, like xbacklight or light? Even less keystrokes and no problems with sudo/su.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.