Reputation: 4562
I need to create a file with the following permission
srw-rw-rw- 1 own group 0 Feb 6 22:12 myfile
I know chmod 666 would create the 'rw's, but what command to use to create the first s?
Upvotes: 6
Views: 17795
Reputation: 2003
As vjayalakshmi points out, the first character is the file type (normal, directory, fifo, socket, etc). chmod +s
just sets the setuid/setgid bits. These bits imply executability, which is why ls
puts the 's' where the 'x' would usually go - it tells you two things with one character (executable, plus set user/group id), giving you the -rwsrwsrw-
result you are seeing after trying +s with chmod
. IOW, chmod
does exactly what it's name implies - it sets the file access modes, which have nothing to do with file type.
Normally, to create a socket you'd want to do it in a program (i.e. use the socket(2)
system call).
If you really want to create a socket from the command line (and, of course, depending on what you are trying to do), you can try using the nc
command. Also, Tcl has a socket
command - see http://www.tcl.tk/man/tcl8.4/TclCmd/socket.htm for more info.
Upvotes: 7
Reputation: 726
The first bit in the file permission is about the file type. The file that you are creating should be of entry type socket to have that s character in the first bit. Refer this link http://www.cyberciti.biz/faq/explain-the-nine-permissions-bits-on-files/
The Entry Type
There are total 10 bits -rw-r--r--: The file mode printed under the -l option consists of the entry type (1st bit) and the permissions (9 bits). The entry type character describes the type of file, as follows:
- Regular file. b Block special file (stored in /dev). c Character special file (stored in /dev). d Directory. l Symbolic link. p FIFO. s Socket. w Whiteout.
Upvotes: 4