LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-29-2005, 07:16 PM   #1
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Rep: Reputation: 32
Permissions question: what does the


What does the C charater mean on a permissions string?

c-rx-x-xr
 
Old 03-29-2005, 07:20 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
The leading 'c' indicates the file is a device node for a character-based device (as opposed to a block device)
 
Old 03-29-2005, 07:38 PM   #3
yenonn
Member
 
Registered: Feb 2003
Location: Malaysia
Distribution: Redhat 8.0, 9, Slackware 9.1
Posts: 511

Rep: Reputation: 30
not understand... need more explanation...thanks
 
Old 03-29-2005, 08:02 PM   #4
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
d means it's a directory right? What other leading charaters are there?
 
Old 03-29-2005, 08:42 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
There are a couple different kinds:
  • '-' : a regular file
  • 'd' : a directory
  • 'l' : a symbolic link
  • 'b' : a block device
  • 'c' : a character device
  • 'p' : a named pipe
  • 's' : UNIX domain socket

The difference between a character device and a block device is in how much data a device can take/give to the computer. A character device can give/receive 1 character (one byte) at a time. A block device handles chunks/blocks of data; typically a block is 512 bytes, but it can vary depending on the device.
 
Old 03-29-2005, 09:00 PM   #6
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
Quote:
Originally posted by Dark_Helmet
There are a couple different kinds:
  • '-' : a regular file
  • 'd' : a directory
  • 'l' : a symbolic link
  • 'b' : a block device
  • 'c' : a character device
  • 'p' : a named pipe
  • 's' : UNIX domain socket

The difference between a character device and a block device is in how much data a device can take/give to the computer. A character device can give/receive 1 character (one byte) at a time. A block device handles chunks/blocks of data; typically a block is 512 bytes, but it can vary depending on the device.
Ah... excellent!

Can you possiblely give me an example of what a block device, character device, named pipe, and UNIX domain socket is and how the premissions apply to it?

I'm gueesing that a block device is a hard drive and the premissions apply to who can use that drive...
 
Old 03-29-2005, 09:41 PM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Well, both character and block devices are "communication points" to the actual hardware. In UNIX, accessing anything is synonymous to accessing a file. So those character and device file entries are the means for what are called "user space" programs to access the hardware. Whether a device is a character or block device completely depends on how the device was built/designed. However, your hunch is correct. Your hard drive is a block device; it's capable of moving large quantities of data at once. Most storage devices are block devices (floppy disks, CD ROM drives, USB sticks, etc.) Some examples of character devices are your keyboard and the mouse; they don't need to move a whole lot of data.

A named pipe is probably exactly what you think it would be if I forced you to come up with something. You're familiar with "piping" one command's output to another, right?
Code:
ls -l | grep "^d"
A named pipe is pretty much the same thing, without forcing you to specify the interacting commands. It looks, smells, and acts just like a normal file, but when a process writes to it, the operating system holds onto that information until another process reads from it. So, an equivalent example to the command above would be:
Code:
mkfifo named_pipe
ls -l > named_pipe &
grep "^d" < named_pipe
rm named_pipe
The reason you have to background the ls command is because reading or writing from/to the pipe will "block" the process until there's data to give to it. In other words, your shell would sit there and stare at you. You'd have to open another shell to do the grep. What's nice about this is, you could have more than one process shoving data into the pipe, and one "traffic cop" type of process to receive all the data, and organize & present it in some interesting fashion.

A socket is very similar to a pipe, but I don't have much experience with them. It's very similar to traditional networking (where you make a client-server connection through a socket). It's a means to pass data back and forth between two processes. In fact, the only time I've ever encountered one is in messing with a MySQL server. The server sets up a socket file to allow processes running on the local machine to access the server to do database queries and the like.

Permissions for all of these guys is right along the lines of what you were thinking. Reading and writing are probably the only permissions that make sense for any of these items. I mean, it doesn't make any sense to "execute" a device, a pipe, or a socket.
 
Old 03-29-2005, 10:16 PM   #8
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
Thanks! ...that's pretty much what I figured but it good to have somebody like you make the hunch redundant! I've had to use a "UNIX socket" with logging output from snort before... I figured it was some kind of network type communication but it sounds more like a metaphor than a physical facility.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Another permissions question BajaNick Linux - Software 2 01-21-2004 11:40 AM
Permissions Question dragin33 *BSD 1 01-05-2004 06:35 PM
Permissions question sammckee Linux - Newbie 3 09-23-2003 10:55 AM
Permissions question... phil1076 Linux - General 3 09-03-2003 10:50 AM
Permissions Question? gsmonk Linux - General 3 08-27-2003 03:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:16 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