How to set sticky bit?

To set the sticky bit on a directory in a Unix-like operating system, you can use the chmod command. Here are the steps to do so:

  1. Open Terminal: Access your terminal or command line interface.

  2. Use chmod Command: You can set the sticky bit using either symbolic or octal notation.

    • Using Symbolic Notation:

      chmod +t directory_name

      Replace directory_name with the name of the directory where you want to set the sticky bit.

    • Using Octal Notation:
      You can also set the sticky bit along with other permissions using octal notation. For example, to set the sticky bit along with read, write, and execute permissions for everyone:

      chmod 1777 directory_name

      Here, 1 represents the sticky bit, and 777 represents read, write, and execute permissions for the owner, group, and others.

  3. Verify Sticky Bit: After setting the sticky bit, you can verify it by listing the directory's permissions:

    ls -ld directory_name

    Look for a t at the end of the permission string, indicating that the sticky bit is set.

Example

To set the sticky bit on a directory named shared_dir, you would run:

chmod +t shared_dir

or

chmod 1777 shared_dir

This will ensure that only the owners of files within shared_dir can delete or rename their files.

0 Comments

no data
Be the first to share your comment!