Protecting Files with the Sticky Bit

Unix Power Tools
Protecting Files with the Sticky Bit

by Jerry Peek
01/27/2000

Unix directory access permissions say that if a user has write permission on a directory, she can rename or remove files there–even files that don't belong to her. Many newer versions of Unix have a way to stop that. The owner of a directory can set its sticky bit. The only people who can rename or remove any file in that directory are the file's owner, the directory's owner, and the superuser.

Here's an example: the user jerry makes a world-writable directory and sets the sticky bit (shown as t here):


jerry% mkdir share

jerry% chmod 1777 share

jerry% ls -ld share

drwxrwxrwt   2 jerry    ora           32 Nov 19 10:31 share

Other people create files in it. When jennifer tries to remove a file that belongs to ellie, she can't:


jennifer% ls -l

total 2

-rw-r--r--   1 ellie    ora          120 Nov 19 11:32 data.ellie

-rw-r--r--   1 jennifer ora         3421 Nov 19 15:34 data.jennifer

-rw-r--r--   1 peter    ora          728 Nov 20 12:29 data.peter

jennifer% rm data.ellie

data.ellie: 644 mode ? y

rm: data.ellie not removed.

Permission denied


Back More Unix Power Tools

 

Close    To Top
  • Prev Article-OS: None
  • Next Article-OS:
  • Now: Tutorial for Web and Software Design > OS > Linux > OS Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction