Can't run fdisk on Cygwin when it is installed

1

I can't run fdisk on Cygwin, either outside or inside of the directory that contains it, despite confirming that:

  • fdisk.exe exists inside of /sbin, via both the command line and Windows Explorer

  • C:\cygwin64;, C:\cygwin64\sbin; and C:\cygwin64\bin; are set in the PATH environment variable

enter image description here

Running which fdisk returns a "no fdisk in [PATH]" error, where [PATH] is the contents of my PATH environment variable.

What's going on here?

Hashim

Posted 2017-10-23T01:16:38.103

Reputation: 6 967

Answers

1

After some testing, it seems the problem in this case was that my computer needed to be restarted for the Windows PATH environment variable to be updated. I hadn't tried this because I assumed that this was the purpose of source ~/.bashrc, which I'd always used for similar purposes in the past.

It wasn't too much trouble for me personally to restart my computer, but I'd much prefer to have a command that prevents me from doing so, and I can see a required restart being very problematic for server users.

Looking into this deeper, it seems source ~/.bashrc is capable of doing this on UNIX-based systems, but the same doesn't apply to Cygwin, presumably because Cygwin uses the Windows PATH environment variable rather than setting them explicitly in .bashrc.

I've posted a follow-up question to this here.

Hashim

Posted 2017-10-23T01:16:38.103

Reputation: 6 967

In the past for updating my environmental variables, I have just killed all the Explorer.exe task in Task Manager, then from Task Manager's File -> New Task menu option, I run Explorer.exe again. This forces Windows to pick up the new variables for me. Never had any issues doing this in Windows 7, but YMMV – abelito – 2019-04-07T12:14:36.403

0

*NIX works differently than Windows.

You will need to type out the full path /sbin/fdisk

Or, while in the /sbin directory you need to type ./fdisk

Here is how you can learn about and modify the *NIX $path environment variable.

Keltari

Posted 2017-10-23T01:16:38.103

Reputation: 57 019

By default on cygwin /sbin/ is not on the path, as usually on most Unix. – matzeri – 2017-10-23T15:45:27.650

I'm aware *NIX systems work differently to Windows, but Cygwin also isn't your average *NIX system because of needing to run on Windows, and so also works a little differently to *NIX. The following page from the Cygwin documentation seems to state that Cygwin inherits Windows' environment variables, which would seem to contradict with what you're saying here. In addition, running which fdisk does seem to return my PATH fine, it just can't find fdisk inside of it.

– Hashim – 2017-10-23T23:14:55.697

@Hashim try my answer it will work – Keltari – 2017-10-24T00:26:37.010

I'm aware that it works, because it's the full path to the executable, but typing that every time is annoying and cumbersome. The real issue here, which you seem to have overlooked, is that I'm not able to run fdisk as a standalone command like I am with every other command, and plastering over that problem by using the full path is a hacky solution, and not the one that I'm looking for. – Hashim – 2017-10-24T23:33:19.140