Write a script to make sure that user home directories are owned and only accessible by the owner. The script can assume home directories are descendants of /users.
Answer:
First Script
Clear; This is first used to clear the terminal
#read the username from users.txt
un=`cat users.txt|cut - d " - f 1`
#read the Home Directory from users.txt
hd=`cat users.txt|cut - d " - f 2`
#read the gecos string from users.txt
g=`cat users.txt|cut - d " - f 3-4`
#generate the irregular secret word
p=`head/dev/urandom | tr - dc A-Za-z0-9 | head - c 8 ; reverberate ''`
#display the secret word
resound "The secret key of client $un is $p"
#add the client by useradd order
adduser - d $hd - c "$g" $un
#assign the secret word and divert the yield into/dev/invalid
(resound $p|passwd $un - stdin) >/dev/invalid
Section 2. Plan of a File framework
resound "Enter the username"
read un
grep $un/and so on/passwd
in the event that test $? - eq 0
at that point
tar - czf/tmp/back1.tar $hd
userdel - r $un
Not at all like FreeBSD, ZFS isn't a piece of the Linux base establishment because of permitting issues, which is a startling in light of the fact that it is pleasant to introduce Ubuntu on a ZFS pool. Regardless, we can even now run ZFS on Linux by introducing it with the accompanying summons.
ZFS is a joined record system and canny volume manager arranged and executed by a gathering at Sun Microsystems driven by Jeff Bonwick and Matthew Ahrens. Its headway started in 2001 and it was legitimately proclaimed in 2004. In 2005 it was fused into the basic trunk of Solaris and released as a component of OpenSolaris. At the present time, as of January 2015, it is neighborhood to Solaris, OpenSolaris, OpenIndiana, illumos, Joyent SmartOS, OmniOS, FreeBSD, Debian GNU/kFreeBSD structures, NetBSD, OSv and reinforced on Mac OS with MacZFS.
On Backups, this system is absolutely in light of dataset depictions and replication back to our ability servers using zfsnap and zxfer. zfsnap takes a depiction every day for a week and reliably for multi month. It disposes of old ones thusly so you don't gather excess depictions. For example, most of our present Jail servers' dataset get snapshotted, by then every delineation gets rehashed back to the limit servers. It's snappy.
The ZFS filesystem is open for Ubuntu as either a FUSE module or a neighborhood partition module. The part module is given as usual. To present the customer level instruments, simply present:
sudo well-suited introduce zfsutils-linux or sudo able introduce zfs
For each and every present variation from 16.04 ahead.
To have the ability to have ZFS on root, present:
sudo apt install zfs-initramfs
Make ZFS POOL
In the accompanying illustration, we will make a RAIDZ-2 Storage Pool utilizing 3 hard plates. In ZFS RAIDZ-2 resembles equipment RAID 6 in that two hard plates can bomb before the information on the volume is lost.
Discover Device Name
Zpool Status
That is the zfs presently running as proposed on a linux working framework.
Section 5: File System Management with Scripts.
Changing User get to rights on ubuntu is certifiably not a major undertaking to handle, One needs just to be acquainted with the accompanying tips:
Use chown to change ownership and
chmod to change rights.
use the - R decision to apply the rights for all reports inside a list too.
Note that both these charges basically work for registries too. The - R elective takes off them furthermore change the approvals for all reports and lists inside the registry.
For example
chown - R username:group list
will change proprietorship (for the gathering and customer also) everything being equivalent and inventories inside list and registry itself.
chown username:group list
will simply change the approval of the coordinator registry anyway will leave the records and envelopes inside the index alone.
you need to use sudo to change the proprietorship from root to yourself.
Change proprietor
sudo chown - R $USER:$USER/home/$USER/
sudo chmod - R 750/home/$USER/
# get path
path=$1
# display files information
find $path -type f ( -name "*.mp3" -o -name "*.mp4" -o -name "*.aac" -o -name "*.mov" -o -name "*.avi" -o -name "*.vid" ) | xargs du -sh
remove files
find $path -type f ( -name "*.mp3" -o -name "*.mp4" -o -name "*.aac" -o -name "*.mov" -o -name "*.avi" -o -name "*.vid" ) -exec rm -f {} ;
Alternatively;
Get-ChildItem -Path C: -Force /*get path from item*/
Get-ChildItem -Path $environment:ProgramFiles -Recurse /*get the path from programming files*/
-Include *.exe | Where-Object -FilterScript /*to find the object from script*/
-and ($_.Length -ce data storage) -and ($_.Length -le data storage)
Copy-Item -Path C:boot.
ini -Destination C:boot.dat /*to copy the item from directory*/
(New-Object -script Object Scripting.FileSystemObject)
New-Item -Path 'C:tempNew Folder' -ItemType Directory /*a folder to store*/
/* Assumption of home directories are descendants of /users
Get-Data-Path C:boot.ini
[boot loader]
timeout=0
default=multi(0)disk(0)rdisk(0)partition(1)WINDOWS[operating systems]
/*The script takes an argument the filesystem name
multidata()disk()rdisk()partition(1)WINDOWS. mp3 ="receive file" /*to find the summary*/
/noexecute=AlwaysOff.aac /fastdetect /*detection of fast execution*/
multi(0)disk(0)rdisk(0)partition(1)WINDOWS.mp4="Descendants of users"
with Data Execution Prevention" /notexecuted=option /datadetect
(Get-Content -Path C:boot.initiate).Length.avi() /*to find the length of data storage*/
/*to find the initiation of argument storage*/
$System = Get-Context -Path C:temporaryDomainMembers.txt
$scl = Get-Scl fs1sharedfilesdata
$AccessData = New-Object System.Security.AccessControl.FileSystemAccessRule("FullControl","Data")
$scl.RemoveAccessDta($AccessData)