bash betiği içindeki dosyaların sahipliğini değiştirme


-1

Kullanıcının sahip olduğu ilk iki dosyayı ve kök olarak sahip olduğu sonraki üç dosyayı çıkaran bu bash betiğine sahibim:

##################################################
# Variables
NUM="6"     #number of backup files to keep
LOGFILE="/home/boudiccas/cron/obnam-ls.txt"
####################################################

# Change into new directory
cd /home/boudiccas/cron/obnam/

# Generate new file and save it
sudo -u boudiccas obnam ls>"obnamhome-ls-$(date +%Y-%m-%d).txt"

sudo -u boudiccas obnam --config=/etc/obnam-back4.conf ls>"obnamback4-ls-$(date +%Y-%m-%d).txt"

obnam --config=/etc/obnametc.conf ls>"obnametc-ls-$(date +%Y-%m-%d).txt"

obnam --config=/etc/obnamusr.conf ls>"obnamusr-ls-$(date +%Y-%m-%d).txt"

obnam --config=/etc/obnamvar.conf ls>"obnamvar-ls-$(date +%Y-%m-%d).txt"

# Delete old backups!
find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamhome-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1

find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamback4-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1

find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnametc-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1

find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamusr-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1

find /home/boudiccas/cron/obnam -type f -mtime +$NUM -name 'obnamvar-ls-*.txt' -exec rm -v {} + >>$LOGFILE 2>&1
########################################################################

Lütfen son üç dosyayı kullanıcı tarafından yazılan script ile nasıl alabilirim?

Yanıtlar:


4

Bir dosyanın sahipliğini değiştirmek için chown, şu şekilde kullanabilirsiniz :

chown newuser myfile

veya grubu da değiştirmek istiyorsanız:

chown newuser:newgroup myfile

Senin durumunda, daha sudo -u boudiccasönce eklemek için son 3 satırını değiştirebilirsin obnam ..., hile yapması gerekir.


Teşekkürler, boğulma hakkında biliyorum ama gerçekten senaryoda gidip otomatik olarak yapılabilecek bir şey arıyorum.
— boudiccas

4
@ user205787 ve chownbetiğinize bazı komutlar eklemeyi engelleyen nedir?
— Levans

Haklıydın Levans, chown istediğim her şeyi yaptı, hoş ve basit ve kolay. Teşekkürler.
— boudiccas
Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.