Advertisement
balaji

ASSIGNMENT 1

May 15th, 2011
1,184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  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 into ‘sdp’, ‘re’ and ‘se’. From the subdirectory ‘se’ how can one reach the home directory in one step and also how to navigate to the subdirectory ‘sdp’ in one step? Give the commands, which do the above actions?
  2.  Ans) $ mkdir training $ cd training $ mkdir level1 level2 cep $ cd level1 $ mkdir sdp re se $ cd se $ pwd /home/Mani/training/level1/se $ cd ~ $ pwd /home/Mani $cd training $cd level1 $cd se $cd ../sdp $pwd /home/Mani/training/level1/sdp
  3.  
  4. 2. How will you copy a directory structure dir1 to dir2 ? (with all the subdirectories)
  5.  Ans) $ cp -R dir1 dir2
  6.  
  7. 3. How can you find out if you have the permission to send a message?
  8.  Ans) $ ls -l
  9.  
  10. 4. Find the space occupied ( in Bytes) by the /home directory including all its subdirectories.
  11.  Ans) $ du -sb
  12.  
  13. 5. What is the command for printing the current time in 24-hour format?
  14. Ans) $ date +%T
  15.  
  16. 6. What is the command for printing the year, month, and date with a horizontal tab between the fields?
  17.  Ans) $ date +%Y%t%m%t%d
  18.  
  19. 7. Create the following files: chapa, chapb, chapc, chapd, chape, chapA, chapB, chapC, chapD, chapE, chap01, chap02, chap03, chap04, chap05, chap11, chap12, chap13, chap14, and chap15.
  20.  Ans) $ touch chapa chapb chapc chapd chape chapA chapB chapC chapD chapE chap01 chap02 chap03 chap04 chap05 chap11 chap12 chap13 chap14
  21.  
  22. 8. With reference to question 7, What is the command for listing all files ending in small letters?
  23.  Ans) $ find . -name “*[a-z]”
  24.  
  25. 9. With reference to question 7, What is the command for listing all files ending in capitals?
  26.  Ans) $ find . -name “*[A-Z]”
  27.  
  28. 10. With reference to question 7, What is the command for listing all files whose last but one character is 0?
  29. Ans) $ find . –name “*0?” 
  30.  
  31. 11. With reference to question 7, What is the command for listing all files which end in small letters but not ‘a’ and ‘c’?
  32.  Ans) $ find . -name “*[bd-z]”
  33.  
  34. 12. In an organisation one wants to know how many programmers are there. The employee data is stored in a file called ‘personnel’ with one record per employee. Every record has field for designation. How can grep be used for this purpose?
  35. Ans) $ grep -c programmer personnel
  36.  
  37. 13. In the organisation mentioned in question 12 how can sed be used to print only the records of all employees who are programmers.
  38.  Ans) $ sed -n "/programmer/p" personnel
  39.  
  40. 14. In the organisation mentioned in question 12 how can sed be used to change the designation ‘programmer’ to ‘software professional’ every where in the ‘personnel’ file
  41.  Ans) $ sed -e "s/programmer/software professional/g" personnel
  42.  
  43. 15. Find out about the sleep command and start five jobs in the background, each one sleeping for 10 minutes.
  44.  Ans) $ sleep 10 & sleep 10 & sleep 10 & sleep 10 & sleep 10 &
  45.  
  46. 16. How do you get the status of all the processes running on the system? i.e. using what option?
  47.  Ans) $ ps -e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement