Shell---Practice3

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.