Skip to main content
deleted 138 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165
chmod g+s .; 

This command sets the "set group ID" (setgid) mode bit on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the files' group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike C or Perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

Documentation

As an added noteFor more information, I think thesee man chmod. Also, wikipedia has tables fromsummarizing the Wikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others toocommand options.

chmod g+s .; 

This command sets the "set group ID" (setgid) mode bit on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the files' group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike C or Perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

As an added note, I think the tables from the Wikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others too.

chmod g+s .; 

This command sets the "set group ID" (setgid) mode bit on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the files' group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike C or Perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

Documentation

For more information, see man chmod. Also, wikipedia has tables summarizing the chmod command options.

Improved wording, grammar and formatting; fixed capitalization.
Source Link
chmod g+s .; 

This command sets the "set group IDID" (setgid) mode bit on the current directory, written as ...

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the file'sfiles' group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike cC or perlPerl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

As a finalan added note, I think the tables from the wikipediaWikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others too.

chmod g+s .; 

This command sets the group ID (setgid) on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the file's group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike c or perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

As a final added note, I think the tables from the wikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others too.

chmod g+s .; 

This command sets the "set group ID" (setgid) mode bit on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the files' group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike C or Perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

As an added note, I think the tables from the Wikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others too.

Added a link to the chmod symbolic mode tables in wikipedia and the equivalence between s and setuid/gid
Source Link
chmod g+s .; 

This command sets the group ID (setgid) on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the file's group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike c or perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

As a final added note, I think the tables from the wikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others too.

chmod g+s .; 

This command sets the group ID (setgid) on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the file's group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike c or perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 
chmod g+s .; 

This command sets the group ID (setgid) on the current directory, written as ..

This means that all new files and subdirectories created within the current directory inherit the group ID of the directory, rather than the primary group ID of the user who created the file. This will also be passed on to new subdirectories created in the current directory.

g+s affects the file's group ID but does not affect the owner ID.

Note that this applies only to newly-created files. Files that are moved (mv) into the directory are unaffected by the setgid setting. Files that are copied with cp -p are also unaffected.

Example

touch un; chgrp canard .; chmod g+s .; touch deux ; 

In this case, deux will belong to group canard but un will belong to the group of the user creating it, whatever that is.

Minor Note on the Use of Semicolons in Shell Commands

Unlike c or perl, a shell command only needs to be followed by a semicolon if there is another shell command following it on the same command line. Thus, consider the following command line:

chgrp canard .; chmod g+s .; 

The final semicolon is superfluous and can be removed:

chgrp canard .; chmod g+s . 

Further, if we were to place the two commands on separate lines, then the remaining semicolon is unneeded:

chgrp canard . chmod g+s . 

As a final added note, I think the tables from the wikipedia article on chmod are very helpful. Because I use them often, recalling the equivalence of w=write and r=read and x=execute is easy for me, but because I use it rarely, I'm always forgetting that s=setuid/gid, so I add it here in case it helps others too.

Makes the heading more clear since it's mostly off topic
Source Link
Loading
added 58 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165
Loading
added 19 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165
Loading
added 668 characters in body
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165
Loading
Source Link
John1024
  • 76.4k
  • 12
  • 176
  • 165
Loading