LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   no output for fdisk -l (https://www.linuxquestions.org/questions/linux-newbie-8/no-output-for-fdisk-l-759076/)

gerryd 10-01-2009 04:38 PM

no output for fdisk -l
 
when i'm not logged in as root i get no output when running fdisk. i can't even find the command without giving the absolute path
Code:

/sbin/fdisk -l
can anyone tell me why this happens? and if i can change it? thanks.
oh, and i'm using slackware 13 if that helps at all.

slimg00dy 10-01-2009 04:52 PM

Use sudo fdisk -l

Or login as root with su

If you want your account to be in the sudoers so you can just use sudo fdisk -l do
echo 'usernamehere ALL=(ALL) ALL

waltuotinen 10-01-2009 04:54 PM

fdisk -l not found
 
If the first word on a command line, which is almost always a command, does not contain any "/" characters, your shell tries to find the command you're trying to run.

To do this (unless the command is a built-in, an alias or a defined function), the shell searches the directories that are contained in your PATH variable, which usually has a list of one or more directory pathnames seperated by ":".

You can view your current PATH by entering:
echo $PATH

It will include /bin and or /usr/bin, but not /sbin.

If you enter:
PATH=$PATH:/sbin
you can then run fdisk -l without having to qualify its location.

To make this change to the PATH variable permanent, edit the .profile file in your home directory and add that same line of code (PATH=$PATH:/sbin) somewhere in the file, then the next time you log in, you'll be able to run any of the commands in /sbin without having to tell the shell where to find them.

I'm not sure, though, why the output is blank. I'll boot up my Linux laptop and check it out.

Best regards,
Walt Uotinen

markush 10-01-2009 05:09 PM

Hello together,

you'll need root-permissions to get an output for the command and you'll have to take the full path since /sbin is not in the path for a normal user.
Code:

sudo /sbin/fdisk -l
will work.

Markus

Edit: in Slackware, if you have not configured sudo just try
Code:

su -c /sbin/fdisk -l

waltuotinen 10-01-2009 05:17 PM

no output for fdisk -l
 
One other way to get fdisk to give you output without using sudo or becoming root (with su):

Become root, then enter:
chmod u+s /sbin/fdisk

This enables the Set User Id bit on the executable, so anyone can run fdisk and the process will have an effective user id of 0, indicating that root is running it.

A word of caution, though, that will allow anyone to use fdisk, albeit they'll have to run /sbin/fdisk, but it can do far more than just produce reports. It can reformat a disk...

Best regards,
Walt Uotinen

sploot 10-01-2009 05:31 PM

Quote:

Originally Posted by waltuotinen (Post 3704218)
Become root, then enter:
chmod u+s /sbin/fdisk

Don't do this if any other person might ever have access to your computer. Use sudo. log into the root user. dont give such huge system access to all users if you have any expectation of your computer surviving other people's use.

Easiest way, set up sudo. Configure it so you can use it and it will null your authentication after 30 seconds or so. Keep it secure :)

chrism01 10-01-2009 05:45 PM

sbin = system binaries; those usually only needed by root(!) user.
http://en.wikipedia.org/wiki/Filesys...archy_Standard


All times are GMT -5. The time now is 07:58 AM.