B.Sc.
/BCA DEGREE (CBCS) REGULAR EXAMINATION, MAY 2023
CORE COURSE - CS4CRT10 - LINUX ADMINISTRATION
QP CODE: 23124368
Part A
Answer any ten questions.
Each question carries 2 marks.
1. What is a data block??
A data block is a basic unit of data storage in a file system. It is the smallest unit of data that
can be read or written in a single operation. In most file systems, each data block is a fixed
size, typically between 512 and 4096 bytes.
2. What is the difference between home directory and working directory?
Home Directory: Every user will have one home directory and will have complete control over
it. On login, home is the default working directory for the user. It contains the configuration
files and responsible for login and logout of the user.
Working directory: The directory in which the user is working currently is known as working
directory. The home may also be the working directory, if the user is working in it.
3. Which are the commands used to create files in Linux?
The touch command creates empty files
The cat command is most commonly used to view the contents of a file. But you can also use it
to create files.
The echo command is used to add and append text to files. It also creates the file if it doesn't
already exist.
4. Define tee command
tee command reads the standard input and writes it to both the standard output and one or more
files. The command is named after the T-splitter used in plumbing. It basically breaks the
output of a program so that it can be both displayed and saved in a file. It does both the tasks
simultaneously, copies the result into the specified files or variables and also display the result.
5. Define who and whoami commands in Linux.
The command who lists the currently logged in user. The command whoami show the current
user.
6. What is the use of file and touch command in Linux?
file command is used to determine the file type. It does not care about the extension used for
file. It simply uses file command and tell us the file type.
touch command: It is used to create a file without any content. The file created using touch
command is empty. This command can be used when the user doesn’t have data to store at the
time of file creation.
7. What is shell environment?
A shell maintains an environment that includes a set of variables defined by the login program,
the system initialization file, and the user initialization files. In addition, some variables are
defined by default.
8. Give syntax of case statement.
case word in
pattern1)
Statement(s) to be executed if pattern1 matches
;;
pattern2)
Statement(s) to be executed if pattern2 matches
1
;;
pattern3)
Statement(s) to be executed if pattern3 matches
;;
*)
Default condition to be executed
;;
Esac
9. Distinguish between groupmod -g and groupmod -n command in Linux.
Syntax:
groupmod [option] GROUP
groupmod command in Linux is used to modify or change the existing group on Linux system.
-g, –gid GID: The group ID of the given GROUP will be changed to GID.
n, –new-name NEW_GROUP: The name of group will change into newname.
10. Define the term file system
a file system -- is the way in which files are named and where they are placed logically for
storage and retrieval. Without a file system, stored information wouldn't be isolated into
individual files and would be difficult to identify and retrieve. As data capacities increase, the
organization and accessibility of individual files are becoming even more important in data
storage.
11. What is the use of sed command?
SED is a powerful text stream editor. Can do insertion, deletion, search and
replace(substitution).
SED command in Linux supports regular expression which allows it perform complex pattern
matching.
Syntax:
sed OPTIONS... [SCRIPT] [INPUTFILE...]
12. What is samba?
Samba enables Linux / Unix machines to communicate with Windows machines in a network
Part B
Answer any six questions.
Each question carries 5 marks.
13 Which are the hardware requirements for Linux installation?
System Characteristic Recommended
Processor 64-bit Opteron, EM64T
RAM 1 GB or greater
Swap space 1 GB or greater
Disk space 500 MB free space
14. Explain Linux file system in detail.
o / (root filesystem): It is the top-level filesystem directory. It must include every file needed
to boot the Linux system before another filesystem is mounted. Every other filesystem is
mounted on a well-defined and standard mount point because of the root filesystem
directories after the system is started.
o /boot: It includes the static kernel and bootloader configuration and executable files needed
to start a Linux computer.
o /bin: This directory includes user executable files.
2
o /dev: It includes the device file for all hardware devices connected to the system. These
aren't device drivers; instead, they are files that indicate all devices on the system and provide
access to these devices.
o /etc: It includes the local system configuration files for the host system.
o /lib: It includes shared library files that are needed to start the system.
o /home: The home directory storage is available for user files. All users have a subdirectory
inside /home.
o /mnt: It is a temporary mount point for basic filesystems that can be used at the time when
the administrator is working or repairing a filesystem.
o /media: A place for mounting external removable media devices like USB thumb drives that
might be linked to the host.
o /opt: It contains optional files like vendor supplied application programs that must be placed
here.
o /root: It's the home directory for a root user. Keep in mind that it's not the '/' (root) file
system.
o /tmp: It is a temporary directory used by the OS and several programs for storing temporary
files. Also, users may temporarily store files here. Remember that files may be removed
without prior notice at any time in this directory.
o /sbin: These are system binary files. They are executables utilized for system administration.
o /usr: They are read-only and shareable files, including executable libraries and binaries, man
files, and several documentation types.
o /var: Here, variable data files are saved. It can contain things such as MySQL, log files,
other database files, email inboxes, web server data files, and much more.
15. What is Linux Redirection? Explain the different types of redirection with suitable examples.
Redirection is a feature in Linux such that when executing a command, you can change the
standard input/output devices
Types of Redirection
1. Overwrite Redirection:
Overwrite redirection is useful when you want to store/save the output of a command to a file
and replace all the existing content of that file. for example, if you run a command that gives a
report, and you want to save the report to the existing file of the previous report you can use
overwrite redirection to do this.
“>” standard output
“<” standard input
Example:
So whatever you will write after running this command, will be redirected and copied to the
“file.txt”. This is standard output redirection.
cat > file.txt
input redirection, cat command will take the input from “file.txt” and print it to the terminal
screen. This line of code also shows the real working and meaning of the cat command that is
copy and paste. Many people have a misconception that the cat is used to create a file, but it is
not true, the main work of the cat is to copy the input and give the output to the screen.
cat < file.txt
2. Append Redirection:
With the help of this Redirection, you can append the output to the file without compromising
the existing data of the file.
“>>” standard output
“<<” standard input
3. Merge Redirection:
3
This allows you to redirect the output of a command or a program to a specific file
descriptor instead of standard output. the syntax for using this is “>&” operator followed by
the file descriptor number.
“p >& q” Merges output from stream p with stream q
“p <& q” Merges input from stream p with stream q
16. What are editors? Explain vi editors.
Linux text editors can be used for editing text files, writing codes, updating user instruction
files, and more. A Linux system supports multiple text editors. There are two types of text
editors in Linux, which are given below:
o Command-line text editors such as Vi, nano, pico, and more.
o GUI text editors such as gedit (for Gnome), Kwrite, and more.
VI in the vi editor stands for Visual Editor. It is a user-friendly and very powerful application
that is available in all Linux distros. An improved version of vi editors is vim.
These are the following reasons why VI editor is popular:
It is available in almost all Linux Distributions.
It is user-friendly.
It works the same across different platforms and distributions.
There are two modes of operation of VI editor:
Command Mode: In command mode, actions are taken on the file.
Insert Mode: In insert mode, the text will be inserted into the file.
By default, the vi editor starts in the command mode. You have to be present in the insert mode
in order to enter the text. For that, just type 'i' and you'll be in insert mode.
17. What is command line argument? How will you use command line arguments in a shell?
Command-line arguments are parameters that are passed to a script while executing them in
the bash shell. They are also known as positional parameters in Linux. We use command-line
arguments to denote the position in memory where the command and it's associated parameters
are stored.
Command-line arguments are passed in the positional way i.e. in the same way how they are
given in the program execution. Let us see with an example. The program can be executed by
using the “sh” command. Note: We can pass n number of arguments and they are identified by
means of their position
18. Explain different types of variables in shell script.
In shell scripting there are three main types of variables are present. They are –
Local Variables -A local variable is a special type of variable which has its scope only within
a specific function or block of code
Global Variables or Environment Variables-A global variable is a variable with global scope.
It is accessible throughout the program.
Shell Variables or System Variables-These are special types of variables. They are created and
maintained by Linux Shell itself. These variables are required by the shell to function properly.
They are defined in Capital letters.
19 Discuss how a system administrator can manage its user account.
1. Add, modify, delete, or copy user accounts 2. Assign a data store to a user 3. Change the
security role of a user 4. Generate a report on selected user account
20. What is DNS Server?
DNS (Domain Name System) is a network protocol used to translate hostnames into IP
addresses. DNS is not required to establish a network connection, but it is much more user
friendly for users than the numeric addressing scheme. To use DNS, you must have a DNS
server configured to handle the resolution process. A DNS server has a special-purpose
application installed. The application maintains a table of dynamic or static hostname-to-IP
address mappings. When a user request some network resource using a hostname, (for example,
4
by typing www.google.com in a browser), a DNS request is sent to the DNS server asking for
the IP address of the hostname. The DNS server then replies with the IP address. The user’s
browser is then able to access www.google.com using that IP address.
The picture below explains the concept:
DNS Client wants to communicate with the server named home_server. Since the DNC
Client doesn’t know the IP address of home_server, it sends a DNS Request to the DNS Server,
asking for the IP address of home_server. The DNS Server replies with the IP address
of home_server (DNS Reply). The DNS Client can then communicate with home_server.
21. What are the advantages and disadvantages of using Telnet?
Advantages of Telnet
Telnet can also be useful for testing or debugging network services, such as SMTP or HTTP,
by sending raw commands and observing the responses. Telnet can also be faster, since it does
not have any encryption or authentication overhead.
DIS ADVNTAGES
User ID and password are communicated in clear text.
Since Telnet is a character-based communication method, it is not possible to use GUI-
based tools through Telnet connections.
It is a pretty ineffective protocol.
Part C
Answer any two questions.
Each question carries 15 marks.
22. Explain any five file processing commands in Linux with its syntax and suitable examples.
1. cp file1 file2 - The copy command is used to copy the contents of one file to another. You
can also use this command to copy a file from one directory into another.
2. mv file1 file2 - The move command allows a user to move or rename a file.
3. touch file - Use the touch command to create or update a file
4.cat > file - This command is used to input standard output into a file.
5.more file - The more command will allow the user to view the contents of a file one screenful
at a time.
23. Explain decision making and branching statements with examples.
1. If-else statement
if-fi
if-else-fi
if-elif-else-fi
nested if-else
2.The case-sac statement
case $var in
Pattern 1) Statement 1;;
Pattern n) Statement n;;
esac
5
24. a) Explain file access permission in detail.
All the three owners (user owner, group, others) in the Linux system have three types of
permissions defined. Nine characters denotes the three types of permissions.
1.Read (r): The read permission allows you to open and read the content of a file. But you can't
do any editing or modification in the file.
2.Write (w): The write permission allows you to edit, remove or rename a file. For instance, if
a file is present in a directory, and write permission is set on the file but not on the directory,
then you can edit the content of the file but can't remove, or rename it.
3.Execute (x): In Linux type system, you can't run or execute a program unless execute
permission is set. But in Windows, there is no such permission available.
Permissions are listed below:
permission on a file on a directory
r (read) read file content (cat) read directory content (ls)
w (write) change file content (vi) create file in directory (touch)
x (execute) execute the file enter the directory (cd)
b) What is the use of uname and hostname commands in Linux?
uname -a command can be used to display all system information such as the kernel name,
hostname, kernel version, operating system, etc. This means it gives a comprehensive summary
of system information
hostname command in Linux is used to obtain the DNS (Domain Name System) name and set
the system's hostname or NIS (Network Information System) domain name. A hostname is a
name given to a computer and attached to the network.
25. With example explain different filters available in Linux.
Filters are programs that take plain text (either stored in a file or produced by another program)
as standard input, transforms it into a meaningful format, and then returns it as standard output.
Linux has a number of filters. Some of the most commonly used filters are explained below:
1. cat: Displays the text of the file line by line.
Syntax: cat [path]
2. head : Displays the first n lines of the specified text files. If the number of lines is not
specified then by default prints first 10 lines.
Syntax: head [-number_of_lines_to_print] [path]
3. tail: It works the same way as head, just in reverse order. The only difference in tail is, it
returns the lines from bottom to up.
Syntax: tail <file name>
4. sort: Sorts the lines alphabetically by default but there are many options available to modify
the sorting mechanism. Be sure to check out the main page to see everything it can do.
Syntax: sort [-options] [path]
5. grep : grep is used to search a particular information from a text file.
Syntax: grep [options] pattern [path]il [-number_of_lines_to_print] [path]
Scheme prepared by:
Sanam S, Assistant Professor, Seth Ram Bahadur Singh Gujarati College, Kochi-02