Lab Setup/Requirements Note the information at the top of the SECTION 2 lab. The student1 and student2 accounts, as well
Posted: Fri Jul 01, 2022 5:38 am
Lab Setup/Requirements
Note the information at the top of the SECTION 2lab.
The student1 and student2 accounts, as well as thestudents group are needed for this lab, as well as other thingsmentioned below.
Please read and execute what is in this document, sothat lab 2 will run as expected.
The following are setup requirements for Lab#2.
We need 2 student accounts, called student1 andstudent2, with home directories of /home/student1 and/home/student2 respectively. And we need both of them to be membersof a common group called students.
Following are the detailed commands you need to run ifthis is not set up on your Unix computer.
You may get “account already exists” or “group alreadyexists” on some of the commands on computer where this setup hasalready been done. In this case, to get a fresh start, use userdel–r ‘accountname’ and groupdel ‘groupname’ to delete the accountsand/or groups, as long as you do not have any data you want to savein these home directories
Setup Commands for Lab #2.
While logged in as root, run the following:
groupaddstudents (creates the “students” group)
useradd –c student1 –g students –d /home/student1 –mstudent1 (creates student1account)
useradd –c student2 –g students –d /home/student2 –mstudent2 (creates student2account)
passwdstudent1 (set password to “password”)
passwdstudent2 (set password to “password”)
cd /home
chmod 755 student1student2 (set proper permissions on student1 and 2 directories)
chown student1:students /home/student1 (ensure owner:group are set on /home/student1)
chown student2:students /home/student2 (ensure owner:group are set on /home/student2)
su – student1 (verify the account functions; verify pwd and umask is022)
su – student2 (verify the account functions; verify pwd and umask is022)
Also verify that the shell for the user is BASH byexamining the SHELL variable of the user or the entry in/etc/passwd. If it is not, run usermod –s /bin/bash to change it toBASH.
To view your current shell, enter echo $SHELL and itshould say /bin/bash. Or if you cat /etc/passwd, the last entry foryour account should say /bin/bash. See next page for some ubuntunotes.
Some additional notes regrding Ubuntufollow:
DIRECTORY PERMISSIONS:
.
Using the octal notation for permissions, what are thepermissions on this directoryfile: .
While still in the student1 account,use the echo > command with outputredirection, create a file inthe subdir2 directorycalled labfile5 and put the followingtext in this file: “This is the first line of labfile5”. Ensure thepermissions on the subdir2 directory andthe subdir2/labdile5 fileare read and execute,and not write,for group. Set them withthe chmod command if necessary.
Now su – tothe student2 account. Asthe student2 user, ensure you are inyour home directory. Display the contents ofthis labfile5 file using a relative pathwith the cat command. What command didyouuse: .
Can you view this file? (you should be ableto…) .
Attempt to append a second line of text called “This is thesecond line of labfile5” tothe labfile5 file usingthe echo command with outputredirection. Can you doit? .
Why or whynot? .
Log out of the student2 account andback into the student1 account andchange the permissions onthe subdir2 directoryonly, to include writepermission, leaving the read and execute access onit. What command did youuse? .
In the student2 account, againattempt to append a second line of text called “This is the secondline of labfile5” to thestudent1’s labfile5 file usingthe echo >> command. Can you doit? .
Why or whynot? .
Attempt to delete the labfile5 filefrom student2 account. Can you doit? .
Create a file called labfile6 inthe subdir2 directory. Can you doit? .
What three file operations does write permission allow on adirectory, even if write is not enabled on files within?
1 .
2 .
3 .
Note the information at the top of the SECTION 2lab.
The student1 and student2 accounts, as well as thestudents group are needed for this lab, as well as other thingsmentioned below.
Please read and execute what is in this document, sothat lab 2 will run as expected.
The following are setup requirements for Lab#2.
We need 2 student accounts, called student1 andstudent2, with home directories of /home/student1 and/home/student2 respectively. And we need both of them to be membersof a common group called students.
Following are the detailed commands you need to run ifthis is not set up on your Unix computer.
You may get “account already exists” or “group alreadyexists” on some of the commands on computer where this setup hasalready been done. In this case, to get a fresh start, use userdel–r ‘accountname’ and groupdel ‘groupname’ to delete the accountsand/or groups, as long as you do not have any data you want to savein these home directories
Setup Commands for Lab #2.
While logged in as root, run the following:
groupaddstudents (creates the “students” group)
useradd –c student1 –g students –d /home/student1 –mstudent1 (creates student1account)
useradd –c student2 –g students –d /home/student2 –mstudent2 (creates student2account)
passwdstudent1 (set password to “password”)
passwdstudent2 (set password to “password”)
cd /home
chmod 755 student1student2 (set proper permissions on student1 and 2 directories)
chown student1:students /home/student1 (ensure owner:group are set on /home/student1)
chown student2:students /home/student2 (ensure owner:group are set on /home/student2)
su – student1 (verify the account functions; verify pwd and umask is022)
su – student2 (verify the account functions; verify pwd and umask is022)
Also verify that the shell for the user is BASH byexamining the SHELL variable of the user or the entry in/etc/passwd. If it is not, run usermod –s /bin/bash to change it toBASH.
To view your current shell, enter echo $SHELL and itshould say /bin/bash. Or if you cat /etc/passwd, the last entry foryour account should say /bin/bash. See next page for some ubuntunotes.
Some additional notes regrding Ubuntufollow:
DIRECTORY PERMISSIONS:
.
Using the octal notation for permissions, what are thepermissions on this directoryfile: .
While still in the student1 account,use the echo > command with outputredirection, create a file inthe subdir2 directorycalled labfile5 and put the followingtext in this file: “This is the first line of labfile5”. Ensure thepermissions on the subdir2 directory andthe subdir2/labdile5 fileare read and execute,and not write,for group. Set them withthe chmod command if necessary.
Now su – tothe student2 account. Asthe student2 user, ensure you are inyour home directory. Display the contents ofthis labfile5 file using a relative pathwith the cat command. What command didyouuse: .
Can you view this file? (you should be ableto…) .
Attempt to append a second line of text called “This is thesecond line of labfile5” tothe labfile5 file usingthe echo command with outputredirection. Can you doit? .
Why or whynot? .
Log out of the student2 account andback into the student1 account andchange the permissions onthe subdir2 directoryonly, to include writepermission, leaving the read and execute access onit. What command did youuse? .
In the student2 account, againattempt to append a second line of text called “This is the secondline of labfile5” to thestudent1’s labfile5 file usingthe echo >> command. Can you doit? .
Why or whynot? .
Attempt to delete the labfile5 filefrom student2 account. Can you doit? .
Create a file called labfile6 inthe subdir2 directory. Can you doit? .
What three file operations does write permission allow on adirectory, even if write is not enabled on files within?
1 .
2 .
3 .