/dev/null file issue | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

/dev/null file issue

AIX


Tags
aix, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-25-2013
jayadeava jayadeava is offline
Registered User
 
Join Date: May 2011
Last Activity: 27 June 2014, 4:54 PM EDT
Posts: 17
Thanks: 14
Thanked 0 Times in 0 Posts
IBM /dev/null file issue

Hi Experts,

I Have a query. In one of my server I just came to know that there was /dev/null file which is a not a character file. Its just a normal file. I know the command to create the character file (/dev/null) but what is the procedure. Like should i delete /dev/null and create or anything else. I have a doubt that we can't remove /dev/null right ?

Expected format:
crw-rw-rw- 1 root system 2, 2 Feb 25 15:13 /dev/null

Format in my server:
-rw-rw-rw- 1 root system 0 Feb 25 15:22 /dev/null

Thanks & Regards,
B. Jayadeava
Sponsored Links
    #2  
Old 02-25-2013
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 18 October 2014, 9:20 PM EDT
Location: Saskatchewan
Posts: 19,614
Thanks: 811
Thanked 3,329 Times in 3,118 Posts
Take my advice with a grain of salt since I'm not an AIX expert, but: Having a /dev/null that is not a character device could be a big problem, yes! Things might create huge files in it, expecting them to go into the bit bucket, but actually ending up on disk instead... Some memory mapping things might not work right... etc.

You're generally not supposed to delete anything in /dev/, no. But when things are messed up like this, don't know what else you're supposed to do.

See those numbers there, 2,2? They're what make /dev/null act like /dev/null and not be some other device. You give those to mknod when you create it, and also give it c to tell it it's a character device and not a block one.


Code:
rm /dev/null ; mknod -m 0666 /dev/null c 2 2 ; chown root:system /dev/null


Last edited by Corona688; 02-25-2013 at 10:51 AM..
The Following User Says Thank You to Corona688 For This Useful Post:
jayadeava (03-08-2013)
Sponsored Links
    #3  
Old 02-25-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 973 Times in 789 Posts
Disclaimer: I have never used AIX. Everything I say below is based on the OP's statement that /dev/null is a regular file.

Quote:
Originally Posted by Corona688 View Post
Take my advice with a grain of salt since I'm not an AIX expert, but: Having a /dev/null that is not a character device could be a big problem, yes! Things might create huge files in it, expecting them to go into the bit bucket, but actually ending up on disk instead... Some memory mapping things might not work right... etc.
Although a less common scenario, there are times when using /dev/null for reading is useful. One example that comes to mind is with grep, to force its output to include filenames, you may explicitly list /dev/null in a find -exec predicate or an xargs invocation, to ensure that grep is never called with a single file argument. If /dev/null does not yield nothing but EOF ... woe.

Regards,
Alister

Last edited by alister; 02-25-2013 at 01:26 PM..
The Following User Says Thank You to alister For This Useful Post:
jayadeava (03-08-2013)
    #4  
Old 02-25-2013
MichaelFelt MichaelFelt is offline
Registered User
 
Join Date: Nov 2012
Last Activity: 11 December 2013, 7:33 AM EST
Location: on the road for work; home is private time
Posts: 311
Thanks: 6
Thanked 76 Times in 71 Posts
I think a more AIX way of recreating /dev/null on AIX is:


Code:
# rm /dev/null
# cfgmgr

I would be curious to know how it became a character file (implies someone with write perms on /dev removed it, and the first person to write to /dev/null (would be the new owner) recreated it as a regular file. I would expect that there is a script being run by root that is deleting it, and writing it again. Since you show 0 bytes, it is also being truncated as well.

So, your second security issue is when is it being removed? If you cannot answer this, the issue will come back and haunt you.
The Following User Says Thank You to MichaelFelt For This Useful Post:
jayadeava (03-08-2013)
Sponsored Links
    #5  
Old 02-26-2013
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 19 October 2014, 3:14 PM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 4,282
Thanks: 45
Thanked 824 Times in 651 Posts
Was/is the file really "/dev/null" or is it rather "/dev/nulll" (3 "l"s!) ? The latter is a residue of some typo in an AIX script, i believe. I have seen it at various customers even in newly installed systems, so i suppose some IBM script, maybe in the HACMP installation procedure, is the culprit.

See also this thread .

I hope this helps.

bakunin
The Following 2 Users Say Thank You to bakunin For This Useful Post:
Corona688 (02-28-2013), jayadeava (03-08-2013)
Sponsored Links
    #6  
Old 03-08-2013
jayadeava jayadeava is offline
Registered User
 
Join Date: May 2011
Last Activity: 27 June 2014, 4:54 PM EDT
Posts: 17
Thanks: 14
Thanked 0 Times in 0 Posts
No it was /dev/null only... N i tried rm /dev/null but din allow me to...
Sponsored Links
    #7  
Old 03-08-2013
Peasant's Avatar
Peasant Peasant is offline
Registered User
 
Join Date: Mar 2011
Last Activity: 20 October 2014, 3:22 AM EDT
Posts: 665
Thanks: 18
Thanked 149 Times in 145 Posts
Real worls example of /dev/null usage with grep on HPUX systems, where grep lacks option to show filename where grep has matched the result.

Code:
find . -type f -exec grep "string" {} /dev/null \;
/root/test/string.txt:string

Sorry for the offtopic.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Redirecting standard out to /dev/null goes to file "/dev/null" instead jbmorrisonjr Shell Programming and Scripting 5 06-06-2012 07:27 PM
/dev/null 2>&1 Versus /dev/null 2>1 glev2005 UNIX for Dummies Questions & Answers 3 03-08-2011 01:20 PM
What is /dev/tty /dev/null and /dev/console civic2005 Solaris 12 01-04-2008 06:56 AM
mv /dev/null file raj8 UNIX for Dummies Questions & Answers 3 07-17-2003 04:36 PM
Has anyone seen this issue with the /dev/null? oott UNIX for Advanced & Expert Users 4 09-18-2002 02:31 PM



All times are GMT -4. The time now is 05:44 AM.