Code – ETCS-307 LINUX AND X WINDOWS PROGRAMMING

Assignment II

Question 1:

I) What is the purpose of following commands?

a)kill -9

(Hint: Surest kill, can’t be trapped)

b)init 6

(Hint: Reboot)

c)ls –all

(Hint: lists all the files including hidden ones)

d)cut –d: -f1,3 filename

(Hint: this will cut the first and third fields of the file named as filename and consider the colon as delimiter )

e)cd../..

(Hint: if you are in some file or directory, this command will lead you to the top of the directory structure which is root)

f)grep “manager” emp_data>file1 2>/dev/null

(Hint: grep is a serachstring, it is searching manager from emp_data and is stored in file 1. Apart from this the content will be redirected to in /dev/null where /dev/null is a dummy file which is considered as null)

g)ls..

(Hint: List files of a parent directory)

II) What is the purpose of ifconfig tool, iwconfig tool and linuxconf tool?

Question 2: Write Linux commands

a)To establish connections with remote user.

(Hint: rlogin, telnet-23, ssh-works on port 22. ssh is a program to log into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh and provides secure encrypted communications between two untrusted hosts over an insecure network.)

b)To display current working directory. (2 methods).

(Hint: pwd: prints current working directory and echo $ PWD)

c)To display the filenames included in the archive abc.tar.

(Hint: tar –tvf, t=list content of archive, v=verbosely list file process, f=use archive file or device archive )

d)To mount a pen drive in read only mode with ext3 file system type. (Hint: $ mount -t vfat -o r /dev/sdb1 /media/disk)

e)To remove a non-empty directory.

(Hint: rm –rfdir_name>, recursively and forcefully removes)

f)To find the name of current working shell on which you are working.

(Hint: $ echo $SHELL)

g)To shut down the system at 2:00 p.m.

(Hint: $ shutdown –h 14:00)

h)To kill a process of pid 1099.

(Hint: $ kill 1099)

i)To find the total number of users working in a network.

(Hint: users. Lists the users currently logged in )

Question 3:

a)What is difference between “pwd” and “PWD”?

(Hint: pwd is print working directory & PWD is the variable to store the path name of current working directory)

b)What are the default permissions for newly created regular files and directories?

(Hint: default file permission can be revealed by creating a file (lets say arena) and using a command $ ls –l arena

-rw-r--r--)

c)List 5 options used with ls command.

(Hint: -a, -l, -x, -R, -d, -L, -n, -t, -u etc)

d)How many types of users can be created in Linux OS?

(Hint: Root and Normal users)

e)Where ownership and group ownership details are stored?

(Hint: /etc/passwd and /etc/group)

f)You removed the write permission of a file from a group and others, and yet they could delete your file. How could that happen?

(Hint: Your directory has write permission for them)

g)For a group member to be able to remove a file what does she require?

(Hint: she requires group write permission on the directory containing the file name.)

h)Which file attributes are changed when you copy a file from one user to another user account?

(Hint: no change in file attributes apart from the path)

i)Which option do you use for with kill to make sure that process is killed?

(Hint: -9 or SIGKILL option)

j)How do you display signal list?

(Hint: kill -l)

k)Can you kill processes of other users?

(Hint: only if you are a superuser)

l)What are the two system calls used to create the process?

(Hint: fork(), exec())

m)What is the easiest way of finding out PID of your login shell?

(Hint: $ echo $$)

n)How can you remove header file from ps output?

(Hint: ps | tail +2)

o)Why isps –f considered to be an intrusion into user’s privacy?

(Hint: because it shows the name of file that the user is working on)

p)When does the login shell spawn another shell?

(Hint: when a user logs out)

q)Which is the process that listens on every terminal for a login request? (Hint: getty)

r)Does ls –l show all the files?

(Hint: not hidden files)

s)Which ls option marks directories and executables separately?

(Hint: -F option marks directory with /a and executables with an *)

t)How do you obtain complete listing of all files and directories in the whole system?

(Hint: ls –R /)

u)How do you list files of parent directory?

(Hint: Use ls .. to list files in a parent directory)

v)Who can change the attributes of a file or a directory?

(Hint: Superuser)

w)For a group member to be able to remove a file, what are the requirements?

(Hint: requires group write permissions on the directory containing the filename)

x)First create a file. How will you assign all permission to the owner and remove all permissions from others assuming that default file permissions are –rw-r--r--?

(Hint: chmodu+x, go-r)

y)If the file doesn’t have write permission for the owner, can she remove the file?

(Hint: yes only if she has write permission for her group)

z)If the owner doesn’t have write permission on a file but her group has, can she edit it?

(Hint: yups)

Question 4:

a)How long can a LINUX file name can be?

(Hint: 256)

b)Can you have a file past and Past in the same directory?

(Hint: yes, Linux is case sensitive)

c)How will you copy directory structure from bar1 to bar2?

(Hint: use cp –r bar1 bar2)

d)What is the difference between du, df and fdisk commands?

(Hint: du-disk space used by each subdirectory as well as files under a directory. Also show the summary at the end. du –s shows only the summary

df-amount of disk space used and free disk space available for each file in kilobytes. df –h shows the same in human readable form i.e., in MBs

fdisk-to create partitions manually)

e)With reference of permission, what is the meaning of 544 and umask 002?

(Hint: for directory & file: read and execute permission for user, read permission for both the group to which the owner belongs and for other groups.

umask 002: for directories: 777-002=775, i.e., read, write & execute permission for user and its group but only read and execute permission for other users.

For Files: 666-002=664, i.e., read and write permission for both user and its group and only read permission for others.)

f)List 5 differences between Linux and UNIX OS.

g)List the differences between ext2 & ext3 file-systems.

h)List 5 commands to compare files.

(Hint: cmp, diff, sdiff, cat, more)

Arena Nishant

Page 1