-->

Changing Permissions Security Settings On Linux

Changing Security Settings

If you’ve already created a file or directory and need to change the security settings on it, Linux has a few different utilities available for this. This section shows you how to change the existing permissions, the default owner, and the default group settings for a file or directory.


Changing permissions


The chmod command allows you to change the security settings for files and directories. The format of the chmod command is:

chmod options mode file

The mode parameter allows you to set the security settings using either octal or symbolic mode. The octal mode settings are pretty straightforward; just use the standard three-digit octal code you want the file to have:

$ chmod 760 newfile
$ ls -l newfile
-rwxrw–- 1 rich rich 0 Sep 20 19:16 newfile
$

The octal file permissions are automatically applied to the file indicated. The symbolic mode permissions are not so easy to implement.

Instead of using the normal string of three sets of three characters, the chmod command takes a different approach. The following is the format for specifying a permission in symbolic mode:

[ugoa…][[+-=][rwxXstugo…]

Makes perfectly good sense, doesn’t it? The first group of characters defines to whom the new permissions apply:

  • u for the user
  • g for the group
  • o for others (everyone else)
  • a for all of the above

Next, a symbol is used to indicate whether you want to add the permission to the existing permissions (+), subtract the permission from the existing permission (−), or set the permissions to the value (=).

Finally, the third symbol is the permission used for the setting. You may notice that there are more than the normal rwx values here. These are the additional settings:

  • X assigns execute permissions only if the object is a directory or if it already had execute permissions.
  • s sets the UID or GID on execution.
  • t saves program text.
  • u sets the permissions to the owner’s permissions.
  • g sets the permissions to the group’s permissions.
  • o sets the permissions to the other’s permissions.
Using these permissions looks like this:


$ chmod o+r newfile
$ ls -lF newfile
-rwxrw-r— 1 rich rich 0 Sep 20 19:16 newfile*
$

The o+r entry adds the read permission to whatever permissions the everyone security
level already had.

$ chmod u-x newfile
$ ls -lF newfile
-rw-rw-r— 1 rich rich 0 Sep 20 19:16 newfile
$

The u-x entry removes the execute permission that the user already had. Note that the –F option for the ls command indicates whether a file has execution permissions by adding an asterisk to the filename.

The options parameters provide a few additional features to augment the behavior of the chmod command. The -R parameter performs the file and directory changes recursively.

You can use wildcard characters for the filename specified, changing the permissions on multiple files with just one command.

0 Response to "Changing Permissions Security Settings On Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel