I have a script that does an "su - oracle" then runs exp. I need to store that file to a directory /app/dumps that the user "backups" has access to read + write the file.

What's the proper way to setup the /app/dumps directory so that "backups" has ownership to modify any files in the directory but "oracle" can still write data to the directory?


The easiest way to go around this is to use the directory sticky bit together with the appropriate group permissions.

  1. Create a new group: groupadd orabak
  2. Add both users to the group: usermod -G orabak oracle; usermod -G orabak backups
  3. Set the group sticky bit on the directory: chmod g+s /app/dumps
  4. Make sure that when the oracle and backups users write files, they do so with the group write bit set (you can use umask for this)

You should be able to accomplish what you're looking to do with these two commands:

chown oracle:backups /app/dumps
chmod 2370 /app/dumps

chown sets the owner of the directory to the oracle user and the group to the backup user.

chmod does the following:

  • Sets the setgid bit
  • Gives the owner (oracle) write/execute access
  • Gives the group (backups) read/write/execute access

Setting the setgid on a directory means that a file created in the directory will inherit the group of the directory and not of the creator. In your instance, this means that any files written there by oracle will have backups as a group.

Oracle can write to the dir but not read from it. If it needs to do so, change the permissions to 2770.

This also assumes that your script is creating the files with read/write access in the /app/dumps directory. If this isn't the case, you can run setfacl -d -m g::rw /app/dumps to set the default group permissions of files created in /app/dumps to be read/write.


If you do ls -alh /somedir you will get some thing like this

ls -alh /somedir 
drwxrwxrwx 1 owner   group  [size and date]  .
drwxrwxrwx 1 powner  pgroup [size and date]  ..
-rwxrwxrwx 1 owner   owner  [size and date]  somefile

As soon as you can make sense of this you will be able to figure out what permissions and owner ships you must set to your files. This Ubuntu Wiki entry will enlighten you.

This leaves you with some options:

  1. Create a croup named backup and add the user backups and oracle to it. The files that are groupowned by backups-group will now share access rights with the users backups and oracle.
  2. Create a group backups add the user backups ot it. Give ownership to user oracle and groupownership to group backups. This gives you seprated rights for user oracle and all the group members of group backup
  3. Do the same like in 2. but with oracle

The tools to do that are groupadd, chown, chmod, and usermod. The man pages will provide you with more detailed info. I know it is a bit of a RTFM answer. But I am sure that if you do the reading you will be able to handle Linux file permissions in the future. =) Good luck


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.