Script shell lấy đường dẫn hiện tại Centos
bash
1#!/bin/bash2# Purpose: Set file permission to read-only3# Author: nixCraft <www.cyberciti.biz> under GPL v2.0+4# ---------------------------------------------------------------5# DocumentRoot permissions 6_dp="0544"7_fp="0444"8_sp="0744"9 10# Apache user/group11_user="www-data"12_group="www-data"13 14## If $1 is not passed, set to the current working dir using $PWD15_dir="${1:-${PWD}}"16 17## Die if $dir does not exists18[ ! -d "$_dir" ] && { echo "Error: Directory $_dir not found."; exit 2; }19 20## Get confirmation 21echo "I will change file permission for the webserver dir and files to restrictive read-only mode."22read -p "The current working dir is ${PWD}. Are you sure (y / n) ?" ans23 24## Lowercase $ans and compare it 25if [ "${ans,,}" == "y" ]26then27 chown -R ${_user}:${_group} "$_dir"28 chmod -R $_fp "$_dir"29fi



