[Ilugc] [[Linux]] Few Technical Questions

  • From: scorpionking.sahil@xxxxxxxxx (Sahil ModGill)
  • Date: Tue, 15 Oct 2013 20:09:47 +0530

Greetings All,

I have few technical questions on which I need views. So kindly share your
views. And I have answered which I know. Please correct me if my answers
are wrong.

1. Which of the following 2 options is efficient and why?
a. tail -c 100 /tmp/test
b. cat /tmp/test | tail -c 100

Answer 1: Option (a) is efficient because it prints the last '100' bytes
from the file whereas option (b) firstly concatenate the file and then
parse it to last '100' bytes so option (a) is efficient.
Technically speaking: there's one fork in option (a) which requires no IPC
but in option (b) there are two forks and requires IPC.

2. Describe what the following command pipeline tries to do:
nc -l 10000 < /tmp/fifo | tee client_request | nc google.com 80 | tee
server_response > /tmp/fifo and how should /tmp/fifo be created (give the
command) for this to work as expected?

3. You freezed your laptop by closing its lid with out exiting your ssh.
now when you open it again, how do you exit the ssh (closing the pty or
killing is not elegant).

Answer 3: As far as I know, in both cases (if keys are saved or not), we
have to 'logout' the session manually. SSH-connection terminates if we move
one system from the location for some period (because next time we'll get
the IP from dhcp that can create confusions).

4. You only have 10mb disk space left, but still truncate -s 1g /tmp/file
succeeds and the file size shows 1gb post creation. explain how and why ?


Thank you.

-- 
*Regards,
Sahil ModGill*

Other related posts:

  • » [Ilugc] [[Linux]] Few Technical Questions - Sahil ModGill