What does the ‘d’ mean in ls -al results and what is that slot called?

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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)

Method 2

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.

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d58517d5c535a5851544c58">[email protected]</a> ~/tmpdir $ mkdir my_empty_directory
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="64010824050a0301080d1501">[email protected]</a> ~/tmpdir $ touch myfile.txt
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef8a83af8e81888a83869e8a">[email protected]</a> ~/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

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="187d745879767f7d7471697d">[email protected]</a> /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

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="34515874555a5351585d4551">[email protected]</a> /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

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f5a537f5e51585a53564e5a">[email protected]</a> ~/tmpdir $ touch myfile.txt
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8de8e1cdece3eae8e1e4fce8">[email protected]</a> ~/tmpdir $ ln -s myfile.txt myfile2.txt
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91f4fdd1f0fff6f4fdf8e0f4">[email protected]</a> ~/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

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5d38311d3c333a3831342c38">[email protected]</a> /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

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a7f765a7b747d7f76736b7f">[email protected]</a> /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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x