User & File System Management with Advanced Shell Scripting

Verified

Added on  2023/06/07

|6
|1201
|456
Practical Assignment
AI Summary
This assignment solution provides shell scripts for automated user account management, file system manipulation, and ZFS setup. The first script automates user creation based on data from a 'users.txt' file, generating random passwords and adding users to the system. The second script focuses on user removal, backing up the user's home directory before deletion. The solution also covers ZFS installation on Linux, including creating storage pools and snapshots for data backup. Additionally, it details how to modify user access rights using 'chown' and 'chmod' commands, and provides scripts for finding and removing specific file types. The final section includes scripts for various file system tasks, such as copying, creating, and deleting files and directories, and managing file permissions using PowerShell.
tabler-icon-diamond-filled.svg

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Section 1:
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
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
hd=`grep $un/and so on/passwd|cut - d ":" - f 6`
tar - czf/tmp/back1.tar $hd
userdel - r $un
Section 3:
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
Document Page
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
Document Page
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
tabler-icon-diamond-filled.svg

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
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*/
Document Page
(New-Object -script Object Scripting.FileSystemObject)
New-Item -Path 'C:\temp\New 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:\temporary\DomainMembers.txt
$scl = Get-Scl \\fs1\shared\files\data
$AccessData = New-Object
System.Security.AccessControl.FileSystemAccessRule("FullControl","Data")
$scl.RemoveAccessDta($AccessData)
$scl | Set-Scl \\fs1\shared\files
Remove-Item -Path C:\temp\DeleteMe /*to remove files*/
chevron_up_icon
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
logo.png

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]