You are on page 1of 9

Assignment Question

Linux System Programming

1) Explain the main purpose of an operating system?


2) What is kernel?
3) What are the advantages of a multiprocessor system?
4) What are real-time systems?
5) Describe the objective of multiprogramming.
6) What are time sharing systems?
7) What are the different types of CPU registers in a typical operating system design?
8) What is a shell?
9) What is the difference between soft and hard links?
10) How will you pass and access arguments to a script in Linux?
11) What is the significance of $#?
12) What is the difference between $* and $@?
13) Use sed command to replace the content of the file (emulate tac command
14) Given a file, replace all occurrence of word “ABC” with “DEF” from 5th line till end in
only those lines that contains word “MNO”
15) How will you find the 99th line of a file using only tail and head command?
16) Print the 10th line without using tail and head command.
17) I want to create a directory such that anyone in the group can create a file and access any
person’s file in it but none should be able to delete a file other than the one created by
himself.
18) What is the difference between $$ and $!?
19) I want to monitor a continuously updating log file, what command can be used to most
efficiently achieve this?
20) Given a file find the count of lines containing word “ABC”.
21) How do we delete all blank lines in a file?
22) How will I insert a line “ABCDEF” at every 100th line of a file?
23) How to get the OS version in unix?
24) What is the default login shell and how to change default login shell for a specific user ?
25) What are the different type of variables used in a shell Script ?
26) How to redirect both standard output and standard error to the same location ?
27) What is difference between absolute and relative path?
28) How to open a file in read only mode using vi editor?
29) Which alphabet keys can move the cursor equivalent to arrow keys?
30) What is yanking w.r.t vi editor?
31) How can you display line numbers in vi editor?
32) How can we execute a shell script if execute bit is off for a shell script?
33) Which is the command used to create a new user on the system
34) Command ‘telnet’ is used for ___
35) Which command can be used to stop the current executing process in the background?
36) What is the basic purpose of ‘find’ command?
37) Which filter can be used to display first 10 lines of a file?
38) What is the first operating system designed using a high level programming language?
39) Which command can be used to create alternate name for an existing command?
40) How can you suppress trailing new line for echo command?
41) Distinguish between cmp and diff commands?
42) How can we redirect the output of one command to the another command?
43) Which command you can use to find the remaining disk free space?
44) What is the purpose of ‘at’ command?
45) Explain the purpose of nohup command.
46) How are devices represented in UNIX/Linux?
47) Which command can be used to execute a command/s repeatedly for the given schedule?
48) Which command can be used to rename a file/directory?
49) What are the respective octal value for the permission bits r, w & x?
50) Which operator can be used to throw a process into background?
51) How can we list out all currently executing background processes?
52) Which command can be used to know the terminal type?
53) What is an internal command?
54) How to Restart Apache over the SSH?
55) How to Stop Apache over the SSH?
56) How to Start Apache over the SSH?
57) How to Restart Httpd over the SSH?
58) How to Stop Httpd over the SSH?
59) How to Start Httpd over the SSH?
60) Import database from sql file to mysql?
61) How to delete ALL files including sub directory in current directory with prompting each
time?
62) How to reverse a string in unix?
63) How to unzip a file in Linux?
64) How to test if a zip file is corrupted in Linux?
65) How to find hidden files in current directory?
66) How to check if a file is zipped in Unix?
67) How to check all the running processes in Unix?
68) find all files in current and subdirectories which contains 'webtechnology' name?
69) How to make any script file executable?
70) How to kill process in unix server?
71) I have read permission on a directory but I am not able to enter it, why?
72) What do you know about wildcard interpretation?
73) What do know about tee command and its usage?
74) Explain mount and unmount command.
75) What is ephemeral port?
76) How do you find which processes are using a particular file?
77) How do you find which remote hosts are connecting to your host on a particular port say
10123?
78) How to tell if my process is running in Unix?
79) What is ephemeral port in UNIX?
80) How to list down file/folder lists alphabetically
81) If one process is inserting data into your MySQL database? How will you check how
many rows inserted into every second?
82) There is a file Unix_Test.txt which contains words "Unix". How will you replace all
Unix to UNIX?
83) You have a tab separated file which contains Name, Address and Phone Number. List
down all Phone Number without their name and addresses?
84) How to check if the last command was successful in Unix?
85) echo $?
86) How to check all the running processes in Unix?
87) If you wish to see the % of memory usage and CPU usage, then consider the below
switches
88) Your application home directory is full? How will you find which directory is taking
how much space
89) How do you find for how many days your Server is up?
90) How to check if a file is present in a particular directory in Unix?
91) ls –l file.txt; echo $?
92) You have an IP address in your network. How will you find hostname and vice versa?
93) How to execute a database stored procedure from Shell script?
94) How to check the command line arguments in a UNIX command in Shell Script?
95) How to fail a shell script programmatically?
96) How to print/display the first line of a file?
97) How to print/display the last line of a file?
98) How to display n-th line of a file?
99) How to remove the first line / header from a file?
100) How to remove the last line/ trailer from a file in Unix script?
101) How to remove certain lines from a file in Unix?
102) How to remove the last n-th line from a file?
103) How to check the length of any line in a file?
104) How to get the nth word of a line in Unix?
105) How to reverse a string in unix?
106) How to get the last word from a line in Unix file?
107) How to get the n-th field from a Unix command output?
108) How to replace the n-th line in a file with a new line in Unix?
109) How to show the non-printable characters in a file?
110) How to zip a file in Linux?
111) How to unzip a file in Linux?
112) How to test if a zip file is corrupted in Linux?
113) How to check if a file is zipped in Unix?
114) What difference between ' and " quotes ?
115) Write a script to print the first 10 elemenst of Fibonacci series.
116) How do you debug bash script?
117) How do you check if file exists on filesystem?
118) What is the use of a shebang line?
119) How to compare numbers in Linux shell Scripting ?
120) What is the use of break command ?
121) What needs to be done before you can run a shell script from the command line
prompt?
122) What code would you use in a shell script to determine if a directory exists?
123) How do you access command line arguments from within a shell script?
124) What does 2>&1 mean and when is it typically used?
125) What are some ways to debug a shell script problem?
126) Within a UNIX shell scripting loop construct, what is the difference between the
break and continue?
127) What is the use of “$?” sign in shell script ?
128) How to debug a shell script ?
129) How to test files in a shell script ?
130) How to put comments in your shell script ?
131) How to get input from the terminal for shell script ?
132) How to unset or de-assign variables ?
133) How to perform arithmetic operation ?
134) Basic Syntax of do-while statement ?
135) How to define functions in shell scripting ?
136) How to use bc (bash calculator) in a shell script
137) How do you find which processes are using a particular file?
138) How do you find which remote hosts are connecting to your host on a particular port
say 10123?
139) How to tell if my process is running in Unix?
140) What is ephemeral port in UNIX?
141) How to list down file/folder lists alphabetically?
142) If one process is inserting data into your MySQL database? How will you check how
many rows inserted into every second?
143) There is a file Unix_Test.txt which contains words "Unix". How will you replace all
Unix to UNIX?
144) You have a tab separated file which contains Name, Address and Phone Number. List
down all Phone Number without their name and addresses?
145) How to check if the last command was successful in Unix?
146) How to check all the running processes in Unix?
147) Your application home directory is full? How will you find which directory is taking
how much space?
148) How do you find for how many days your Server is up?
149) How to check if a file is present in a particular directory in Unix?
150) You have an IP address in your network. How will you find host name and vice
versa?
151) Copy the file F3 to your current directory.

152) Copy all the contents of directory D1 into directory D3.

153) Move the file F2 to your current directory.

154) Move file F4 to user U3

155) List all the contents of user U3.

156) List the contents of directory D3.

157) List all the contents of directory D6 using absolute path.

158) Open the file F1 with vi

159) Open the file F4 with vi, open the file F3 in edit mode.

160) Rename the file F3 as f3

161) How will you search the file F1

162) How will you search the given pattern in a file without opening the file.
163) How will you complete a command just typing 1 or 2 characters.

164) How will you list hidden files.

165) How can you view the file permissions and change its permissions.

166) Write the format to change the permissions of file xyz. Give all permissions only to
the user.

167) What is the command to change the owner, specify its format.

168) Rename a file x as y and a directory Abc/ as Xyz/

169) Command to check your present working directory.

170) Using the file structure shown below. Perform the following operations assuming that
you are in directory D4. Use relative path if path type is not specified.
171) Linux Systems, Quiz 1 - Commands
172) Which command will display the current date.
173) How do you find the kernel version
174) How do you print system information (machine, kernel, OS)
175) Use bc and find the value of 125 / 5
176) Use bc and find the value of 10 / 3. What is the output? Change bc options to get the
correct output.
177) What is the name of admin/super user in Linux.
178) Which command will display the user currently logged in.
179) Which command will display the list of all users logged in.
180) How do you list all the groups the current user belongs to.
181) What is root user's id. Which command will help you to find it.
182) Assuming you are logged in as a normal user, how can you execute a command as
root.
183) How do you login as root in linux, assuming you are already logged in as a normal
user.
184) How do you create a new user in Linux.
185) How will you change your password.
186) Can root user change user's password. How?
187) What do you understand by group. How do you create a new group.
188) How do you add a group to a user.
189) Which files contains user login details and group details.
190) Which file contains the hashed password of a user.
191) Which directory is root user's home directory.
192) Which is the home directory for a user named "xyz".
193) Is it possible to change user's how directory. How?
194) How do you display current user's home directory name.
195) What is your user-id and user-name and group id.
196) Find your default shell.
197) How do you list all the files in the current directory
198) Which is the top level directory in linux. List all the files in the top level directory.
Who is its owner, and which group does it belong to.
199) List down all the files in the root directory
200) Which command will display current working directory
201) How will you cd to your home directory
202) What is the shortcut for your home directory name.
203) Assuming you are in /tmp. You have a directory called Desktop in your home
directory. cd to the Desktop directory using a single command.
204) How do you go the previous working directory.
205) Which directories contains the following

- binaries/executable

- library files

- configuration files

- log files

- temporary files

- binaries/executable for system and system admin

- User's home directories

- Root user's home directory

- kernel, and boot loader releated files

- device files

- Scripts invoked during bootup

- Removable media contents (Pen driver, cdrom etc)

- Externally mounted filesystem

206) Which is the directory seperator in Linux/Unix

a) Back-slash (\)

b) Forward slash (/)

207) How will you create an empty file in linux


208) How do you know whether a file is executable in linux?
209) What is the size of your machines kernel.
210) How do you create a hardlink to a file /etc/hosts
211) How do you create a softlink to a file /etc/hosts
212) What is an inode number. How do you display the inode number of a file.
213) What is the difference between hardlink and softlink.
214) What does find command do? Write down the syntax of find command
215) What does grep command do? Write down the syntax of find command
216) Use find to list all the .c files in current directory
217) Use find to list all the .c files in src directory
218) Use find to list all the .c and .h files in current directory (Use only one find)
219) Search for tcp in /etc/services
220) Search for tcp and udb in /etc/services (Use options in grep)
221) Search for tcp and udb in /etc/services, but ignore line containing #. Lines containing
# should be filtered out
222) Find/Display all subdirectories in current directory. Do not display other types of files
223) Find/Display all regular files in current directory. Do not display other types of files
224) Find all executables in current directory
225) touch some files. Find all files you modified in last 5 minutes.
226) touch some files. Find all files you modified before last 5 minutes.
227) Find all files greater than 10KB in CWD. (Assuming you have few files greater than
10KB)

You might also like