accessing fdisk -l as user

Owen Townend owen.townend at gmail.com
Thu Aug 14 02:17:30 UTC 2008


2008/8/14 Patrick Drechsler <patrick at pdrechsler.de>:
> 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:
>
> ,----
> | # ls -al /proc/partitions
> | -r--r--r-- 1 root root 0 2008-08-14 03:23 /proc/partitions
> `----
>
> Should this file be created automatically during boot time?
>
> Thankful for any pointers,
>
> Patrick

Hey,

One _possible_ solution would be to write a script such as:
   #!/bin/sh
   /sbin/fdisk -l
Place it in a suitable location, `chown root:root` and `chmod 500` it
and add it to the user's sudo permissions.
If you want to keep arguments such as device node but strip out other
(dangerous) options then obviously the script will need a few
additions.

cheers,
Owen.




More information about the ubuntu-users mailing list