PC & IT SUPPORT MADE EASY FORUM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Web Dev Owner Tool

Go down

Web Dev Owner Tool Empty Web Dev Owner Tool

Post by jamied_uk 4th July 2021, 17:16

Web Dev Owner Tool (c)J~~Net 2021



This will search for files in web directory owned by a user of your choice and change ownership to another user of your choice!


own.sh

Code:
#!/bin/bash
# (c) J~Net 2021
# jnet.sytes.ent
#
# https://jnet.forumotion.com/t1749-web-dev-owner-tool#2708
#
# ./own.sh   (Edit Before Running)!
#
targetname="root"
path="/var/www" # Path
username="www-data" # Username to be owned by!
group=":sftp_users"  # Group Membership (not mandatory) Comment out this line to ignore group part!
#
echo -en "\e[92mWelcome To (c)J~Net Owner Program 2021 "
#
echo "Current Config:"
echo ""
echo "Target Username: $targetname"
echo ""
echo "Target Path: $path"
echo ""
echo "New Owner Will Be: $username"
echo ""
echo ""

while true; do
    read -p "Do you wish to continue y/n?" yn
    case $yn in
        [Yy]* )
echo "Setting Ownership..."
sudo chown -R $username$group $path
echo ""

echo "Listing out any files that are owned by $targetname"
echo ""
for i in $(sudo find $path -user $targetname -name "*.*")
do
    echo "$i"
  #  sudo chown $username:$group $i
done
 break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done

Now edit the file for your needs

Code:
sudo gedit own.sh


Make executable

Code:
sudo chmod +x *.sh

Run

Code:
./own.sh
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Web Dev Owner Tool Empty Re: Web Dev Owner Tool

Post by jamied_uk 4th July 2021, 18:10

On the video you see me use key words like bedit

Code:
alias bedit='sudo gedit ~/.bashrc'

Needs to be in your bashrc file to use this key word!

To edit that type

Code:
sudo gedit ~/.bashrc
jamied_uk
jamied_uk
Admin

Posts : 2951
Join date : 2010-05-09
Age : 41
Location : UK

https://jnet.sytes.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum