UNIX ASSIGNMENT 1

1. Create a tree structure named training in which there are 3 subdirectories level 1 , level2 and cep . Each one is again further divided into 3. The level 1 is divided to sdp , re and se . From the subdirectory se how can one reach the home directory in step and also how to navigate to the subdirectory sdp in one step? Give the comman ds, which do the above actions? A) % mkdir training % cd training now we are in training directory.now type the following command % mkdir level 1 % mkdir level2 % mkdir cep now change directory to level 1 by following command % cd level1 now type following command % mkdir sdp % mkdir re % mkdir se From the directory se to reach the home directory in one step just type cd command at % prompt.it will direct us to the home directory of the user and to n avigate to the subdirectory sdp in one step type following command at % promp t % cd ~/training/level1/sdp 2. How will you copy a directory structure dir1 to dir2 ? (with all the subdirec tories) A) % cp -r /dir1 /dir2 3. How can you find out if you have the permission to send a message? A) % ls -l If, in the output, we get; -rw------- , then only the owner have the rig ht to send the message, while others can't 4. Find the space occupied ( in Bytes) by the /home directory including all its subdirectories. A) % du -b -s . 5. What is the command for printing the current time in 24-hour format? A) % date 6. What is the command for printing the year, month, and date with a horizontal tab between the fields? A) % date +"%y"%'\t'"%m"%'\t'"%d" 7. Create the following files: chapa, chapb, chapC, chapD, chapE, chap01, chap02, chap03, p13, chap14, and chap15. A) touch chapa chapb chapc chapd chape chapA 02 chap03 chap04 chap05 chap11 chap12 chap13 chapc, chapd, chape, chapA, chapB, chap04, chap05, chap11, chap12, cha chapB chapC chapD chapE chap01 chap chap14 chap15

8. With reference to question 7, What is the command for listing all files endin g in small letters? A) % ls egrep [a-z]$ or type this command % find . -name "*[a-z]" 9. With reference to question 7, What is the command for listing all files endin

each one sleeping for 10 minutes. which are programs that are laun ched during booting (i.g in capitals? A) % ls egrep [A-Z]$ or type this command % find . sleep NUMBER[SUFFIX]. computer startup) and run unobtrusively in the backgr ound until they are activated by a particular event or condition. h end in small letters but not a A) % ls egrep [a-z]$ egrep -v or type this command % find .. sleep OPTION DESCRIPTION Pause for NUMBER seconds. here NUMBER may be an arbitrary floating p oint number. giv e the following command 5 times sleep 10m & 16. With reference to question 7. Unlike most implementations that require NUMBER be an integer. .e. Find out about the sleep command and start five jobs in the background.. each one sleeping for 10 minutes. A) % sed -n '/programmer/p' < personnel 14. -name "*[A-Z]" 10. Ever y record has field for designation.e. -name "*[a-z]" -not What is the command for listing all files whic and c ? [a]$ egrep -v [c]$ \( -name "*a" -o -name "*c" \) 12.The -u option tells ps to provide detailed in formation about each process. The -x option adds to the list processes that have no controlling terminal. pause for the amount of time specified by the sum of their values. u sing what option? A) A common and convenient way of using ps to obtain much more complete informat ion about the processes currently on the system is to use the following: % ps -aux less file The -a option tells ps to list the processes of all users on the system rat her than just those of the current user. To start five jobs in the background. A) % sleep . with the exception of group leaders and processes not associated with a terminal. How can grep be used for this purpose? A) % grep -ic programmer personnel 13. With reference to question 7. -name "*0?" 11. In an organisation one wants to know how many programmers are there.. What is the command for listing all files whos e last but one character is 0? A) % find . Given two or more arguments. `h' for hours or `d' for days. How do you get the status of all the processes running on the system? i. SUFFIX may be `s' for seconds (the default). such as daemons.`m' f or minutes.delay for a specified amount of time. In the organisation mentioned in question 12 how can sed be used to change t he designation programmer to software professional every where in the personnel A) % sed 's/programmer/software professional/g' < personnel 15. The emp loyee data is stored in a file called personnel with one record per employee. In the organisation mentioned in question 12 how can sed be used to print on ly the records of all employees who are programmers. A group leader is the first member of a group of related processes.