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?
Answer:
1.To go home directory from se = cd ~
Here: cd = change directory, ~ = for home directory.
2.To navigate to subdirectory sdp = cd training/level1/sdp
2. How will you copy a directory structure dir1 to dir2 ? (with all the subdirectories)
Answer: cp –R dir1 dir2
Here: cp = copy, -R =copy directories recursively.
3. How can you find out if you have the permission to send a message?
Answer: ls -l
4. Find the space occupied ( in Bytes) by the /home directory including all its subdirectories.
Answer: du -sb
Here: du = outputs the number of kb used by each subdirectory.
-s =including subdirectory (total) , -b = bytes
5. What is the command for printing the current time in 24-hour format?
Answer: date +%R
Here : %R = 24 hr format (hr:min)
6. What is the command for printing the year, month, and date with a horizontal tab between the fields?
Answer: date +%F
Here : %F = Full date ;%Y-%M-%D
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.
Answer:
Cat > chapa Contents of file Ctrl+D Cat > chapb Contents of file Ctrl+D
Cat > chapc Contents of file Ctrl+D Cat > chapd Contents of file Ctrl+D
Cat > chape Contents of file Ctrl+D Cat > chapA Contents of file Ctrl+D
Cat > chapB Contents of file Ctrl+D Cat > chapC Contents of file Ctrl+D
Cat > chapD Contents of file Ctrl+D Cat > chapE Contents of file Ctrl+D
Cat > chap01 Contents of file Ctrl+D Cat > chap02 Contents of file Ctrl+D
Cat > chap03 Contents of file Ctrl+D Cat > chap04 Contents of file Ctrl+D
Cat > chap05 Contents of file Ctrl+D Cat > chap11 Contents of file Ctrl+D
Cat > chap12 Contents of file Ctrl+D Cat > chap13 Contents of file Ctrl+D
Cat > chap14 Contents of file Ctrl+D Cat > chap15 Contents of file Ctrl+D
Here: cat = to concatenate a file.
> = to redirect the output
8. With reference to question 7, What is the command for listing all files ending in small letters?
Answer: find . –name “*[a-z].*”
9. With reference to question 7, What is the command for listing all files ending in capitals?
Answer: find . –name “*[A-Z].*”
10. With reference to question 7, What is the command for listing all files whose last but one character is 0?
Answer: find . –name “*0?.*”
Here: ? = wildcard(will match exactly one character.)
11. With reference to question 7, What is the command for listing all files which end in small letters but not ‘a’ and ‘c’?
Answer: find . –name “*[b d-z].*”
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?
Answer: $ grep -c programmer personnel
Here: -c = count
13. In the organisation mentioned in question 12 how can sed be used to print only the records of all employees who are programmers.
Answer: $ sed -n “/programmer/p” personnel
Here: sed =stream editor
/ /p =for printing pattern space
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
Answer: $ sed -e “s/programmer/software professional/” personnel
Here: sed =stream editor
-e = script
s/regexp/replacement =for replacement
15. Find out about the sleep command and start five jobs in the background, each one sleeping for 10 minutes.
Answer: $ sleep 10 & sleep 10 & sleep 10 & sleep 10 & sleep 10 &
16. How do you get the status of all the processes running on the system? i.e. using what option?
Answer: $ ps –e
Here:ps= displays information about the selection of active processes.
-e = select all processes.
May 15th, 2012 at 2:32 pm
very helpful! thanks.
June 12th, 2012 at 9:05 pm
thanku so much 🙂
June 14th, 2012 at 12:43 am
hey frnds do u want all assignments…jst let me know here
and thank you for ur precious feedback
July 17th, 2012 at 1:32 pm
awesome,this.
it’ll be great if you can help for all assignments:)
September 11th, 2012 at 8:01 pm
Dude i have a little change here, i might be wrong..
As in question 7 we have created files without any extension (like .c, .cpp, .txt etc..).
So the answer of the questions 8 9 10 and 11 could be like this..
8.
Answer: find . –name “*[a-z]”
9.
Answer: find . –name “*[A-Z]”
10.
Answer: find . –name “*0?”
11.
Answer: find . –name “*[b d-z]”
Please let me know if i m wrong.
September 21st, 2012 at 8:31 pm
thank u very much:) it helped me alot:)
October 25th, 2012 at 6:10 pm
Thank you.
February 16th, 2013 at 1:52 pm
sir, the ans of Q3 would b finger -i or who -T….how ls -l can show permissions to send message
February 17th, 2013 at 11:53 am
Hello Aditya
Thank you for your comment
here are some link that might be useful to you
1. http://mally.stanford.edu/~sr/computing/basic-unix.html
2. http://www.umanitoba.ca/cgi-bin/man.cgi?section=1&topic=ls
3. http://www.umanitoba.ca/cgi-bin/man.cgi?section=1&topic=finger
4. http://www.umanitoba.ca/cgi-bin/man.cgi?section=1&topic=who
5. http://www.umanitoba.ca/cgi-bin/man.cgi?section=1&topic=mesg
It will be helpful if you can show me outputs of above commands
I also searched about it while preparing it..but unable to find correct answers.. 😦
anyways welcome to TCS 🙂
February 17th, 2013 at 11:45 am
Requesting to all viewers please share your ideas so that i can make this blog as source of information…
Thank you in Advance..!!!
July 2nd, 2013 at 12:50 pm
This is the perfect webpage for everyone who really wants to understand this topic.
You realize a whole lot its almost hard to argue with you (not that I really would want to…HaHa).
You certainly put a fresh spin on a topic which has been discussed for decades.
Great stuff, just wonderful!
March 1st, 2014 at 11:35 pm
Hello to all, the contents present at this website are genuinely awesome
for people experience, well, keep up the nice work fellows.
March 1st, 2014 at 11:47 pm
Awesome things here. I’m very happy to look your post.
Thank you a lot and I am looking ahead to touch you.
Will you please drop me a e-mail?
March 2nd, 2014 at 11:44 pm
Thank you for your inspirational word…Please drop me mail for any query and information and such kind words kharwade.aditya@gmail.com
September 16th, 2017 at 10:32 pm
It’s going to be end of mine day, except before finish I am reading this enormous post to
improve my know-how.