Lets have some fun on the first day !!
Now the following tut will tell u a few fun stuff about
1. Linux terminal.
2. Shell.
3. Multiple users.
Well it happened once that i was sitting in my school's computer lab(all machines were running linux). It was of a time when i used to think that linux was but a cheap imitation of windows and that a computer that could not run any games was just not worth getting interested in.
I just had this gnome terminal open(some thing like cmd prompt on windows C:\) and was just looking at the time to see when that terrible period would be over and i could get out of that drool...
Then i see out of no where this message being printed on my screen. And i was like 'what the ... ?' .
Now in a situation like this there is no point making an assumption that you are 'Neo' and 'Morphius' is pinging you from somewhere trying to warn you of the Matrix( but its only human to have your failings. right ?? ).
Now in a situation like this the best thing to do is get some help. So i called the guy next to me(who was by the way the top of the class in the subject). And that guy was quite excited himself. He told me the following things that day that really helped me a lot
1. Linux is a machine whose inheritence comes from Unix, and those Unix machines were built with one very important thing in mind - NETWORKING.
2. In linux EVERYTHING IS A FILE. Be it a device, a directory, a terminal or what ever you can think of.
But at that particular movement my reaction was - "So what's that got to do with Morohius pinging me ??".
"Well when unix was written the computers were very expensive. If you joined as a developer to some company you would never have got a PC to your self, instead there would have been one main machine and all of you people would have got only a monitor that would connect to that monster of a machine(UNIX). There terminals were called tele-type-terminals (tty for short).
Also as all the people were logged into one system you could see things like.
1. who all are logged in
2. what terminals the people are using
3.from what ip address they are logged in.
... and many other important information......
In todays world the thing that those tty's used to do is done using softwares like putty(isn't that amazing replacing hardware with a 200kb of executable file :-) ). Using one tty you could log into any other linux machine, all you need to know is the ipaddress, username and password of the machine that you wanted to login. Now in the school all the machines have the same username password. so anyone can log into your machine if they know the ipaddress. and knowing the ipaddress is also not a problem if its pasted on top of the monitor"
"Oh!! that's what those 4 numbers with dots between them are?? I always wondered what that was ?? Ok so any one can log into my machine ?"
"Yeah!! you can see the screen here "
"I am logging into your machine using the ssh command"
"what is this ssh command"
"We would keep that for later"
"ok"
"using the who or finger command we can find out who all are logged in and what terminal they are using?"
"Terminal??"
"That window where you type into the screen you dummy!!!"
"Oh.. right .. "
"Now this terminal has a name assigned to it, we can find that by typing the command tty".
"See that output. that is the name of the terminal"
"Now do you remember that everything is a file is linux?"
"Are you saying that terminal is also a file according to the linux machine?"
"yeah, and just like you write to a file you can write to the terminal"
"But you can do this only if you are logged in as the same user" lets us see how many people are logged into your system. What command would you use to find that?"
"Who"
"correct"
"See that ipaddress there is not yours!! So that person is sending you the message!!!"
"Arghh!! i am going to stop that persons computer now!!". I am about to get up when he stops me a says no need we can do that from here.
"You... can do that ??"
"Yeah sure!!. See that tty we saw? well you cannot open a tty without assosiating with a shell. When you open that terminal the device used to show that window to use is the terminal, but that $ sign you see there is the real program that's running on that terminal. You close that program, then the terminal will have nothing to run on it and it will close.
You can see what all programs are running on you machine by running ps -ef command"
"Do you see that output in the end ? there are these processes "bash" running? Well those are your shell . And do you see that /pts/x. That is not your tty right ? yo can check that using the tty command. So who is running that terminal then ?"
" Well that must be Mr Morphius !!. How do we shot him down?"
"Well we can kill that process. If you notice then in that line there are two numbers in the beginning. Well the first number is the process number. do $kill process_number"
"Done!!!"
"But i wanted to send him some message instead."
"Well we can do the same what he did to us. You have his ip address right ? look at fig"
"yeah!!"
"Well what are you waiting for login!!"
"i logged in"
"Then find what terminal he has open?"
"He has got pts/1 open"
then type in the following command
$echo "Your message" > /dev/pts/1
"Now you can go and sneak up behind him !!! "
"Yeah .. that will be fun"
"Coolll !!!! But how is taht"