Requirements:
1. Create a directory/tmp/scripts
2. Switch the working directory to this directory
3. Copy the/ETC/PAM.D directory to the current directory and rename it to test
4. Change the current directory's test and the owner of the files and subdirectories inside to Redhat
5. Change the permissions of other users of the files in test and its subdirectories to no permissions
#!/bin/bash //program starts #file: chmod.sh#date: 2016-01-13dir= "/tmp/scripts/" //Assigning a directory to a variable if [ ! -d "$dir" ] ; then //this if statement to determine the directory, does not exist to create mkdir -p $direlse echo "This dir is exists." firm -rf /tmp/scripts/* //Clear all contents of directory cd $dir && cp -R /etc/pam.d . && mv pam.d test // Copy directory and modify directory name rm -rf /home/redhat | | useradd redhat && groupadd redhat //creating users and Groups If [ $? -eq 0 ] ; then //this if statement to modify the property chown -R redhat:redhat $dir/test chmod -R o-x $dir/test echo "congratulations, your work is ok!" else echo "Test directory permisson can ' t change! " fi //program Start
This article from "Experience from pain" blog, declined reprint!
Shell---Practice3