Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In Linux, what does the d mean in the first position of drwxr-xr-x? And what are all of the possible letters that could be there, and what do they mean?

I'm trying to learn more about the Linux file permissions system, and I'd like to see a list of the character meanings for the first slot.

share|improve this question

2 Answers 2

up vote 16 down vote accepted

It means that it is a directory. The first mode field is the "special file" designator; regular files display as - (none). As for which possible letters could be there, on Linux the following exist:

  • d (directory)
  • c (character device)
  • l (symlink)
  • p (named pipe)
  • s (socket)
  • b (block device)
  • D (door, not common on Linux systems, but has been ported)
share|improve this answer

On Gentoo, what the first character in a linux file permissions drwxrwxrwx means:

The first character gives you a hint of the type of object it is.

Possible values for that first character: ( -, d, c, l, p, s, b, D )

- (dash) means file and and d means directory.

el@angeliqe ~/tmpdir $ mkdir my_empty_directory
el@angeliqe ~/tmpdir $ touch myfile.txt
el@angeliqe ~/tmpdir $ ls -al
total 16
drwxrwxr-x 3 el users 4096 Dec 21 13:06 .
drwx--x--x 9 el users 4096 Dec 21 11:47 ..
drwxrwxr-x 3 el users 4096 Dec 21 11:54 my_empty_directory
-rw-rw-r-- 1 el users  182 Dec 21 11:45 myfile.txt

my_empty_directory has a 'd' and is a directory, and myfile.txt has a '-' and is a normal text file.

c means character device file

el@angeliqe /dev $ ls -al
total 4
drwxr-xr-x 12 root root      4080 Dec 19 21:18 .
drwxr-xr-x 20 root root      4096 Nov  3 19:00 ..
crw-rw----  1 root tty     7, 133 Nov 24 10:13 vcsa5

vcsa5 is a character device file. Find character device files with this command: find / -type c -print 2>/dev/null

b means block device

el@angeliqe /dev $ ls -al
total 4
drwxr-xr-x 12 root root      4080 Dec 19 21:18 .
drwxr-xr-x 20 root root      4096 Nov  3 19:00 ..
brw-rw----  1 root disk    8,   0 Nov 24 10:13 sda

sda is a block device. Find block device files with this command: find / -type b -print 2>/dev/null

l means link

el@angeliqe ~/tmpdir $ touch myfile.txt
el@angeliqe ~/tmpdir $ ln -s myfile.txt myfile2.txt
el@angeliqe ~/tmpdir $ ls -al
total 8
drwxrwxr-x 2 el users 4096 Dec 21 13:23 .
drwx--x--x 9 el users 4096 Dec 21 13:22 ..
-rw-rw-r-- 1 el users    0 Dec 21 13:23 myfile.txt
lrwxrwxrwx 1 el users   10 Dec 21 13:23 myfile2.txt -> myfile.txt

myfile2.txt is a symbolic link to myfile.txt. Find symbolic link files with this command: find / -type l -print 2>/dev/null

p means named pipe

el@angeliqe /dev $ ls -al
total 4
drwxr-xr-x 12 root root      4080 Dec 19 21:18 .
drwxr-xr-x 20 root root      4096 Nov  3 19:00 ..
prw-------  1 root root         0 Nov 24 10:13 initctl

initctl is a named pipe. Find pipe files with this command: find / -type p -print 2>/dev/null

s is a socket

el@angeliqe /dev $ ls -al
total 4
drwxr-xr-x 12 root root      4080 Dec 19 21:18 .
drwxr-xr-x 20 root root      4096 Nov  3 19:00 ..
srwxrwxrwx  1 root root         0 Nov 24 10:13 gpmctl

gpmctl is a socket. Find socket files with this command: find / -type s -print 2>/dev/null

D means door

None found on my Gentoo.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.