Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 18

CLASSWORK OF LAB 2

1. Create a new user, naming sv2 :


- To create a new user in your computer system, you need to use the command
which follows the syntax below :
”useradd” + <name of user that you want to create>  If so, the system
will not grant us the permission. To solve this issue, we have to use “sudo”
command to get the privilege from “root” which has the highest level in the
system.
- Here is the illustration :

 Because when I had created sv2 before I took the photos so this is just same
steps as I did.
2. Activate password for sv2 account:
- So after I had created a new user in our system, I needed to activate the
password of that user to provide the security. And it must be so for the full
activation of new user.
- Here is the illustration :

- After that, I logged out to check whether it exists from the outside.
3. Create sv2 directory in home directory:
- We have to back to main user on our system to continue handle with these
things.
- To create sv2 directory in home directory, we use the command following the
syntax below:
”sudo” + ”mkdir” + <name of directory that you would love to>.
- Explanation : “sudo”  is used to get the privilege to address with system.
- Here is the illustration :
4. Transfer owner of sv2 directory to sv2 user:
- To transfer owner of a directory to a user, we use the syntax below:
”sudo” + “chown” + <username> + <filename>.
- “sudo” is also used to get the privilege.
- Here is the illustration :

 But don’t really care the half above, that just something which is previous one
and I forget clearing it.
5. Similarly create sv3 user following steps 1-4:
- This is what has been done in the above and will repeat to create another one
“sv3”which includes 4 steps:
+ Create a new user using : “sudo” + ”useradd” + <name of user that you
want to create> 
+ Activate password using: “sudo” + “passwd” + <user>
+ Create directory using: “mkdir” command
+ Change owner using: “sudo” + “chown” + <user> + <file>
- Here is the illustration:
6. Create the lab2 group:
- Use the command below:
 “sudo” + “groupadd” + <name of group>  “sudo”  is used to get the
privilege to address with system.
- Here is the illustration:

- Type the password to continue.


7. Add sv2 and sv3 users to lab2 group:
- A user is added to a group with the “usermod” command:
Syntax: “sudo” + “usermod” + “-a -G” + <group-name> + <user-name>
- Here is the illustration:

- Use “id + <user-name>” to check if it exists.


8. List the users of the lab2 group:
- In order to list users on Linux, you have to execute the “cat” command on the
“/etc/group” file. When executing this command, you will be presented with the
list of users currently available on your system.
- Syntax : “cat” + “/etc/group”.

--> It’ll list all the groups and just scroll the pointer down to see “lab2”. It has 2
user which I have added to lab2 above.
9. Rename group lab2 to lab3:
- To change the name of the group from lab2 to lab3, we can use the following
command:

- Here is the illustration and result:


\

- Type the password of main user to get the privilege.

After changing Before changing


10. List all the users of the lab3 group
- - In order to list users on Linux, you have to execute the “cat” command on the
“/etc/group” file. When executing this command, you will be presented with the
list of users currently available on your system.
- Syntax : “cat” + “/etc/group”.
- Here is the illustration:
11. Delete sv2 users from lab3 group:
- To remove a user from a group, use the gpasswd command with the -d option as
follows.

- In this example, sv2 is the username and lab3 is the group name:


- Here is the illustration:
12. Lock up sv2 account:
To be able to lock user accounts on Linux. Then we have 2 ways to use the co
mmand program "passwd" and "usermod". These two programs both do the s
ame task, which is to lock the user account password on a Linux system, but 

the method is slightly different.
- Use the command below to lock up an account:

- Here is the illustration :

 The yellow circel which is “L’’ letter means “LOCK”


13. Unlocking sv2 account:
– To unlock the locked user account, we continue to use 2 command programs
"passwd" and "usermod" with other support options.
- Use this command to unclock account:

- Here is the full illustration:


15. Add test.doc file to sv3 directory:
- To add or create any file. There are some ways to do that but in this case. I’m
going to use the command below to create a file in sv3 directory:

- You can use “cat > <file-name>” to create file as well.


- Here is the full illustration:
16. Show access permissions for sv3 files and directories:
- If you prefer using the command line, you can easily find a file’s permission
settings with the ls command, used to list information about files/directories. You
can also add the –l option to the command to see the information in the long list
format.
To check the permission configuration of a file, use the command:
ls –l [file_name]
- Example :

- Full illustration :
17. Change the permissions of test.doc file to: Owner has the right to read,
write; Group can read only; Others have no rights at all.
- We can use the ‘chmod’ command which stands for ‘change mode’. Using the
command, we can set permissions (read, write, execute) on a file/directory for
the owner, group and the world.
- Syntax : “chmod” <permissions> <filename>

- Example :
 “640” :
+ 6 : read and write (from binary to decimal)
+ 4 : read only (from binary to decimal)
+ 0 : No permission (from binary to decimal)
- Here is the full illustration:
18. Change access to sv2 directory to: “Owner can read, write, execute; Group
can read and write; Other groups read” using octal code.
- We can use the ‘chmod’ command which stands for ‘change mode’. Using the
command, we can set permissions (read, write, execute) on a file/directory for
the owner, group and the world.
- Syntax : “chmod” <permissions> <filename>

- Example :
 “764” :
+ 7 : read and write and execute (from binary to decimal)
+ 6 : read and write (from binary to decimal)
+ 4 : read only (from binary to decimal)
- Here is the full illustration:
19. Change the mask so that the files are created from now can read only by the
Owner.
- Use the command below to change the mask as requires:

- “444” is read only for all .


20. Transfer owner of sv3 directory to sv2 user:
- To transfer owner of a directory to a user, we use the syntax below:
”sudo” + “chown” + <username> + <filename>.
- “sudo” is also used to get the privilege.
- Here is the illustration :

You might also like