What does the 's' in srwxr-xr-x in the 'ls' output mean?
Solution 1
From the ls
manual:
The file type is one of the following characters:
‘-’ regular file
‘b’ block special file
‘c’ character special file
‘C’ high performance (“contiguous data”) file
‘d’ directory
‘D’ door (Solaris 2.5 and up)
‘l’ symbolic link
‘M’ off-line (“migrated”) file (Cray DMF)
‘n’ network special file (HP-UX)
‘p’ FIFO (named pipe)
‘P’ port (Solaris 10 and up)
‘s’ socket
‘?’ some other file type
So, that's a Unix socket. It could be meaningful, since sockets are created by processes to listen for requests. Use lsof
to determine what process is using that socket.
You may need to use sudo
with lsof
, if the socket is opened by a process running as another user:
$ lsof /run/snapd.socket
$ sudo lsof /run/snapd.socket
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd 1 root 197u unix 0xffff99dc9afa3000 0t0 191670 /run/snapd.socket type=STREAM
snapd 18626 root 8u unix 0xffff99dc9afa3000 0t0 191670 /run/snapd.socket type=STREAM
Solution 2
You could use file
command to determine its type too:
$ file /tmp/ssh-k405k6mf0/agent.1221
/tmp/ssh-k405k6mf0/agent.1221: socket
or even mimetype
:
$ mimetype /tmp/ssh-k405k6mf0/agent.1221
/tmp/ssh-k405k6mf0/agent.1221: inode/socket
Solution 3
To add up, this file type is also called special file there are multiple special files exist in UNIX (all of them are listed as part of ls manual, useful snippet is provided by muru).
Further read - https://www.linux.com/blog/file-types-linuxunix-explained-detail
Related videos on Youtube
hol
Updated on September 18, 2022Comments
-
hol over 1 year
I have a directory entry as follows
srwxr-xr-x 1 ubuntu ubuntu 0 May 29 05:03 0.0.0.0=
I do not know what the
s
means and also that is a strange file name and I wonder what it is good for. Could this be garbage or is it something meaningful?-
0x2b3bfa0 almost 7 yearsRemotely related question: askubuntu.com/questions/626634/converting-a-file-to-directory/… On the answer there is a script that explains and calculates the inode modes.
-
-
Clayton almost 7 yearsYour answer is not wrong. To make it better, consider adding additional information to your answer - such as that it is a socket file. Links can provide extra information, but your answer should be able to stand on its own without the link and still provide a thorough response.
-
gardenhead almost 7 yearsYou can also use
fuser
to determine the processes using a file.