accessing fdisk -l as user
Smoot Carl-Mitchell
smoot at tic.com
Thu Aug 14 02:34:39 UTC 2008
On Thu, 2008-08-14 at 03:36 +0200, Patrick Drechsler wrote:
> Hi,
>
> can I access the output of
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
>
> I would like to use this information for a script without root
> privileges. The user running this script is sudo user.
>
> According to the man page of fdisk, the -l option is:
>
> ,----
> | -l List the partition tables for the specified devices and then exit.
> | If no devices are given, those mentioned in /proc/partitions (if that
> | exists) are used.
> `----
>
> The file /proc/partitions is empty:
The file is not empty. It is a filename in the special "proc"
filesystem. Do:
cat /proc/partitions
and you will see a list of your disk partitions. The -l option to fdisk
requires read access to your disk devices in the /dev/ directory. These
have rw permission granted for the root user and the disk group. If you
put the user running the script in the "disk" group in /etc/group, then
you will be able to read the disk partition table. Be aware that the
user will now have read/write access to all your disks which is a
potential security issue.
An alternate to the above is to add something like this to your sudoers
file with visudo:
test ALL=NOPASSWD: /sbin/fdisk -l
This lets the "test" user execute the fdisk command only with the "-l"
option without entering a password.
--
Smoot Carl-Mitchell
System/Network Architect
smoot at tic.com
+1 480 922 7313
cell: +1 602 421 9005
More information about the ubuntu-users
mailing list