LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-09-2024, 07:52 AM   #1
cwdztsd88
LQ Newbie
 
Registered: Feb 2024
Distribution: Pop_OS
Posts: 14

Rep: Reputation: 0
Question 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?
 
Old 03-09-2024, 10:50 AM   #2
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
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.
 
Old 03-09-2024, 11:02 AM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,306

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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.
 
1 members found this post helpful.
Old 03-09-2024, 07:08 PM   #4
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,127
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
Is your user account in the cdrom group?
 
Old 03-09-2024, 07:55 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by cwdztsd88 View Post
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?
 
Old 03-12-2024, 01:29 PM   #6
cwdztsd88
LQ Newbie
 
Registered: Feb 2024
Distribution: Pop_OS
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rnturn View Post
What do you get back when you issue the "groups" command? Is "cdrom" in the list?
no i dont see it
 
Old 03-12-2024, 01:31 PM   #7
cwdztsd88
LQ Newbie
 
Registered: Feb 2024
Distribution: Pop_OS
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by business_kid View Post
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.
 
Old 03-12-2024, 01:49 PM   #8
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by cwdztsd88 View Post
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.
 
1 members found this post helpful.
Old 03-12-2024, 02:08 PM   #9
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
In deed. Sudo is quite an ingenuous tool. Whatever you think to know about it, find out, what it really does.
 
Old 03-12-2024, 03:04 PM   #10
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,306

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Quote:
Originally Posted by cwdztsd88 View Post
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.
 
Old 03-13-2024, 08:37 AM   #11
cwdztsd88
LQ Newbie
 
Registered: Feb 2024
Distribution: Pop_OS
Posts: 14

Original Poster
Rep: Reputation: 0
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.
 
Old 03-13-2024, 11:13 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
in that case you might want to mark it solved
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to eject a removable device in a software way, but not by "eject"command viktor2000 Linux - Newbie 13 10-14-2011 04:40 AM
Unmount and Eject with CD-Rom Eject Button? CrownAmbassador Linux - Hardware 3 12-26-2006 08:45 PM
VCD does not eject even eject button pressed ic_torres Linux - Software 4 12-01-2005 05:40 PM
Toggling "eject" and "eject -t" daihard Linux - Software 3 12-27-2004 03:01 AM
CD Won't Eject With "eject" Command Dr. Ephemeron Slackware 13 11-13-2003 12:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration