Jun 30 01:26:23 <-------- Class started --------> Jun 30 01:26:26 * roni has quit ("Leaving") Jun 30 01:26:30 * roni (n=aritra@117.201.96.252) has joined #dgplug Jun 30 01:26:53 This is the second class on the basics of the Unix shell. Jun 30 01:27:14 For today's class we will assume knowledge of: Jun 30 01:27:28 (i) what the shell is and what it does Jun 30 01:27:51 (ii) ability to use man, apropos, whatis and info to see documentation Jun 30 01:28:06 (iii) cd, pwd, basename and dirname Jun 30 01:28:32 * roni has quit (Client Quit) Jun 30 01:28:37 (iv) meanings of '~', '..', '.', '$HOME', '-' Jun 30 01:28:51 * roni (n=aritra@117.201.96.252) has joined #dgplug Jun 30 01:29:10 Like yesterday everyone is encouraged to ask questions. Use a '!' and wait fro your turn. Jun 30 01:29:41 * mavu (n=satya@59.178.190.54) has joined #dgplug Jun 30 01:29:59 If you find that I am not responding for a long time, say 15 minutes, then that is because of a powercut at my house. Jun 30 01:30:53 Today we will look at basic manipulation of files and directories. Jun 30 01:32:08 cp, ln, ls, mkdir, mv, rm <-- please have a look at the documentation for these Jun 30 01:33:29 ! Jun 30 01:34:17 susenj: Ask. Jun 30 01:34:23 i din't understand 'ln'-to make links between files.which type of link it is? Jun 30 01:34:43 Jun 30 01:34:52 same query Jun 30 01:34:59 A link is something similar to a shortcut in Windows, but exactly the same thing. Jun 30 01:35:12 * Kishan (n=Kishan@218.248.70.235) has left #dgplug ("Leaving") Jun 30 01:35:53 pushkal, susenj: Clear? Jun 30 01:36:03 ! Jun 30 01:36:08 pls provide an example to show.....how to make links Jun 30 01:36:10 pushkal: Ask Jun 30 01:36:12 Jun 30 01:36:28 susenj: Will come to that later. Jun 30 01:36:29 a shortcut in windows is not between two files.. Jun 30 01:36:39 here it says between stwo files Jun 30 01:36:42 Jun 30 01:36:54 * ria has quit ("Leaving") Jun 30 01:36:57 pushkal: What is a shortcut then? Jun 30 01:37:33 ! Jun 30 01:38:15 rishi: k clear Jun 30 01:38:39 deepak: Ask. Jun 30 01:38:43 * amrita has quit (Remote closed the connection) Jun 30 01:39:14 do operating system use soft link and hard link? Jun 30 01:39:40 Jun 30 01:41:39 deepak: Are you asking whether both are supported or not? Jun 30 01:45:21 deepak: What do you mean by "used by operating system" ? Jun 30 01:45:42 If it was not supported by the OS there is no way you could have had hard/soft links. Jun 30 01:46:09 By the way if someone wants to read a bit more: http://kb.iu.edu/data/aibc.html Jun 30 01:46:37 * mavu_ has quit (Read error: 110 (Connection timed out)) Jun 30 01:46:37 means both user and OS use linking concept Jun 30 01:47:33 The user uses it. That is what the ln command provides. Jun 30 01:48:22 I do not know what you mean by "OS use linking concept". If the OS supports it, you can use it. Jun 30 01:48:34 how the OS uses this linking concept? Jun 30 01:50:03 please site some example where OS use soft linking or hard linking? Jun 30 01:50:09 deepak: There is nothing special about how the OS uses it. It uses it like any other user would use it -- to create links. Jun 30 01:50:40 A hard link is just another entry for a file that already existed. Jun 30 01:51:59 * roni has quit (Read error: 110 (Connection timed out)) Jun 30 01:51:59 means you want to say OS uses it in the same way as user Jun 30 01:52:39 deepak: Are you asking how the OS implements links? Jun 30 01:52:50 "implements" is different from "uses" Jun 30 01:53:04 yes Jun 30 01:53:29 deepak: Please use the right words. I can not guess what is on your mind. Jun 30 01:53:54 http://kb.iu.edu/data/abbe.html Jun 30 01:54:02 http://kb.iu.edu/data/aibc.html Jun 30 01:54:38 deepak: Will come to links when we discuss the ln command. Jun 30 01:54:38 For the moment, just go through those links. Jun 30 01:54:38 Ok. Jun 30 01:54:40 So lets move ahead. Jun 30 01:55:04 The cp command is what allows us to copy files and directories. Jun 30 01:55:55 In Unix almost all I/O related things are represented as files. Jun 30 01:56:32 A directory is just a special file, so what applies to files also applies to directories (with some modifications). Jun 30 01:57:19 * coolpyro_rishi has quit (Read error: 110 (Connection timed out)) Jun 30 01:58:30 It will also help to remember that every file has an entry in some filesystem. Jun 30 01:59:19 And each entry is represented by an inode. Jun 30 01:59:38 * TanmayaT (n=chatzill@59.95.194.40) has joined #dgplug Jun 30 02:00:04 * TanmayaT has quit (Client Quit) Jun 30 02:00:25 We don't need too many details about inodes today. Just remember that each inode has an index number corresponding to it. Jun 30 02:00:41 For further reading on inodes: http://en.wikipedia.org/wiki/Inode Jun 30 02:01:00 So if you do: Jun 30 02:01:09 $ cp foo /tmp Jun 30 02:01:51 ..it will copy an existing file named foo, present in your current working directory, to a directory named /tmp. Jun 30 02:02:51 In case there was no directory named tmp under /, cp will try to create a file named tmp which will be a copy of foo, Jun 30 02:03:09 Another alternative is: Jun 30 02:03:16 $ cp foo /tmp/bar Jun 30 02:03:50 Sorry, not really an alternative, rather just another example. Jun 30 02:04:37 * ecntrk1 (i=sunny@117.194.0.143) has joined #dgplug Jun 30 02:05:05 If what you are trying to copy is a directory and not a regular file, then you need to use the '-R' or '-r' option. Jun 30 02:05:38 $ cp -r /usr /tmp Jun 30 02:05:46 ... is the same as ... Jun 30 02:05:46 * t4num0y_cs3 has quit ("Bye Bye..") Jun 30 02:05:54 $ cp -R /usr /tmp Jun 30 02:06:00 ... which is the same as ... Jun 30 02:06:20 $ cp --recursive /usr /tmp Jun 30 02:06:53 ! Jun 30 02:07:00 susenj: Ask. Jun 30 02:07:11 why this --? Jun 30 02:07:18 before recursive? Jun 30 02:07:21 Jun 30 02:07:55 susenj: If the option is a single character usually a '-' is used, otherwise '--'. Jun 30 02:08:00 * susenj has quit (Excess Flood) Jun 30 02:08:27 * susenj (n=root@59.178.169.121) has joined #dgplug Jun 30 02:08:38 Otherwise the command will not be able to differentiate between a single character option and a longer option. Jun 30 02:08:55 okay....thanks Jun 30 02:09:13 A few other options that might interest you areL Jun 30 02:09:21 * debayan (n=debayan@117.198.32.30) has joined #dgplug Jun 30 02:09:46 ! Jun 30 02:10:17 -i, -p, -l, -s Jun 30 02:10:38 Please read the documentation for these options. Jun 30 02:10:43 deepak: Ask. Jun 30 02:11:12 if both option do the same job then why both we require? Jun 30 02:12:10 deepak: Sometimes for compatibility, sometimes for clarity and sometimes for brevity. Jun 30 02:12:15 ! Jun 30 02:12:50 --recursive is clearer than -r/-R, but -r/-R are easier to type. Jun 30 02:13:08 So its upto the user to use whatever she wants. Jun 30 02:13:10 Soumya: Ask. Jun 30 02:13:17 cp -l and cp -s er madhye exactly ki difference ? Jun 30 02:13:30 clarity is good but how compatibility and brevity Jun 30 02:14:28 Soumya: cp -l will create a hard link, while cp -s will create a symbolic or soft link. Jun 30 02:14:32 * Prakhar has quit (Read error: 60 (Operation timed out)) Jun 30 02:14:39 $ cp -l foo bar Jun 30 02:14:46 ... is same as Jun 30 02:14:53 $ ln foo bar Jun 30 02:14:58 Similarly: Jun 30 02:15:03 $ cp -s foo bar Jun 30 02:15:08 ...is same as Jun 30 02:15:13 $ ln -s foo bar Jun 30 02:15:32 * kushal gives channel operator status to rishi Jun 30 02:16:19 got you, thanks rishi Jun 30 02:17:01 ! Jun 30 02:17:03 deepak: Different flavours of Unix might offer differ short and long options for the same thing. Jun 30 02:17:44 So for compatibility you might have more than one option for the same purpose. Jun 30 02:18:16 Any more queries? Jun 30 02:18:24 brevity means what? Jun 30 02:18:52 deepak, can we please proceed with shell. rather than ENGLISH Jun 30 02:18:56 deepak: please use google, define:brevity on google Jun 30 02:19:10 ok Jun 30 02:19:15 can we discuss englis classes in different channel Jun 30 02:19:24 rishi, please proceed Jun 30 02:20:00 While we are dealing with file manipulation, it might be useful to know about 'touch'. Jun 30 02:20:04 $ touch foo Jun 30 02:20:20 ...will create an empty file named foo in the current directory. Jun 30 02:20:25 Similarly: Jun 30 02:20:30 $ touch ~/foo Jun 30 02:22:08 You can also use touch on an existing file. Jun 30 02:23:14 In that case 'touch' will update the 'times' of the file to the current time. Jun 30 02:24:12 ! Jun 30 02:24:13 Every file has some timestamps associated with it. eg., access time or atime, modification time or mtime Jun 30 02:24:13 atime is when the file was last read/written Jun 30 02:24:20 mtime is when it was last modified Jun 30 02:25:05 When we come to the ls command we will see how one can see the timestamps of a particular file. Jun 30 02:25:53 If you do: Jun 30 02:26:01 $ touch -r foo bar Jun 30 02:26:27 ... then the timestamps of the pre-existing file foo will be copied to that of bar. Jun 30 02:26:31 susenj: Ask. Jun 30 02:26:44 no query.....it was resolved! Jun 30 02:26:57 Anything else? Jun 30 02:27:20 !! Jun 30 02:27:25 pushkal: Ask. Jun 30 02:27:51 the touch command created a file foo on my distro.. but when i deited it with vim, it couldnt save it Jun 30 02:28:07 edited* Jun 30 02:28:29 * Prakhar (n=prakhar@122.163.69.172) has joined #dgplug Jun 30 02:28:41 pushkal: Why? What was the message given? Jun 30 02:28:51 this file is read only Jun 30 02:29:22 Jun 30 02:30:49 rishi:carry on Jun 30 02:30:55 pushkal: Can I see what you did? Jun 30 02:31:02 Paste it on some pastebin. Jun 30 02:31:19 ok rishi Jun 30 02:31:35 Now lets move to 'ls'. Jun 30 02:31:53 ls is what is used to list files in a directory, Jun 30 02:32:10 * debayan has quit (Read error: 110 (Connection timed out)) Jun 30 02:32:12 By default it will list the entries in the current directory: Jun 30 02:32:13 $ ls Jun 30 02:32:19 You can also do: Jun 30 02:32:25 $ ls Jun 30 02:32:47 ...where can be an absolute/relative path to a directory or file. Jun 30 02:33:16 $ ls -R Jun 30 02:33:39 ... will recursively list the entries of all sub-directories in the path Jun 30 02:34:53 * debayan (n=debayan@117.198.32.27) has joined #dgplug Jun 30 02:35:46 You can use the -s option to see the size of the files Jun 30 02:36:10 rishi, alapathy hai kya? Jun 30 02:36:27 debayan, no , he is the trainer Jun 30 02:36:33 rishi, o sorry Jun 30 02:36:37 :) Jun 30 02:36:44 ... however the size will be in terms of 1KB blocks. So usually one would use the -h option alongwith -s. Jun 30 02:37:01 Any queries? Jun 30 02:37:32 Another common option for ls is -l: Jun 30 02:37:39 $ ls -l Jun 30 02:38:33 In the output of ls -l, the leftmost columns are the permissions associated with the file. Jun 30 02:38:43 It is something like: Jun 30 02:39:11 drwxr-xr-x or -rw-r--r-- Jun 30 02:39:44 d --> directory Jun 30 02:39:47 r --> read Jun 30 02:39:52 w --> write Jun 30 02:39:56 x --> execute Jun 30 02:40:57 The 2nd, 3rd and 4th characters are for the owner of the file, the next three are for all users that belong to the same group as the owner, while the last three characters for other users. Jun 30 02:42:09 d, r, w are obvious. 'x' is necessary to execute a file (eg., programs) or to cd inside it (eg., directories). Jun 30 02:42:29 If /usr/bin did not have 'x', then: Jun 30 02:42:35 $ cd /usr/bin Jun 30 02:42:39 ...would not work. Jun 30 02:43:14 The second field is the user, while the thrid field is the group. Jun 30 02:43:21 rishi, ! Jun 30 02:43:27 kushal: Ask. Jun 30 02:44:03 rishi, if I only need to read/write/execute a file inside a directory , what permissions I should need on that directory Jun 30 02:44:06 as user Jun 30 02:44:15 user == owner Jun 30 02:44:51 rishi, Yahoo! interview people asked me this question Jun 30 02:45:16 rishi, and i got totally confused Jun 30 02:45:28 me too :P Jun 30 02:45:44 kushal, Soumya: Ok. Jun 30 02:45:59 As owner you will need: Jun 30 02:46:12 * ecntrk1 has quit (Read error: 110 (Connection timed out)) Jun 30 02:46:41 d--x------ Jun 30 02:48:46 ok Jun 30 02:48:54 ! Jun 30 02:49:02 i thought of similarly but 'r' will not be neede ? Jun 30 02:49:11 r/neede/needed Jun 30 02:49:14 Soumya: I am trying that. :-) Jun 30 02:49:16 not drwx------ Jun 30 02:49:22 kushal: Hang on. Jun 30 02:49:40 d-x------ should work,i think Jun 30 02:49:52 guys please let rishi talk Jun 30 02:51:33 kushal: It looks like you will need drwx------ Jun 30 02:51:50 * susenj has quit () Jun 30 02:52:23 kushal: Lets solve this tommorrow. Jun 30 02:52:36 ! Jun 30 02:52:38 Its 03:00hrs now. Jun 30 02:52:43 pushkal: Ask. Jun 30 02:52:50 what was the logic behind d--x------ ? Jun 30 02:52:58 yes rishi you need like it only Jun 30 02:53:01 i tried Jun 30 02:53:13 and not drwx------ Jun 30 02:53:45 pushkal: Without x you can not enter/traverse the directory, so that is a must. Jun 30 02:54:18 rishi, ok Jun 30 02:55:03 just a last ! Jun 30 02:56:00 kushal: d--x------ will work as long as you have an existing file that is readable and writable Jun 30 02:56:09 rishi, ok Jun 30 02:56:13 you can not create a new file. Jun 30 02:56:27 * chacha_chaudhry has quit ("Ex-Chat") Jun 30 02:56:53 rishi: but question said read/write/execute , for reading writing r,w must also be there, right ? Jun 30 02:57:28 pushkal, means , read or write or execute Jun 30 02:57:36 pushkal: Question did not say whether its an existing file or not. Jun 30 02:57:42 * sharanr has quit (Read error: 110 (Connection timed out)) Jun 30 02:58:02 rishi, you can call it off for tonight Jun 30 02:58:05 ok got it Jun 30 02:58:40 kushal: Did they ask for existing file? Jun 30 02:58:44 yes Jun 30 02:59:03 Then d--x------ is enough. Jun 30 02:59:18 yup, it seems logical Jun 30 02:59:37 for an existing file this should do Jun 30 02:59:54 Ok. Folks. Jun 30 03:00:01 Anymore queries? Jun 30 03:00:09 nopes Jun 30 03:00:10 :) Jun 30 03:00:29 not today atleast Jun 30 03:00:31 :) Jun 30 03:00:32 :P Jun 30 03:00:36 :) Jun 30 03:01:04 Then lets stop at 'cp', 'touch' and 'ls' for today. Jun 30 03:01:13 done rishi Jun 30 03:01:28 Will continue with 'ln', 'mv' ,etc. in the next class. Jun 30 03:01:30 thanks for all the knowledge sharing session Jun 30 03:01:36 :-) Jun 30 03:01:36 oks done Jun 30 03:01:37 rishi:we will carry on next day Jun 30 03:01:51 <-------- Class Ended -------->