Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I noticed on my home machine (OS X 10.6.6) that somehow the /dev/null folder got corrupted. It seemed to exist when browsing in Finder or Terminal, but wouldn't accept any output written to it, and I couldn't CHMOD it, etc. It seemed to be either dead or corrupted!

So I deleted it, and undertook the standard fix:

# rm /dev/null
# mknod /dev/null c 1 3
# chmod 666 /dev/null
# ls -l /dev/null

But, when I try typing mknod /dev/null c 1 3 I get an error message:

Illegal instruction

It's definitely gone - so I don't think I'm illegally trying to create the same folder.

I've tried looking for another combination - for example: mknod /dev/null c 2 2, etc - but nothing works.

What should I do?

share|improve this question
/dev/null isn't a "folder" (or directory), it's a special file. – Dennis Williamson Jan 28 '11 at 18:23
Did you make sure that you only have mknod in /sbin and not elsewhere earlier in your PATH? (check with type -a mknod in bash) – Doug Harris Jan 28 '11 at 20:17

On my system, it's 3, 2.

$ ls -l /dev/null
crw-rw-rw-  1 root  wheel    3,   2 28 Jan 19:01 /dev/null
share|improve this answer
I still get "Illegal Instruction" when I try: 'sudo mknod /dev/null c 3 2' – Jamison Jan 28 '11 at 18:11
@Jamison what about sudo mknod null c 3 2? The man mknod examples don't specify the whole path. – Daniel Beck Jan 28 '11 at 18:13
ahh! That's good thinking! - they just specify "name" as a parameter. Shucks - I just tried it, and got the same Illegal Instruction message – Jamison Jan 28 '11 at 18:16
Here's something strange: in FINDER, there is a symlink to DEV, but if I try to follow it I get a "Dev can’t be opened because the original item can’t be found." symlink error. But in Terminal, cd dev takes me right there and I can browse the contents normally with ls, etc. I'm not sure where the DEV folder is located now... – Jamison Jan 28 '11 at 18:24
@Jamison /dev doesn't open for me in Finder, too. Neither Go to Folder (which fails with "not found"), nor open /dev in Terminal. – Daniel Beck Jan 28 '11 at 18:28

The same problem here on Mac OS X 10.6.8 after testing the GNU script command using /dev/null as log file in a wrong way:

# wrong use of GNU script command (do not use it!)
#sudo sh -c '
#0<&- gscript -q /dev/null -c "x11vnc -storepasswd ~/.vnc/passwd << EOF

sudo ls -ld /
# Illegal instruction

ls -l /dev/null
# crw-------  1 root  wheel    3,   2 31 Jan 15:31 /dev/null

The solution that worked for me was to shut down the computer (by holding down the power button), restart it into single user mode (with cmd and s keys pressed) and then (twice) repeat /sbin/fsck -fy until the message appeared: ** The volume (name_of_volume) appears to be OK (see: Resolve startup issues and perform disk maintenance with Disk Utility and fsck).

share|improve this answer
On Mac OS X 10.6.8 I lost /dev/null after a 'port install' with the symptoms described by the OP. Just restarting into single user mode and then rebooting shutdown -r now (without doing any filesystem repairs) fixed the issue. (See also /dev/null permissions causing "Illegal instruction" for this exact solution.) – orbeckst Jul 8 '14 at 18:14

Yes, all comments and solutions (above) were correct - in the end, the filesystem was corrupted like I suspected.

The solution was to boot up with the INSTALL/BOOT disk, and run Disk Utility. Inside Disk Utility, I simply had to select my Hard Disk (they're listed by name), and then click the "Repair Disk" button - it scanned for a good 1.5 hours, and fixed all the errors, including restoring my Dev/Null folder.

I saw a lot of different instructions in online forums about how to boot up directly into Disk Utility - including "insert boot disk into drive, turn computer off, when re-booting, hold down the "C" key, and you will enter Disk Utility!"

ACTUALLY - that didn't work for my OS X 10.6.6 - I instead had to boot up with my boot disk, enter the OS X Install screens, and you can find the "Disk Utility" program in the "Utilities" menu.

Here are the steps- this works for any/all maintenance you want to do on your OS X 10.6.6 Filesystem:

NOTE: these are only instructions to repair your MAIN HARD DISK that you usually use to boot up. You can't repair this disk when you're running OS X, so you'll need to re-boot into your BootUp Disk to do the repairs. To repair any/all other disks, you can simply go to UTILITIES>Disk Utility, select the disk you want to repair, and click the "Repair" button.

TO FIX MAIN HARD-DISK (main boot up disk):

  1. Insert your OS X Disk into the computer (it could be your original OS X CD, or a USB key loaded with a copy of a OS X INSTALL disk.)
  2. Turn computer off.
  3. Restart computer while holding down ALT/OPTION key during boot-up, keep holding it until you see a screen that lists the different "boot" hard disks and/or USB keys currently plugged in to your system. In my case, I saw my installed Hard Disk (the old one I want to fix) and my OS X CD, which the system recognizes as a boot disk too.
  4. Click on the CD (or USB key).
  5. It will take 30secs to a minute, but your OS X Install screens will open up - click on the language you want (English in my case) and click continue.
  6. BE CAREFUL - in the next few screens, you don't want to click on "Install" or anything similar -you should now see a new MENU BAR along the top of your screen, with a menu called "Utilities". 7.Click on "Utilities" and select "Disk Utility".
  7. Now you're inside the Disk Utility program - simply select the Hard Disk you want to repair, and then click on the "REPAIR" button. It'll take an hour or two to scan and fix everything, but it should work!

When that finishes, click to CLOSE the Disk Utility program. I couldn't find any way to restart the computer, so I just held down the power button, and then again to re-start. Don't press anything and the computer should reboot into your main OS X install (hard disk) with no problems.

Thanks -

share|improve this answer
It's not a folder – miniBill Jan 31 '14 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .