Operating System - HP-UX
1832218 Members
1807 Online
110041 Solutions
New Discussion

Finding block and character devices

 
Alistair Scott
Occasional Contributor

Finding block and character devices

Hello All,

Can anyone tell me the best way to find all block and character device files on a system ?
Can this be done using the find command ?

Thanks
5 REPLIES 5
Helen French
Honored Contributor

Re: Finding block and character devices

You can do this with the find command. You have to use option -type "b" for block and "c" for character special files. For eg:

# find / -type b -depth -print > /tmp/block_files

Life is a promise, fulfill it!
John Palmer
Honored Contributor

Re: Finding block and character devices

Yes, you can use find with -type b for block devices or -type c for character devices. man find for details.

e.g.

find / -type b
find / -type c

Regards,
John
John Palmer
Honored Contributor

Re: Finding block and character devices

You can also find both types with one command, with:

find / \( -type b -o -type c \)

Regards,
John
omars
Advisor

Re: Finding block and character devices

Hi ,

Best to use the command

a.) lsdev | more

b.) the device files are
stored in /dev directory.
These are so called "block & character" files

c.) alternative the find command will assist you

To create device files ,you can use
a.) insf
b.) mksf
c.) mknod

Hope this helps

rgds,
omari

Nothing is too late to learn
Bill Hassell
Honored Contributor

Re: Finding block and character devices

And just a note for good sysadmin practices. The mknod command can create a device file anywhere but for consistency, they should all appear in /dev. From a security point of view, a rogue device file in /tmp or /home... can be a security risk.


Bill Hassell, sysadmin