accessing fdisk -l as user

Karl Larsen k5di at zianet.com
Thu Aug 14 12:48:35 UTC 2008


Patrick Drechsler wrote:
> Hi,
>
> can I access the output of 
>
> fdisk -l
>
> as user on Ubuntu 8.04.1 LTS?
>   
    In a terminal type sudo fdisk -l and give your password.


> I would like to use this information for a script without root
> privileges. The user running this script is sudo user.
>
>   
    The user of fdisk must be a root user I believe.
> 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
>
>   
    Well before you do much do what I gave you above and it should print 
out

karl at karl-hardy:~$ sudo fdisk -l
[sudo] password for karl:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00056ea5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         974     7823623+  83  Linux
/dev/sda2             975        1948     7823655   83  Linux
/dev/sda3            1949        2192     1959930   82  Linux swap / Solaris
/dev/sda4            2193        5598    27358695    5  Extended
/dev/sda5            2193        4625    19543041   83  Linux
/dev/sda6            4626        5598     7815591   83  Linux

This is mine of course and shows I have a lot of free space!

Karl

>
>   


-- 

	Karl F. Larsen, AKA K5DI
	Linux User
	#450462   http://counter.li.org.
   PGP 4208 4D6E 595F 22B9 FF1C  ECB6 4A3C 2C54 FE23 53A7





More information about the ubuntu-users mailing list