Linux System Calls Interview Preparation Guide
Download PDF

Linux System Calls frequently Asked Questions by expert members with experience in Linux System Calls. These interview questions and answers on Linux System Calls will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. So get preparation for the Linux System Calls job interview

35 Linux System Calls Questions and Answers:

1 :: How to get microseconds of system time from Redhat Linux 4.0?

The systemcall "gettimeofday" can be used to get the time in microseconds. The call takes two arguments.
1- struct timeval
2- struct timezone ( for timezone information). you can have second argument null.
timeval structure has two fields:
tv_sec ( represents time in seconds)
tv_usec ( represents time in microseconds )

the code snapshot is :
////
struct timeval t_time;
gettimeofday(&t_time,NULL);

2 :: what is mean by raid and what are all raids available even in software and hardware?

Raid is Redundant Array of Independent Disks/Device.It is
Technology to improve Disk read & write Performence and
FaultTolerance., By adding new disk u can recover data if
one of disk goes down / fails. parity is a calculated
technique to rebuild data from disk fails.
levels in Raid
0 - stripping
1 - Mirroring
3 - Striping with Parity
5 - Striping with Parity with more fault tolerant widley used.

3 :: Why the kernel panic error was appearing?

(1)Suppose any problem in initrd file then kernel panic error showing
(2)Any file system problem or any change or remove file system then showing the kernel panic error

4 :: How to create samba server in fedora Linux 9?

vi /etc/samba/smb.conf
Add these lines

[fedora 9]
comment=publicstuff
path=/share
public=yes
writable=yes
available=yes
create mask=0777
directory mask=0777

5 :: How to create a ftp user on RedHat Linux 4.0?

firstly create the user.
useradd surendra
passwd surendra

then opne the FTP file:-
vi /etc/vsftpd/vsftpd.conf
add this line at the end of the file
userlist_deny=NO

then open this file,
vi /etc/vsftpd/user_list

and add the above created user in this file to access FTP
services.

and restart the FTP services
/etc/init.d/vsftpd start
chkconfig vsftpd on ( for permanent on )

6 :: What is cups and how to configure?

CUPS (formerly an acronym for Common Unix Printing System,
but now with no official expansion) is a modular printing
system for Unix-like computer operating systems which allows
a computer to act as a print server. A computer running CUPS
is a host that can accept print jobs from client computers,
process them, and send them to the appropriate printer.

If you are using a client with CUPS and a CUPS server has
already been configured, installing the printers on your
client can not get much easier than this: do nothing.
Through broadcasting, the client should find the CUPS server
and automatically configure the printers that are installed
on that print server. This is one of the features of CUPS
that will be really appreciated on large networks.

Manually configuring printers with CUPS, also is a peace of
cake. If you are new to CUPS and/or Unix printing, the way
to go is probably the web interface. If you have to
configure lots of printers, using the command-line will
probably be faster.

The URL to access the CUPS web interface is
http://hostname:631/admin by default. The port can be
changed in cupsd.conf if necessary.

To add a printer from the command-line the general syntax is
lpadmin -p printer -E -v device -m ppd Lpadmin with the -p
option adds or modifies a printer. The printers are saved in
the file The -x option deletes the named printer. Read the
lpadmin man page for available options.

Example 3. command-line examples

/usr/sbin/lpadmin -p testpr1 -E -v socket://192.168.1.9 -m
deskjet.ppd
/usr/sbin/lpadmin -p testpr2 -E -v parallel:/dev/lp0 -m
laserjet.ppd
/usr/sbin/lpadmin -x testpr1

More information about configuring printers and options can
be found in the CUPS documentation. The Software
Administrators Manual will teach you all you need to know
about configuring printers with CUPS.

7 :: What are the backup utilities on red hat Linux 4.0?

cpio with find command ,tar with gun/bunzip ,dump with only
ext2 & ext3 Fs used to take backups
Also you have amanda software in RHEL 4.0 version to take a
backup

8 :: How to configure http server on red hat linux4.0?

Simple configuration
--------------------
Install apache: (get the rpm for apache)

# rpm -ivh httpd.rpm

# vi /etc/httpd/conf/httpd.conf

and change
ServerName your-domain.com

Start apache : service httpd start

Verify by pointing the browser to http://localhost/

9 :: What is sudo on Linux?

The sudo command stands for "superuser do". If a server
needs to be administered by a number of people it is
normally not a good idea for them all to use the root
account. This is because it becomes difficult to determine
exactly who did what, when and where if everyone logs in
with the same credentials. The sudo utility was designed to
overcome this difficulty.

The sudo utility allows users defined in the /etc/sudoers
configuration file to have temporary access to run commands
they would not normally be able to due to file permission
restrictions. The commands can be run as user "root" or as
any other user defined in the /etc/sudoers configuration file.

The privileged command you want to run must first begin with
the word sudo followed by the command's regular syntax. When
running the command with the sudo prefix, you will be
prompted for your regular password before it is executed.
You may run other privileged commands using sudo within a
five-minute period without being re-prompted for a password.
All commands run as sudo are logged in the log file
/var/log/messages.

In order to use sudo we first need to configure the sudoers
file.

Do not edit directly the file:

To edit it, use the command

# visudo

******Output***************

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL) ALL
**********************************************

You will see the line

root ALL=(ALL) ALL

This lines means that the user root can execute from ALL
terminals, acting as ALL (any) users, and run ALL (any) command.
The first part is the user, the second is the terminal from
where the user can use sudo, the third is as which user he
may act, and the last one, is which commands he may run.

Example:

Granting Access To Specific Users To Specific Files
---------------------------------------------------
amsin21, %operator ALL= /sbin/, /usr/sbin,
/usr/local/apps/check.pl

This entry allows user amsin21 and all the members of the
group operator to gain access to all the program files in
the /sbin and /usr/sbin directories, plus the privilege of
running the command /usr/local/apps/check.pl. Notice how the
trailing slash (/) is required to specify a directory location:

Granting Access to Specific Files as Another User
-------------------------------------------------
The sudo -u entry allows allows you to execute a command as
if you were another user, but first you have to be granted
this privilege in the sudoers file.

This feature can be convenient for programmers who sometimes
need to kill processes related to projects they are working
on. For example, programmer amsin21 is on the team
developing a financial package that runs a program called
monthend as user accounts. From time to time the application
fails, requiring "amsin21" to stop it with the /bin/kill,
/usr/bin/kill or /usr/bin/pkill commands but only as user
"accounts". The sudoers entry would look like this:

amsin21 ALL=(accounts) /bin/kill, /usr/bin/kill, /usr/bin/pkill

User amsin21 is allowed to stop the monthend process with
this command:

# sudo -u accounts pkill monthend

Granting Access Without Needing Passwords
-----------------------------------------

This example allows all users in the group operator to
execute all the commands in the /sbin directory without the
need for entering a password. This has the added advantage
of being more convenient to the user:

%operator ALL= NOPASSWD: /sbin/

Using Aliases in the sudoers File
---------------------------------

Sometimes you'll need to assign random groupings of users
from various departments very similar sets of privileges.
The sudoers file allows users to be grouped according to
function with the group and then being assigned a nickname
or alias which is used throughout the rest of the file.
Groupings of commands can also be assigned aliases too.

In the next example, users amsin21, amsin211 and amsin212
and all the users in the operator group are made part of the
user alias ADMINS. All the command shell programs are then
assigned to the command alias SHELLS. Users ADMINS are then
denied the option of running any SHELLS commands and su:

Cmnd_Alias SHELLS = /usr/bin/sh, /usr/bin/csh, \
/usr/bin/ksh, /usr/local/bin/tcsh, \
/usr/bin/rsh, /usr/local/bin/zsh


User_Alias ADMINS = amsin21, amsin211, amsin212, %operator
ADMINS ALL = !/usr/bin/su, !SHELLS

This attempts to ensure that users don't permanently su to
become root, or enter command shells that bypass sudo's
command logging. It doesn't prevent them from copying the
files to other locations to be run. The advantage of this is
that it helps to create an audit trail, but the restrictions
can be enforced only as part of the company's overall
security policy.

10 :: What is iptabe on RedHat Linux?

Iptables is the userspace command line program used to
configure the Linux 2.4.x and 2.6.x IPv4 packet filtering
ruleset. Iptables allows administrators to configure the
operating system so that it allows applications and clients
to connect through the network and stop unwanted
applications and clients from communicating and corrupting
the operating system.
It is not specific to Redhat. It is available in all linux
2.4.x and 2.6.x kernels.