[go: up one dir, main page]

0% found this document useful (0 votes)
11 views19 pages

Assignment 1

The document is an assignment by Baltej Singh that covers various data representation conversions, including binary, decimal, octal, and hexadecimal systems. It also discusses file permissions and the use of commands to manage them in a Linux environment, detailing the results of permission changes and calculations. Additionally, it includes steps for writing and running a script file, along with the corresponding permissions for directories created during the assignment.

Uploaded by

iam.baltej1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views19 pages

Assignment 1

The document is an assignment by Baltej Singh that covers various data representation conversions, including binary, decimal, octal, and hexadecimal systems. It also discusses file permissions and the use of commands to manage them in a Linux environment, detailing the results of permission changes and calculations. Additionally, it includes steps for writing and running a script file, along with the corresponding permissions for directories created during the assignment.

Uploaded by

iam.baltej1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Assignment 1

Student name:- Baltej singh


Student ID:- A00127014
Submitted to:- Bushra Zahra Naqvi

1. Data representation

a. Convert 8-bit binary 10111110 to a decimal number.


Conversion:-
Step 1. The binary number to be converted into decimal number is
10111110
Step 2. Multiplying each number of binary with 2 by putting power
(0,1,2,3… respectively) from the least significant number towards
most significant number as shown:
1*27 + 0*26 + 1*25 + 1*24 + 1*23 + 1*22 + 1*21 + 0*20
Step 3. Solving the equation:
1*128+0*64+1*32+1*16+1*8+1*4+1*2+0*1 = 190
 128+0+32+16+8+4+2+0 = 190
Therefore, (10111110)2 = (190)10
b. Convert decimal number 55 into 8-bit binary.
Conversion:-
Step 1. The decimal number to be converted into 8-bit binary is 55
Step 2. To convert, 55 is to be divided by 2
55/2 = 27 R 1 * R = Remainder
27/2 = 13 R 1
13/2 = 6 R 1
6/2 = 3 R 0
3/2 = 1 R 1
1/2 = 0 R 1
Step 3. After division, remainder left in every step are read from
bottom to top , that will be a binary number: 110111.
Step 4. Now, the number got is 6-bit, to make it 8-bit zeros are added
next to the most significant figure:- 00110111, it is a 8-bit binary
number.
 (55)10 = (00110111)2

c. Convert octal number 461 to 8-bit binary number.


Conversion:-
Step 1. 4 6 1
4 2 1 4 2 1 4 2 1
Sum of the bold letters are equal to the digits of octal number.
Bold letters are considered 1 where as simple letters are considered
as 0.
Step 2. 4 6 1
1 0 0 110 0 0 1 => binary digits
Step 3. All binary digits above when combined forms (100110001) 2,
which is binary conversion of (461)8.
d. Convert (11110001)2 to hexadecimal number system.
Conversion:-
Step 1. First of all, break the binary number into segments of four
numbers each:
[1111] [0001]
Step 2. Now, the groups above are converted into decimal number
system:
1 1 1 1 0 0 0 1
23 22 21 20 23 22 21 20
Solving first group into decimal :- 1*8 + 1*4 + 1*2 + 1*1 = 8+4+2+1
= 15
Now, solving second group :- 0*8 + 0*4 + 0*2 + 1*1 = 0+0+0+1
= 1
Step 3. Result of 1st group = 15 which is ‘F’ in hexadecimal.
Result of 2nd group = 1 , it will remain as it is.
∴ Therefore, (11110001)2 = (F1)16

e. Manual conversion of hexadecimal ABC to 8-bit binary.


Conversion:-
Step 1. A= 10 B= 11 C= 12
Step 2. First of all, they need to be converted into decimal:
Converting 10 into binary = 10/2 R 0
5/2 R 1
2/2 R 0
1/2 R 1 (1010 is 10 in binary)
Converting 11 into binary = 11/2 R 1
5/2 R 1
2/2 R 0
1/2 R 1 (1011 is 11 in binary)
Converting 12 into binary = 12/2 R 0
6/2 R 0
3/2 R 1
1/2 R 1 (1100 is 12 in binary
Step 3. Combine binary form of ABC, that will be : 101010111100
Hence, (ABC)16 = (101010111100)2

f. Convert 10101111 into octal number system


Conversion:-
Step 1. The binary number to be converted into octal is 10101111.
Step 2. Group the binary number in three sets having three number
each.
0 1 0 1 0 1 1 1 1

4 2 1 4 2 1 4 2 1
Set one > 0*4+1*2+0*1 =2
Set two > 1*4+0*2+1*1 = 5
Set three > 1*4+1*2+1*1 = 7
After combing the results of all sets we get 257. That means:
(10101111)2 = (257)8
g. Convert 10101111 to hexadecimal.
Conversion:-

Step 1. Firstly, divide the binary number into two groups four
numbers each:
1010 1111
Step 2. Convert the above sets into decimal number system:
1010 = 1*8+0*4+1*2+0*1 = 8+0+2+0 = 10
1111 = 1*8+1*4+1*2+1*1 = 8+4+2+1 = 15
In hexadecimal number system 10 is written as A and 15 as F
So, (10101111)2 = (AF)16
2. File permissions
Step 1. Giving a single command to create the structure as per the
instructions and using tree command to see them. Along with that
empty txt files created in new directories.
Issuing the following commands
Ls -ld ~/documents~/clients~/vendors
Ls -lR ~/documents~/clients~/vendors

As per the permissions the same group member and other group
member have only read permission.
Step 4. Limiting the access for the client and vendors to yourself and
same group member by issuing the command :
Chmod 750 ~/clients~/vendors
Step 6 to 8 in screenshot attached below:

Yes, regular file permission changes after using the chmod


command.
Steps 9 and 10 are in single screenshot pasted
below:
Steps from 11 upto 25 in single screen shot below:

This screenshot is taken after completion of the assignment. I am


doing so because I forgot to take its screenshot while working with
my assignment.
In step 13 we need to open a regular file > memo1.txt using nano
editor and try to some content in it but it shows an error message:

After using command in step 14 to add write permissions then in


step 15 we have to open memo1.txt using nano editor and write
something and hit ctrl+o , the content was saved without any issue.

Question1 in step 19: what are the permissions for the newly created
directory?
Ans. drwxr-xr-x
Question2. Can others access the directory pathname “yourself id
and shared”?
Ans. yes, as there is permission r-x which means they can access but
cannot write or change anything as there is no write command.

Step 26 to 30

Step 21: perform a mathematical calculation by taking the octal


number 777 and subtracting the default unmask value you
determined in the previous step what is the result?
Ans. the result for umask command was 022, that was default
permission.
Step 1.Subtract the default umask permission from the octal number
system 777.
Umask default permission= 022
Subtracting: 777-022 = 755
Step 2. Convert 755 into binary number system:
7 5 5
111 101 101
The binary number for (755)8 = (111101101)2
For one we get permissions like r,w,x,etc. and for zero we get ‘-’.
The final permission for shared file is rwxrwxr-x, that is 111101101 in
binary.
Further, in step 25,26,27 issued commands umask 077 to the newly
created ‘shared2’ directory and umask, mkdir ~/shared2, ls-ld
~/shared2.
By subtracting 077 from 777 we get the permission of shared2 that
is, 777-077 = 700 which is rwx------
Answer for the question of step 27. It does not match with the
permissions of the previous directory.
Step 29. What we noticed about the permissions when used ls -l
command?
Ans. it was noticed that the ‘myfile’ only has permission to read and
write.
Step 30. What happened after issuing umask command?
Ans. here, we got default permission as 077 which clearifies that
there are no permissions for administrator where as all permissions
were enabled for users and others only.
3. Writing and run script file

From step 1 to step 4 in screenshot below:

Paragraph written in nano editor as directed in step 1:


Step 5 to step 9 : in screenshot attached below that is create new
script file by writing step 6 to step 9 in it:
Step 10. Assume you just issued the command : chmod
u=rwx,go=x~/linux/content
What would be the new permissions for the content directory?
Ans. drwx- -x- -x

Step 11. Create new directory ‘mydir’ and view the permissions
for the directory by using ‘ls -ld’:

This directory has permissions: read, write, execute for the user
however, group and others have no permissions.
History commands for this assignment

You might also like