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

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

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.