#!/bin/bash if [[ "$1" && "$2" ]]; then readonly USER1="$1" USER2="$2" else echo $"Two users should be specified by the 1st and the 2nd arguments." > /dev/stderr exit 1 fi set -ex # Exit on failures and echo what is done. # Clean up: rmdir rw-dir ||: # Show perms for the working dir: ls -ld . # Prepare: su -c 'mkdir -p rw-dir' "$USER1" su -c 'chmod a+w rw-dir' "$USER1" ls -ld rw-dir # Try to modify: su -c 'chmod a-w rw-dir' "$USER2" ls -ld rw-dir