-->

Shell Scripting to check file exist and whether file is writable or not

Posted by Admin on
Write a shell script to check to see if the file "/etc/shadow" exists. If it does exist, display "Shadow passwords are enabled." Next, check to see if you can write to the file. If you can, display "You have permissions to edit /etc/shadow." If you cannot, display "You do NOT have permissions to edit /etc/shadow." 



#! /bin/bash

if [ -e "/etc/shadow" ]
then
echo "Shadow Passwords are enabled"
if [ -w "/etc/shadow" ]
then
echo "You have permission to edit shadow password"
else
echo "You do not have permission to edit shadow passwords"
fi
else
echo "Shadow Passwords are not enabled"

fi

No comments:

Post a Comment