Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-19-2005, 04:49 AM   #1
LQ Newbie
Registered: Apr 2005
Location: India
Distribution: Red Hat 8
Posts: 5

Rep: Reputation: Disabled
block special and character special files


My query is how to view the contents of block special and character special files.

Old 04-20-2005, 03:49 PM   #2
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 351

Rep: Reputation: 78
First thing you need to have firmly welded into your head is that in Unix everything is a file, and a file is just a stream of bytes.

Disk drives, graphics cards, mice, network cards, files, directories, memory, etc. etc. etc. everything is a file and file is just a stream of bytes.

So the short answer is is that anything that can read a file, can read any file.

Ooh. "cat" can. "less" can. And editor can! Wow!

Ok, cool it for a moment. Some of those files are pretty big and a editor that pulls the whole file into memory may struggle a little, especially if it is the "memory" file !
ls -l /proc/kcore
-r-------- 1 root root 519241728 Apr 21 08:40 /proc/kcore

Next you may find some of the "special files" are there but nothing is attached or you don't have permission.

cat /dev/hdd
cat: /dev/hdd: Permission denied

So you need to be root...
su -
Password: ******
cat /dev/hdd
cat: /dev/hdd: No such device or address

The file is there, but there is no device behind it. So opening the file gets me nowhere fast.

Lets try /dev/hda
cat /dev/hda
....screenfulls of binary garbage...

Well, that worked. Sort of. (Hint to unscramble your terminal type "reset" and hit enter)

cat /dev/zero > /dev/hda

Don't DO THAT!!!

How ever, block and char special devices usually speak some protocol. You say something to them (write to file) and they say something in some strict format back to you.

Often you will find life easier to talk to them via an appropriate driver. eg. the /dev/hd* you use
"mount /dev/hdc /mnt/cdrom" and mount and the OS do magic for your and turn that ghastly stream of bytes into a file system.

Or use X windows to talk to your graphics card. etc.

So the question really is, so now you know you can _always_ read and write to a block and char special, which one is it and what do you want to say to it?

Last edited by cyent; 04-20-2005 at 06:39 PM.
Old 06-22-2015, 08:15 AM   #3
LQ Newbie
Registered: Jun 2015
Location: Toronto, ON., Canada
Posts: 9

Rep: Reputation: Disabled
Talking Wow, the heavens just opened up for on this matter

I'm beginning to think that this site might be a first stop repository for me
Old 06-22-2015, 03:56 PM   #4
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 351

Rep: Reputation: 78
It's are rather powerful unifying paradigm...
Old 06-23-2015, 02:16 AM   #5
Senior Member
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
You can only read serially char files. And for block file in block of data and may be able to specify position of device to read.

Rest follow what @cyent said.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I insert special character with alt? Meriadoc Linux - Newbie 5 05-17-2006 10:42 AM
samba: special character (umlaute) garbled DexterF Slackware 7 02-13-2004 04:49 PM
special character boolim Linux - General 1 08-29-2003 09:57 AM
how to echo special character question ArnaudVR Linux - Software 1 06-29-2003 11:11 AM
i need help with a special character Hone101 Linux - Newbie 1 05-03-2003 07:21 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration