LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: Disabled
block special and character special files


Hello,

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

Thanks.
 
Old 04-20-2005, 03:49 PM   #2
cyent
Member
 
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 398

Rep: Reputation: 87
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)

You can write to it too. DON'T DO THIS! NO! THIS WILL ZERO YOUR HARDDRIVE NO QUESTIONS ASKED!!!!
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
Fortitude1
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
cyent
Member
 
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 398

Rep: Reputation: 87
It's are rather powerful unifying paradigm...
 
Old 06-23-2015, 02:16 AM   #5
veerain
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.
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:51 PM.

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