[solved]blkid runing for all user not only sudo

vikozo

Member
Joined
Dec 30, 2021
Messages
55
Reaction score
12
Credits
442
hello
how to change the right of blkid to be run by all user not only as sudo ?
i need it in a script
have a nice day
vinc
 


Old Tom Bombadil

Active Member
Joined
Jul 29, 2020
Messages
99
Reaction score
124
Credits
931
sudo is not always required for blkid. It depends on the distro. If you are looking to get UUID information, try lsblk -f instead. It does not need sudo.

I would not, in any case, recommend removing sudo requirements to a program that is deemed to require it by the distro makers. You may open up security vulnerabilities by doing things like this.
 

forester

Active Member
Joined
Mar 5, 2022
Messages
289
Reaction score
167
Credits
2,090
. . . I would not, in any case, recommend removing sudo requirements to a program that is deemed to require it by the distro makers. You may open up security vulnerabilities by doing things like this.
or put it in a script that enters a password. I would say get used to securely using root. just a suggestion.
 
N

NorthWest

Guest
vikozo asked:
how to change the right of blkid to be run by all user not only as sudo ?
i need it in a script
The simplest way of having a user run the command: blkid, is to use the full path to the executable thus:
Code:
[[email protected] ~]$ blkid
bash: blkid: command not found
[[email protected] ~]$ /sbin/blkid
/dev/sda4: UUID="e61bdb54-dc84-403d-bcc3-7615a2e65d33" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="53a851dc-d942-4935-89d0-267519b34363"
/dev/sda2: UUID="4cb91113-2989-44cb-9d2d-9888fa140e55" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6ae0a73d-c3e7-4ed1-94ac-82f14183ad28"
/dev/sda3: UUID="a815d92a-29ef-4c49-9e8d-1a79d3513987" TYPE="swap" PARTUUID="63a839e4-ec39-433c-b15b-58e0393fcafe"
/dev/sda1: UUID="A926-84F6" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="618562c3-5a87-4f69-b89a-4dc5d1297ec6"
This way there is no need for the user to be root. If a command in the /sbin directory does actually require root privileges, it will usually tell you, for example:
Code:
[[email protected] ~]$ iftop
bash: iftop: command not found
[[email protected] ~]$ /sbin/iftop
interface: wlxd037458000c8
IP address is: 192.168.0.14
IPv6 address is: 2001:8003:c436:f401:d237:45ff:fe80:c8
MAC address is: d0:37:45:80:00:c8
pcap_open_live(wlxd037458000c8): wlxd037458000c8: You don't have permission to capture on that device (socket: Operation not permitted)
It's worth noting that the /sbin directory is a link to the /usr/sbin directory in most distros these days, so /sbin/iftop has the same effect as /usr/sbin/iftop.
 
OP
V

vikozo

Member
Joined
Dec 30, 2021
Messages
55
Reaction score
12
Credits
442
yes it was a layer 8 Problem - me - shame !
using the path works fine - sorry!
 

Old Tom Bombadil

Active Member
Joined
Jul 29, 2020
Messages
99
Reaction score
124
Credits
931
/sbin/blkid
This doesn't work on Fedora 35. Nor does /usr/sbin/blkid. All produce no output and no error. Fedora may be odd in this regard, if not unique. I don't know. What does work on Fedora is to run sudo blkid one time first, then just blkid alone without sudo will work, and /sbin/blkid and /usr/sbin/blkid also work. After rebooting, sudo is required again.

Glad Vinc found the solution he needed. :)
 
Last edited:
OP
V

vikozo

Member
Joined
Dec 30, 2021
Messages
55
Reaction score
12
Credits
442
@Old Tom Bombadil
what's happen whit this command?
Code:
$ whereis blkid
i had it like this
Code:
blkid: /usr/sbin/blkid
 

Old Tom Bombadil

Active Member
Joined
Jul 29, 2020
Messages
99
Reaction score
124
Credits
931
I'm not sure of your question. Fedora gives me the same response to whereis as you show, /usr/sbin/blkid (and also the location of the man page). You can also try this command to find the location:
Code:
which blkid
 

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
528
Reaction score
451
Credits
2,408
Code:
lsblk -f
is much more understandable and it doesn't require sudo, so use that. blkid is (IMO) obsolete and should be removed.

Much easier to understand the info the above command displays, isn't it?

yoiMbFu.png
 
OP
V

vikozo

Member
Joined
Dec 30, 2021
Messages
55
Reaction score
12
Credits
442
@rado84 that looks smart this lsblk -f
Merci
 
OP
V

vikozo

Member
Joined
Dec 30, 2021
Messages
55
Reaction score
12
Credits
442
@rado84
why is the size different when you do the
df - h vs. lsblk -f ??
 

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
528
Reaction score
451
Credits
2,408
@rado84
why is the size different when you do the
df - h vs. lsblk -f ??
It seems that df -h shows different stuff than lsblk -f which simply displays your current devices, their UUID, label and how much space is free on them. Whereas df -h displays something about I-nodes - things I know nothing about.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Latest posts

Top