Write a shell Script to assign a file permission to the given file using Symbolic Mode/Absolute Mode

clear
echo "Enter the file name "
read file
echo "Enter the file contents and press control + d"
cat>$file
echo
echo
echo "Permission for the file "
ls -l $file
echo
echo "Changing permission using symbolic mode"
chmod u+x $file
chmod g+wx $file
chmod o-r $file
echo "File permission after assigning permission using symbolic mode"
ls -l $file
echo
echo "changing permission using absolute mode"
chmod u=rw $file
chmod g=rw $file
chmod o=r $file
echo "File permission after assigning permission using absolute mode"
ls -l $file


OutPut

Enter the file name
file3
Enter the file contents and press control + d
ub
comp
unix


Permission for the file
-rw-r--r-- 1 shaan51 shaan51 13 2012-03-01 05:08 file3

Changing permission using symbolic mode
File permission after assigning permission using symbolic mode
-rwxrwx--- 1 shaan51 shaan51 13 2012-03-01 05:08 file3

No comments:

Post a Comment