Unix Module 3 MCQ

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Module-3

Basic File Attributes – Is

MCQ’S

1. An attribute is a specification of an object that defines its property.


a) True
b) False
2. Which command is used to list the attributes of a file?
a) cp
b) list
c) ls
d) attr
3. Which one of the following is not an attribute displayed by ls command?
a) file permissions
b) file ownership
c) links
d) word count of file
4. What are links referred to as in file attributes?
a) number of filenames of a single file that are maintained by the system
b) number of duplicates of a single file
c) number of copies of a single file
d) number of files present in a directory
5. In how many categories are links divided?
a) 1
b) 2
c) 4
d) 0
6. Which option is used with ls command to list the directory attributes rather than its
contents?
a) -b
b) -a
c) -l
d) –d
7. File attributes are of major concern as compared to directory attributes while performing
operations on file system.
a) True
b) False
8. A file contains 1026 bytes. How many bytes of disk space will it consume if size of a
disk block is 1024 bytes?
a) 1026
b) 1024
c) 2048
d) 4096
9. A file can be recognized as an ordinary file or directory by ____ symbol.
a) $
b) –
c) *
d) /
10. How many types of permissions a file has in UNIX?
a) 1
b) 2
c) 3
d) 4
11. Permissions of a file are represented by which of the following characters?
a) r,w,x
b) e,w,x
c) x,w,e
d) e,x,w
12. A file named abd.txt has the following set of permissions
-rwxrwxrwx
All the three operations i.e read, write and execute can be performed on the file by file
owner, group owner and others.
a) True
b) False
13. Which of the following symbol is used to indicate the absence of a permission of a file?
a) $
b) &
c) +
d) –
14. When we create a file, we are the owner of a file.
a) True
b) False
15. What is group ownership?
a) group of users who can access the file
b) group of users who can create the file
c) group of users who can edit the file
d) group of users who can delete the file
16. A file has permissions as rwx r– —. A user other than the owner cannot edit the file.
a) True
b) False
17. f a file is read protected, we can write to the file.
a) True
b) False
18. The write permission for a directory determines that ____________
a) we can write to a directory file
b) we can read the directory file
c) we can execute the directory file
d) we can add or remove files to it
19. If the file is write-protected and the directory has to write permission then we cannot
delete the file.
a) True
b) False
20. What is execute permission?
a) permission to execute the file
b) permission to delete the file
c) permission to rename the file
d) permission to search or navigate through the directory
21. Which of the following is default permission set for ordinary files?
a) rw-rw-rw-
b) rwxrwxrwx
c) r–r–r–
d) rw-rw-rwx
22. Which of the following is default permission set for directories?
a) rw-rw-rw-
b) rwxrwxrwx
c) r–r–r–
d) rw-rw-rwx
23. A file owner does not have a permission to edit the file but the group to which the file
owner belong do have the permission to edit it. Can owner edit the file?
a) Yes
b) No
c) Cannot be defined
d) Error will be encountered
24. While changing permissions in an absolute manner, we explicitly set all the nine bits
irrespective of the previous permissions of the file.
a) True
b) False
25. Which command is used to change the ownership of a file?
a) chmod
b) change
c) ch
d) chown
26. Which command is used to change the group owner of the file?
a) chown
b) ch
c) chgrp
d) chmod
27. A user can change the group ownership of a file to another group to which he does not
belong.
a) True
b) False

Answers

1. Answer: a
Explanation: An attribute defines the property of an object. In UNIX, every file has a set
of attributes which defines the specification of the file.
2. Answer: c
Explanation: ls command is used for listing the attributes of a file or directory. ls
command when used with -l displays all the seven attributes of a file.
3. Answer: d
Explanation: When -l option is used with ls command it simply displays seven attributes
of a file which are file type and permissions, links, ownership, group ownership, file size,
last modification time, filename.
4. Answer: a
Explanation: Links are defined as the number of filenames of a single file that are
maintained by the system. This file can be accessed through as many filenames as there is
a number of links to that file.
5. Answer: b
Explanation: There are basically two types of links; hard link and soft links.
6. Answer: d
Explanation: ls command when combined with -d option displays the attributes of a
directory rather than its contents.
7. Answer: b
Explanation: Directory attributes are of major concern as compared to file attributes when
performing any operation on file system because files are a part of directory or we can
say that files are stored under the directory in the directory tree. So if directory attributes
does not allow us to perform a particular operation on the directory than that operation
can never be performed on the file which is stored inside that directory.
8. Answer: c
Explanation: Sine files are written to the disk in terms of block size, the size consumed
by the file vary from the original size of the file. Suppose, if a file size is 800 bytes but
the block size on the system is 1024 bytes, then that file will consume 1024 bytes on
diskspace i.e. 1 block.
9. Answer: b
Explanation: When ls command is used with -l option its displays attributes of a file in
the multi-columnar form. The first column defines the file types and permissions
associated with a file. If the permissions are preceded by a (-), then it is an ordinary file
otherwise it is a directory.
10. Answer: c
Explanation: In UNIX system, a file can have three types of permissions -read, write and
execute. Read permission means that the file is readable. Write permission means that the
file can be edited while executing permission (for a directory) means that we can “pass
through” the directory file for searching subdirectories.
11. Answer: a
Explanation: A file can have three types of permissions; read, write and execute which is
represented by characters r, w and x respectively.
12. Answer: a
Explanation: UNIX provides a three tired file protection system that determines the file
access rights i.e. the permissions are dived into three groups as
13. Answer: d
Explanation: ( – ) is used to indicate the absence of a single or set of permissions of a file.
For example, if a file has all the three permissions for owner but is only readable by
group members and others, then the set of permissions would be,
rwx r-- r--
14. Answer: a
Explanation: In most cases, the user which creates the file is regarded as owner of the
file. The owner of the file can create, delete or edit the file or he can change the
permissions associated with it.
15. Answer: a
Explanation: When the system administrator creates a user account, he assigns the user
two parameters; UID (user ID) and GID (group ID). Group id denotes the group to which
the user belongs.
In simple words, group ownership defines the group to which the file is accessible.
16. Answer: a
Explanation: Since the second and third group of permissions of a file are r– and —
respectively. So the file is only readable and that too, only by the members of the group
to which the file belongs.
17. Answer: b
Explanation: If a file is not readable then it is obvious that we cannot write anything to
the file. To write anything to a file it should be readable first. But if a file is writable then
we can read the file easily but the reverse is not true.
18. Answer: d
Explanation: The write permission of a directory does not imply that we can write to the
directory. Only kernel is allowed to do that. It simply means that we can create or remove
files from the directory.
19. Answer: b
Explanation: The term ‘write-protected’ has a limited meaning in the UNIX file system.
A file which is write protected cannot be written, but it can be removed if the directory
has to write permission.
20. Answer: d
Explanation: Executing a directory does not make any sense, execute permission simply
means that a user can “pass through” the directory while searching for subdirectories.
When we use pathname with any command we should have execute permission for each
of the directories involved in the complete pathname. For example,
cd users/users06/abd/dir01/file01.txt // all directories should have execute permission.
21. Answer: a
Explanation: The default permission set for an ordinary file is rw-rw-rw i.e. it is readable
and writable by owner, group member and others.
22. Answer: b
Explanation: The default permission set for an ordinary file is rwxrwxrwx i.e. it is
readable, writable, executable by owner, group members and others.
23. Answer: b
Explanation: The file owner cannot edit the file because the owner’s permission overrides
the group’s permission. In other words, the priority of owner’s permission is greater than
group’s permission.
24. Answer: a
Explanation: The expression used by chmod in an absolute manner is a string of three
octal numbers (base 8). A set of 3 bits represent a single octal digit.
-> Read permission –4 (100 in octal)
-> Write permission –2(010 in octal)
-> Execute permission –1(001 in octal)
For each category, we add up these numbers. For example, if we have to set read and
write permission then an octal number will be 110 (4+2).
25. Answer: d
Explanation: For changing the file ownership, we use the chown command. chown
transfer the ownership of a file to another user. The command requires the user-ID (UID)
of the recipient. To change the ownership of a file from user01 to user02, use the
following commands:
26. Answer: c
Explanation: A user can change the group owner of a file but only to that group to which
he belongs. A user can belong to more than one group and the one shown in /etc/psswd is
the user’s main group.
27. Answer: b
Explanation: Group ownership can be changed only to that group to which the user also
belongs otherwise a user cannot change the group ownership of a file to another group to
which he does not belong.

You might also like