LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   eject Command asks for root permission (https://www.linuxquestions.org/questions/linux-newbie-8/eject-command-asks-for-root-permission-4175734717/)

cwdztsd88 03-09-2024 07:52 AM

eject Command asks for root permission
 
I don't think ejecting a drive should be this laborious. How i can use eject command without using sudo?

Michael Uplawski 03-09-2024 10:50 AM

Provide the rights to execute “sudo eject” without password in sudoers, then write a script
Code:

#!/bin/sh
sudo eject

untested.

The right to eject depends on the device.

business_kid 03-09-2024 11:02 AM

Hello cwdztsd88 & welcome to LQ.

Disk operations customarily require root permissions for security reasons. You can use sudo if you want to do this. You can set up sudo in /etc/sudoers and do clever things, letting users have root as much or as little as you like. You can also put the dvd (I presume it's a dvd) in /etc/fstab with the 'users' or 'user' option and this might allow you to eject. Man fstab for the details. Test it and see. You might also eject using a right click in the File Manager in X.

replica9000 03-09-2024 07:08 PM

Is your user account in the cdrom group?

rnturn 03-09-2024 07:55 PM

Quote:

Originally Posted by cwdztsd88 (Post 6488582)
I don't think ejecting a drive should be this laborious. How i can use eject command without using sudo?

What do you get back when you issue the "groups" command? Is "cdrom" in the list?

cwdztsd88 03-12-2024 01:29 PM

Quote:

Originally Posted by rnturn (Post 6488684)
What do you get back when you issue the "groups" command? Is "cdrom" in the list?

no i dont see it

cwdztsd88 03-12-2024 01:31 PM

Quote:

Originally Posted by business_kid (Post 6488603)
Hello cwdztsd88 & welcome to LQ.

Disk operations customarily require root permissions for security reasons. You can use sudo if you want to do this. You can set up sudo in /etc/sudoers and do clever things, letting users have root as much or as little as you like. You can also put the dvd (I presume it's a dvd) in /etc/fstab with the 'users' or 'user' option and this might allow you to eject. Man fstab for the details. Test it and see. You might also eject using a right click in the File Manager in X.

I am scared of doing bad things to my computer so i dont want my user have root permission always.

TB0ne 03-12-2024 01:49 PM

Quote:

Originally Posted by cwdztsd88 (Post 6489276)
no i dont see it

Then you should add it
Quote:

Originally Posted by cwdztsd88
I am scared of doing bad things to my computer so i dont want my user have root permission always.

That's why you use SUDO, but beyond that, how do you think you're going to apply updates or do anything system related without admin rights? You can't do that on Windows or Mac either. All you need to do is:
  • Take regular backups
  • Use your own brain to think about what you're doing and be careful
Because eventually your system WILL die, and you'll have to restore your data; the backups are for that. And if you 'do bad things' to the point your system doesn't work, you have now learned what not to do, and can just rebuild your system.

We've all killed systems in the past, and you either have ALREADY done it, or you WILL do it. There's no third option.

Michael Uplawski 03-12-2024 02:08 PM

In deed. Sudo is quite an ingenuous tool. Whatever you think to know about it, find out, what it really does.

business_kid 03-12-2024 03:04 PM

Quote:

Originally Posted by cwdztsd88 (Post 6489277)
I am scared of doing bad things to my computer so i dont want my user have root permission always.

Users of computers divide into three types, according to someone
  1. Beginner: is afraid to do things in case he presses a key that breaks the whole computer.
  2. Intermediate: Doesn't know what to do when he has pressed a key that broke his computer.
  3. Expert: Someone who breaks other people's computers.

Get out of stage 1. The forum here helps And buy yourself a backup disk, make backups, and then you can just restore the backup if you break or wipe stuff.

cwdztsd88 03-13-2024 08:37 AM

Problem solved by adding suid to /usr/bin/eject, all i wanted was to eject flash drive to extend it's service time and since my main drive is nvme it's hard to write /dev/nvme0blablabla instead of /dev/sda. I dont think i would do a mistake. Thanks for everyone's replies, didn't expected to get attention this fast.

pan64 03-13-2024 11:13 AM

in that case you might want to mark it solved


All times are GMT -5. The time now is 12:09 AM.