Jul 02 23:08:45 <--------CLASS STARTS-----------> Jul 02 23:08:55 Can we have a roll call to start with? Jul 02 23:09:01 ya Jul 02 23:09:04 deepak kumar Jul 02 23:09:10 ria das Jul 02 23:09:10 amrita mukherjee Jul 02 23:09:15 Debmalya Sinha Jul 02 23:09:16 debashree banerjee Jul 02 23:09:18 sunnysharma Jul 02 23:09:19 ria, note down the roll call and pass it to kushal Jul 02 23:09:20 arpita kapoor Jul 02 23:09:21 pramit roychowdhury Jul 02 23:09:22 rangeen basu roy chowdhury Jul 02 23:09:36 aritra bose Jul 02 23:09:43 techno_freak, better you do that Jul 02 23:09:43 techno_freak, we dont talk Jul 02 23:09:45 :) Jul 02 23:09:50 Aanjhan Ranganathan Jul 02 23:09:53 ria, ok, he is anways logging all this Jul 02 23:10:00 Parthan Jul 02 23:10:05 Arindam Ghosh Jul 02 23:10:06 techno_freak, ria: I have turned on logging. Jul 02 23:10:17 ok.... Jul 02 23:10:20 Anybody else? Jul 02 23:10:22 rishi: good job mate Jul 02 23:10:28 kishan goyal Jul 02 23:10:29 -------- BELL RINGS --------------- Jul 02 23:10:46 So here we go. This is our third class on basic shell. Jul 02 23:11:09 * Pramit_ (n=chatzill@125.20.11.34) has joined #dgplug Jul 02 23:11:22 Like in the last class, we will assume that you know how to use man, apropos, whatis and info to browse documentation on your system. Jul 02 23:11:42 Those who don't have a Unix system at hand can use the Internet to get the documentation. Jul 02 23:11:54 * ria has quit (Read error: 54 (Connection reset by peer)) Jul 02 23:12:07 We have already covered: cd, pwd, basename, dirname, cp, ls and touch. Jul 02 23:12:15 ! Jul 02 23:12:23 * ria (n=ria@219.64.76.23) has joined #dgplug Jul 02 23:12:40 So I will assume that you already know them, or have atleast consulted the documentation before asking about them again. Jul 02 23:12:43 sunny_slls: Ask. Jul 02 23:12:56 rishi, what is the url for documentation Jul 02 23:13:25 sunny_slls: Use Google, Yahoo! or any search engine to find out. Jul 02 23:13:31 * susenj_ (n=chatzill@59.178.164.224) has joined #dgplug Jul 02 23:14:15 So today we will start with: mv, ln, mkdir and rm. Jul 02 23:14:26 If time permits we will take up some more commands. Jul 02 23:15:13 So just have a look at the documentation for mv, ln, mkdir and rm before we take them up one by one. Jul 02 23:15:18 * rishi waits Jul 02 23:16:03 ! Jul 02 23:17:01 rishi, i am unable to understand what documentation you are talking about....... Jul 02 23:17:20 sunny_slls: Did you attend the any of the previous two classes? Jul 02 23:17:29 rishi, sorry no Jul 02 23:17:31 * chiks (n=chatzill@125.20.11.34) has joined #dgplug Jul 02 23:17:49 sunny_slls: Given any command (eg., mv) you can do: Jul 02 23:17:52 $ man mv Jul 02 23:17:55 $ whatis mv Jul 02 23:18:00 $ info mv Jul 02 23:18:17 ...to access the documentation for the command that is already installed on your system. Jul 02 23:19:09 rishi, man means that it will tell you about the respective command Jul 02 23:19:42 sunny_slls: Do you have a Unix system right now? Jul 02 23:20:13 rishi, yes but i can't access internet on it Jul 02 23:20:33 sunny_slls, please attend this class, look at old logs and learn from them Jul 02 23:20:34 All those who have a Unix system during the course of the class, please try out the command before asking any question. That way we will save a lot of time. Jul 02 23:20:42 rishi, you may continue with never commands Jul 02 23:20:51 * rishi nods Jul 02 23:21:18 'mv' as you may have guesses is for moving files around. Jul 02 23:21:30 This is similar to cp, which stood for copy. Jul 02 23:21:59 If cp did copy/paste, mv does cut/paste. Jul 02 23:22:22 So to move ~/foo to the /tmp directory, you will do: Jul 02 23:22:29 $ mv ~/foo /tmp Jul 02 23:22:54 ...and then you will have /tmp/foo instead of ~/foo. Jul 02 23:23:22 Since directories are merely special files, the same applies for directories as well: Jul 02 23:23:30 $ mv ~/dir1 /tmp Jul 02 23:23:49 ...will move the directory ~/dir1 to /tmp and give you /tmp/dir1. Jul 02 23:23:56 ~/dir1 will no longer be there. Jul 02 23:23:58 Any questions? Jul 02 23:24:43 * chiks has quit (Read error: 104 (Connection reset by peer)) Jul 02 23:25:04 * rishi is waiting Jul 02 23:25:34 ! Jul 02 23:25:44 * khushi (n=khushbu@59.180.132.90) has joined #dgplug Jul 02 23:25:46 deepak: Ask. Jul 02 23:26:49 rishi:if the directory you are moving contains some subdirectories then also it can be moved Jul 02 23:27:16 deepak: Yes, the directory and everything within it will move. Jul 02 23:27:49 ! Jul 02 23:27:56 Kishan: Ask. Jul 02 23:28:03 * rangeen_ (i=sherry@220.226.24.34) has joined #dgplug Jul 02 23:28:05 ! Jul 02 23:28:10 ecntrk: Wait. Jul 02 23:28:12 can we move more than one directories at once? Jul 02 23:28:20 * rangeen has quit (Nick collision from services.) Jul 02 23:28:38 * rangeen_ is now known as rangeen Jul 02 23:28:44 Kishan: Yes. Jul 02 23:28:54 $ mv ~/dir1 ~/dir2 /tmp Jul 02 23:29:03 ... will move _both_ dir1 and dir2. Jul 02 23:29:14 ok thanks... Jul 02 23:29:18 ecntrk: Ask. Jul 02 23:29:22 Suppose a directory has 100 files and we want95 of them moved... How this can be done without redundantly specifying all the filenames? Jul 02 23:29:22 ! Jul 02 23:29:36 Jul 02 23:30:00 * Pramit has quit (Read error: 110 (Connection timed out)) Jul 02 23:30:00 (move 100 files and delete the unwanted 5?) Jul 02 23:30:06 * chiks (n=chatzill@125.20.11.34) has joined #dgplug Jul 02 23:30:07 Like in GUI mode.. we select all then deselect 5... Jul 02 23:30:20 ecntrk: That is what techno_freak said. Jul 02 23:30:41 mv the entire thing, and then restore those five which were not needed to be moved. Jul 02 23:30:43 techno_freak: no we want those five remaining in the parent dir Jul 02 23:30:47 Jul 02 23:30:51 mv the entire thing, and then restore those five which were not needed to be moved. Jul 02 23:30:58 bose_aritra: Wait. Jul 02 23:31:05 (s/delete/move back/) Jul 02 23:31:31 $ mv * /destination Jul 02 23:31:34 if the file number is biger.. like 20.. then we have to again redundantly specify those names.. ecntrk: If the filenames have a particular format then you can use regular expressions or wildcards. Jul 02 23:32:21 I see..thnx.. Jul 02 23:32:25 Say you have 500 .html files and 20 .txt files. Jul 02 23:32:31 *thanks.. Jul 02 23:32:40 ecntrk: Problem solved? Jul 02 23:32:51 yes... Thanks... Jul 02 23:32:52 bose_aritra: Ask. Jul 02 23:32:55 if i want to move dir1 to more than one place, can it be done? Jul 02 23:32:58 if so, how? Jul 02 23:33:20 * susenj__ (n=chatzill@59.178.187.187) has joined #dgplug Jul 02 23:33:32 bose_aritra: Nope. Jul 02 23:33:49 bose_aritra: If you look closely at the man page you will notice: Jul 02 23:34:01 "...or move SOURCE(s) to DIRECTORY.". Jul 02 23:34:35 bose_aritra: Consider we are moving multiple sources: Jul 02 23:34:52 $ mv ~/src1 ~/src2 /tmp Jul 02 23:35:02 * indradg_ (n=indradg@59.93.211.190) has joined #dgplug Jul 02 23:35:18 ...and in the imaginary case of moving to multiple destinations: Jul 02 23:35:30 $ mv ~/src /dest1 /dest2 Jul 02 23:35:54 It becomes complicated to parse which one is destination and which one is source (not that it can not be done). Jul 02 23:35:55 ok Jul 02 23:36:43 ! Jul 02 23:36:46 bose_aritra: Satisfied? Or is there some lingering doubt? Jul 02 23:37:06 no its done Jul 02 23:37:10 Lets make the question from sunny_slls the last question on mv for the moment. Jul 02 23:37:13 sunny_slls: Ask. Jul 02 23:37:22 what is biger file? Jul 02 23:37:37 * Pramit_ has quit ("ChatZilla 0.9.83 [Firefox 3.0/2008052906]") Jul 02 23:37:53 sunny_slls: A file which is bigger in size than some other file. Jul 02 23:38:50 rishi, means a biger file is specified separately to move.........why? Jul 02 23:39:07 * Atanu_bera has quit ("ChatZilla 0.9.83 [Firefox 3.0/2008052906]") Jul 02 23:39:24 sunny_slls: Where did you read that? Jul 02 23:39:51 rishi, ecntrk asked you Jul 02 23:40:04 rishi, previously Jul 02 23:40:33 sunny_slls: He mentioned a bigger number of files, which is different from bigger file. Jul 02 23:40:44 Ok. Lets move on. Jul 02 23:40:56 Some of the useful options that can be used with mv are: -b, -f, -i and -u. Jul 02 23:40:57 rishi, thanks Jul 02 23:41:34 The first three deal with how to handle a scenario where a similarly named file exists in the destination directory. Jul 02 23:41:48 * techno_freak has quit ("time to sleep") Jul 02 23:42:01 So say you have ~/foo and /tmp/foo and you have done: Jul 02 23:42:10 $ mv ~/foo /tmp Jul 02 23:42:51 If you used -b, then mv will save the older /tmp/foo as /tmp/foo~ before overwiriting with the one that came from ~/foo. Jul 02 23:43:05 So you will end up with /tmp/foo and /tmp/foo~ Jul 02 23:43:41 If you had used -i, then it will ask you before overwriting. It will be a simple yes or no and no backups will be used. Jul 02 23:44:24 And -f is almost opposite to -i, since it will silently overwrite and never prompt. Jul 02 23:44:59 The -u or update option is a bit more intelligent. Jul 02 23:45:17 * tux_440volt has quit ("Leaving") Jul 02 23:45:22 * pushkal (n=chatzill@117.197.16.25) has joined #dgplug Jul 02 23:45:43 * susenj_ has quit (Read error: 110 (Connection timed out)) Jul 02 23:46:02 It is similar to -f, but it will only overwrite an existing file, if the source file is newer (modification time) is newer than the existing destination entry. Jul 02 23:46:05 Any questions? Jul 02 23:46:42 ! Jul 02 23:46:55 ria: Ask. Jul 02 23:46:56 ! Jul 02 23:47:02 what will happen if we write no in the -i option? Jul 02 23:47:15 and if yes then? Jul 02 23:47:19 Jul 02 23:47:47 'no' will not overwrite, 'yes' will overwrite. Jul 02 23:48:06 what will happen if we write no? Jul 02 23:48:13 will there be no action? Jul 02 23:48:40 * chacha_chaudhry has quit (Read error: 104 (Connection reset by peer)) Jul 02 23:49:01 Anymore queries? Jul 02 23:49:51 i asked what if no? Jul 02 23:49:56 rishi, explain once more the difference between -f and -u Jul 02 23:49:58 rishi, ^^^ Jul 02 23:50:04 sunny_slls: Wait a moment. Jul 02 23:50:23 rishi, will the file be not moved then? Jul 02 23:50:24 * Debashree has quit (Read error: 104 (Connection reset by peer)) Jul 02 23:50:29 ria: If you say 'no' it will not overwrite the destination file and the source file will be skipped and not moved. Jul 02 23:50:39 ria: No it will not be moved. Jul 02 23:50:44 rishi, ok Jul 02 23:50:47 Jul 02 23:50:51 sunny_slls: Ok. Jul 02 23:51:03 Imagine the source is older than the destination. Jul 02 23:51:20 So -f will blindly overwrite the newer destination with the older source. Jul 02 23:51:33 sunny_slls: -u will not do that and retain the newer destination. Jul 02 23:51:48 Only if the source was newer it would have overwritten it. Jul 02 23:51:50 sunny_slls: Clear? Jul 02 23:51:53 * Debashree (n=Debashre@61.2.165.216) has joined #dgplug Jul 02 23:52:09 rishi, yes Jul 02 23:52:20 Ok. Can we go ahead? Jul 02 23:52:28 * rishi hopes people are awake Jul 02 23:52:33 yes Jul 02 23:52:41 yes Jul 02 23:52:44 rishi,yes Jul 02 23:52:50 Nice. :-) Jul 02 23:52:55 So what was our next command? Jul 02 23:53:05 yes :) Jul 02 23:53:08 Can we take mkdir? Jul 02 23:53:35 ok,but ln is next Jul 02 23:53:43 yes Jul 02 23:54:20 susenj__: Lets take up mkdir, and we will come back to ln after it. Jul 02 23:54:56 rishi:ok Jul 02 23:55:05 susenj__: mkdir is smaller and simpler. Jul 02 23:55:21 As the name suggests, mkdir makes directories. Jul 02 23:55:21 * rangeen has quit (Read error: 113 (No route to host)) Jul 02 23:55:43 $ mkdir ~/foo Jul 02 23:55:49 * amrita_ (n=amrita@117.201.97.3) has joined #dgplug Jul 02 23:56:04 ... will create directory (not a regular file) in your home directory. Jul 02 23:56:24 I hope you remember '~' and '$HOME' denotes the home directory. Jul 02 23:56:28 * amrita has quit (Nick collision from services.) Jul 02 23:56:35 * amrita_ is now known as amrita Jul 02 23:57:02 * rangeen (i=sherry@220.226.72.62) has joined #dgplug Jul 02 23:58:01 Now the interesting options are: - or --mode and -p or --parents. Jul 02 23:58:03 * amrita_ (n=amrita@117.201.97.3) has joined #dgplug Jul 02 23:58:19 * amrita_ has quit (Client Quit) Jul 02 23:58:38 * susenj__ is now known as susenj Jul 02 23:58:41 -m or --mode is used to set the permissions of the new directory that will be created. Jul 02 23:58:45 So instead of doing: Jul 02 23:58:52 $ mkdir ~/foo Jul 02 23:59:01 $ chmod 700 ~/foo Jul 02 23:59:05 ... you can do: Jul 02 23:59:15 $ mkdir -m 700 ~/foo Jul 02 23:59:48 * Soumya (n=Soumya@59.164.98.244) has joined #dgplug Jul 03 00:00:31 To understand -p or --parents assume you want to create: ~/newdir/newdir1. Jul 03 00:00:48 ... where both newdir and newdir1 does not exist. Jul 03 00:00:57 So if one tries to do: Jul 03 00:01:05 $ mkdir ~/newdir/newdir1 Jul 03 00:01:36 ... mkdir will throw an error and not create any directory. Jul 03 00:01:43 So you can either do: Jul 03 00:01:48 $ mkdir ~/newdir Jul 03 00:01:51 $ mkdir ~/newdir/newdir1 Jul 03 00:01:56 ... or you can do: Jul 03 00:02:04 $ mkdir -p ~/newdir/newdir1 Jul 03 00:03:57 * stephaniewhiting has quit ("ChatZilla 0.9.82.1 [Firefox 2.0.0.14/2008040413]") Jul 03 00:04:12 * stephaniewhiting (n=chatzill@65.89.170.203) has joined #dgplug Jul 03 00:05:07 ! Jul 03 00:06:34 * makghosh has quit (Read error: 110 (Connection timed out)) Jul 03 00:07:55 * susenj (n=chatzill@59.178.187.187) has left #dgplug Jul 03 00:08:04 ! Jul 03 00:08:35 * susenj (n=chatzill@59.178.187.187) has joined #dgplug Jul 03 00:10:16 rishi, are you there? Jul 03 00:10:38 i think he is offline Jul 03 00:10:41 * khushi__ (n=khushbu@59.180.138.160) has joined #dgplug Jul 03 00:10:46 yah.. me too. Jul 03 00:10:49 rishi, hey are you there Jul 03 00:11:28 wait for him to come Jul 03 00:11:34 Any problems regarding mkdir? Jul 03 00:11:45 sunny_slls: Ask. Jul 03 00:11:51 sunny_slls: Ask. Jul 03 00:11:56 sunny_slls: Ask. Jul 03 00:12:02 ria: Yes. Waiting for sunny_slls to actually ask something. Jul 03 00:12:05 sunny_slls: No, I am in paradise. :-) Jul 03 00:12:12 rishi, ok Jul 03 00:12:19 :) Jul 03 00:12:29 ria: Wait for whom to come. Jul 03 00:12:35 * amrita_ (n=amrita@117.201.96.109) has joined #dgplug Jul 03 00:12:37 why error is created Jul 03 00:12:50 rishi, actually for you :) Jul 03 00:12:53 * amrita has quit (Nick collision from services.) Jul 03 00:12:59 * amrita_ is now known as amrita Jul 03 00:13:50 rishi, why there is an error while creating two directories Jul 03 00:13:59 * khushi__ has quit (Client Quit) Jul 03 00:14:02 * khushi__ (n=khushbu@59.180.138.160) has joined #dgplug Jul 03 00:14:18 sunny_slls: Can I see your command? Jul 03 00:15:26 $ mkdir ~/newdir/newdir1 Jul 03 00:15:50 rishi, why it will throw error Jul 03 00:16:26 because they are not existing,right rishi? Jul 03 00:17:12 so why Jul 03 00:17:13 susenj: Because ~/newdir is missing, so its a bit strange to create a child directory inside it. Jul 03 00:17:23 sunny_slls: That is why -p is there. Jul 03 00:17:44 yes,the same i wanted to tell.... Jul 03 00:18:49 * amrita_ (n=amrita@117.201.96.109) has joined #dgplug Jul 03 00:19:08 * amrita_ has quit (Client Quit) Jul 03 00:19:44 * rsa_md5 has quit ("Leaving") Jul 03 00:19:52 * rangeen has quit ("Ah La La and Tata") Jul 03 00:19:56 susenj: Are you asking _why_ -p was necessary as a separate option? Jul 03 00:19:59 rishi, ~/newdir and then ~/newdir/newdir1-----does this mean that we are creating a new directory and then directory1 Jul 03 00:20:15 * Debashree has quit (Read error: 104 (Connection reset by peer)) Jul 03 00:20:21 no no i understood Jul 03 00:20:59 sunny_slls: Yes. Jul 03 00:21:15 rishi, thanks Jul 03 00:21:18 ! Jul 03 00:21:27 * indradg_ is now known as indradg Jul 03 00:21:28 what is the job of -p?? Jul 03 00:21:31 * Debashree (n=Debashre@61.2.165.19) has joined #dgplug Jul 03 00:21:39 ! Jul 03 00:21:50 arpita: Ask. Jul 03 00:21:54 deepak: Wait a minute. Jul 03 00:22:05 job of -p? Jul 03 00:22:23 arpita: Did you get disconnected? I just explained it. Jul 03 00:23:17 arpita: Ping? Jul 03 00:23:39 yes please repeat if possible Jul 03 00:24:22 See the scrollback and ask. Till then I will take deepak's question. Jul 03 00:24:24 deepak: Ask. Jul 03 00:24:39 rishi:which one will be created first newdir or newdir1 in /newdir/newdir1? Jul 03 00:25:02 deepak: Obviously newdir, because if the parent does not exist how can you have the child? Jul 03 00:25:16 dir will be created first , isn't rishi? Jul 03 00:25:26 ok Jul 03 00:25:32 sunny_slls: Don't speak out of turn. Jul 03 00:25:33 * chacha_chaudhry (n=dev@gnu-india/supporter/rakeshpandit) has joined #dgplug Jul 03 00:25:47 For those, like arpita, who missed the -p option: Jul 03 00:25:49 To understand -p or --parents assume you want to create: ~/newdir/newdir1. Jul 03 00:25:49 ... where both newdir and newdir1 does not exist. Jul 03 00:25:49 So if one tries to do: Jul 03 00:25:49 $ mkdir ~/newdir/newdir1 Jul 03 00:25:49 ... mkdir will throw an error and not create any directory. Jul 03 00:25:50 rishi, sorry Jul 03 00:25:51 So you can either do: Jul 03 00:25:55 $ mkdir ~/newdir Jul 03 00:25:57 $ mkdir ~/newdir/newdir1 Jul 03 00:25:59 ... or you can do: Jul 03 00:26:01 $ mkdir -p ~/newdir/newdir1 Jul 03 00:26:15 deepak: Clear? Jul 03 00:26:29 can we move ahead? Jul 03 00:26:30 rishi:yes Jul 03 00:26:38 ! Jul 03 00:27:11 if we give names of directories that already exist in this command will it show erroe? Jul 03 00:27:14 error? Jul 03 00:28:06 arpita: Give an example command / case. Jul 03 00:28:25 * khushi has quit (Read error: 110 (Connection timed out)) Jul 03 00:28:42 * khushi__ is now known as khushi Jul 03 00:29:57 i mean if mkdir/newdir/newdir1 in this case newdir and newdir1 already exist it will show error?/ Jul 03 00:30:02 * amrita_ (n=amrita@117.201.96.109) has joined #dgplug Jul 03 00:30:10 * amrita_ has quit (Client Quit) Jul 03 00:30:31 arpita: Without -p you will get an error, with -p you won't. Jul 03 00:30:43 arpita: Do you have access to Unix right now? Jul 03 00:30:50 * chiks has quit ("ChatZilla 0.9.83 [Firefox 2.0.0.14/2008040413]") Jul 03 00:30:50 yes Jul 03 00:31:27 arpita: So why don't you try out the commands before asking? :-) Jul 03 00:31:35 * rishi wants to move on to ln Jul 03 00:33:01 got it Jul 03 00:33:04 thanks Jul 03 00:33:35 So everyone fire up the documentation of ln. Jul 03 00:33:44 ok Jul 03 00:34:23 rishi, please make me clear about the hard link and the soft link Jul 03 00:34:31 i am very confused with it Jul 03 00:34:35 Jul 03 00:35:30 ria: We will come to that. Jul 03 00:35:49 ok Jul 03 00:35:56 So ln is used to create links. Jul 03 00:36:06 Links are of two types: hard and symbolic (or soft). Jul 03 00:36:46 A hard link for a file is basically a synonym or duplicate tag for a file. Jul 03 00:37:35 If you read about inodes in a Unix filesystem, you will see that each file (or directory) in a filesystem has an entry. Jul 03 00:38:05 Each entry is an inode, and its index is an integer. Jul 03 00:38:08 * chiks (n=chatzill@125.20.11.34) has joined #dgplug Jul 03 00:38:17 So if we create a hard link: Jul 03 00:38:26 $ ln foo bar Jul 03 00:38:43 * makghosh (n=Joy@117.99.58.9) has joined #dgplug Jul 03 00:39:01 ... where foo was an existing file (or directory) and bar is the new hard link that was created, foo and bar will have the same inode number. Jul 03 00:39:18 You can see the inode numbers of foo and bar as: Jul 03 00:39:22 $ ls -i foo bar Jul 03 00:40:01 You can also use the 'cp' command to create links. Jul 03 00:40:11 $ cp -l foo bar Jul 03 00:40:16 ... will do the same thing as: Jul 03 00:40:20 $ ln foo bar Jul 03 00:40:56 However there is a difference. Jul 03 00:41:35 The ln command will throw an error if the destination hard link already exists, but 'cp -l ...' will silently ignore it. Jul 03 00:42:12 Other than hard links, there are symbolic or soft links. Jul 03 00:42:40 Soft links are separate files, and unline hard links do not share the same inode. Jul 03 00:42:46 So if you do: Jul 03 00:42:51 $ ln -s foo baz Jul 03 00:43:12 ... you will end up with a symbolic link baz which points to foo. Jul 03 00:43:24 You could have done the same with: Jul 03 00:43:32 ! Jul 03 00:43:33 $ cp -s foo baz Jul 03 00:43:41 If you do: Jul 03 00:43:47 $ ls -i foo bar baz Jul 03 00:44:09 ... you will find foo/bar have the same inode index, while baz is different. Jul 03 00:44:14 sunny_slls: Ask. Jul 03 00:44:38 * Soumya_ (n=Soumya@59.164.98.244) has joined #dgplug Jul 03 00:44:44 ! Jul 03 00:45:31 what's inode Jul 03 00:47:50 * Debashree has quit (Read error: 104 (Connection reset by peer)) Jul 03 00:47:52 * amrita_ (n=amrita@117.201.96.109) has joined #dgplug Jul 03 00:47:58 * amrita_ has quit (Client Quit) Jul 03 00:48:39 sunny_slls: http://en.wikipedia.org/wiki/Inode Jul 03 00:48:55 One more: http://www.cyberciti.biz/tips/understanding-unixlinux-filesystem-inodes.html Jul 03 00:49:16 Simply put, an inode is the entry of a file in a filesystem. Jul 03 00:52:20 ria: Ask. Jul 03 00:52:22 * Debashree (n=Debashre@61.0.133.55) has joined #dgplug Jul 03 00:52:35 rishi, other than the inode what is the difference between hard and soft link? Jul 03 00:53:06 rishi, and what will happen when we delete any of the files in both cases? Jul 03 00:53:16 rishi, why do we need both? Jul 03 00:54:28 ria: If you use hard links, the file will not be deleted until all the synonyms are removed. Jul 03 00:54:56 Because the synonyms are basically one file only. Jul 03 00:54:58 ! Jul 03 00:55:24 rishi, deleting which file? Jul 03 00:55:35 rishi, first one or the 2nd one? Jul 03 00:55:55 ria: 1st and 2nd are same for hard links. Only the names are different. Jul 03 00:56:03 Same inode == same file. Jul 03 00:56:20 Its just like different names for the same person. Jul 03 00:57:08 two pointers for same variable Jul 03 00:57:16 rishi, ok Jul 03 00:57:33 rishi, so deleting anyone will act in the same way right? Jul 03 00:57:42 Yes. Jul 03 00:57:45 rishi, and what about soft links? Jul 03 00:57:55 But if you remove the target to which a soft link was pointing to, the original file will get deleted independent of the soft link. Jul 03 00:58:06 so to remove such a file remove command will have to be used with any 1 of the synonyms or both? Jul 03 00:58:07 So you end up with a broken soft link. Jul 03 00:58:28 arpita: Are you talking about hard or soft links? Jul 03 00:58:34 If one does: Jul 03 00:58:35 hard link Jul 03 00:58:37 $ ln foo bar Jul 03 00:58:45 ... then until you do: Jul 03 00:58:51 $ rm foo bar Jul 03 00:58:53 rishi, so we will have the 2nd file in soft link? Jul 03 00:59:03 ... the file will exist as one name or the other or both. Jul 03 00:59:33 i mean 1st will be deleted but 2nd not Jul 03 00:59:34 ria: Yes, the soft link is a separate file. So you can separately delete the target and the link. Jul 03 00:59:43 ok Jul 03 00:59:49 * ecntrk has quit (Read error: 104 (Connection reset by peer)) Jul 03 00:59:58 rishi, and in hard link deleting one will delete both? Jul 03 01:00:49 $ ln foo bar Jul 03 01:00:50 ... then until you do: Jul 03 01:00:50 $ rm foo bar Jul 03 01:00:57 ... the file will exist as one name or the other or both. Jul 03 01:01:45 ria, arpita: Clear? Jul 03 01:01:53 ok Jul 03 01:02:13 in rm foo bar are we removing the 2 files of the same name or just deleting the link between them? Jul 03 01:02:16 You can use ls -l to see which file a soft link is pointing to. Jul 03 01:02:22 ln foo bar ... is it a hard link? Jul 03 01:02:37 ria: Hard link. See documentation. Jul 03 01:02:40 and if we use rm foo , then? Jul 03 01:02:48 * Soumya has quit (Read error: 110 (Connection timed out)) Jul 03 01:03:00 arpita: A hard link is not really a "link", its more of an alias or synonym. Jul 03 01:03:16 o.k Jul 03 01:03:23 If you delete one, you just remove the alias. The entire file stays with the other alias. Jul 03 01:04:48 arpita, ria: Clearer now? Jul 03 01:04:55 ok Jul 03 01:04:58 Jul 03 01:05:04 yes Jul 03 01:05:11 * rishi looks at the clock Jul 03 01:05:26 * kushal looks at rishi Jul 03 01:05:27 1:07 am Jul 03 01:05:48 2 hours Jul 03 01:06:15 I wonder how many are still awake. Jul 03 01:06:21 Roll call Jul 03 01:06:21 We are left with rm now. Jul 03 01:06:32 Want to do it now, or in the next class. Jul 03 01:06:33 ? Jul 03 01:06:33 deepak kumar Jul 03 01:06:35 emergency rollcall Jul 03 01:06:43 deepak kumar Jul 03 01:06:45 * Soumya_ has quit (Read error: 110 (Connection timed out)) Jul 03 01:06:46 arpita kapoor Jul 03 01:06:46 aritra bose Jul 03 01:06:50 rishi, rest are sleeping Jul 03 01:06:56 Khushbu Mohta Jul 03 01:07:00 amrita mukherjee Jul 03 01:07:00 kishan goyal Jul 03 01:07:17 sunny sharma Jul 03 01:07:18 Seven awake. Jul 03 01:07:22 * bose_aritra is a night crawler Jul 03 01:07:24 Eight now. Jul 03 01:07:44 So do you want to do rm now? Jul 03 01:07:46 hehe Jul 03 01:07:56 rishi, its seven Jul 03 01:07:57 rishi:finish rm without any taking queries Jul 03 01:08:06 ria das Jul 03 01:08:09 Ok. Lets get to rm. Jul 03 01:08:18 Everybody: Jul 03 01:08:21 $ man rm Jul 03 01:08:24 $ info rm Jul 03 01:08:26 sorry for late reply Jul 03 01:08:26 Prakhar Agarwal Jul 03 01:08:27 $ whatis rm Jul 03 01:09:19 So if I have a file /tmp/fubar , how will I delete it? Jul 03 01:09:26 Who can answer? Jul 03 01:09:35 * Debashree has quit (Read error: 54 (Connection reset by peer)) Jul 03 01:09:41 lol Jul 03 01:10:06 * rishi is waiting Jul 03 01:10:11 rm fubar Jul 03 01:10:18 rm tmp Jul 03 01:10:30 sorry just a wild guess Jul 03 01:10:46 rm /tmp/fubar Jul 03 01:10:54 arpita: No wild guesses when you have a Unix system right now. Jul 03 01:11:02 not sure of? Jul 03 01:11:03 bose_aritra: Correct. Jul 03 01:11:08 rishi:rm -r /tmp/fubar Jul 03 01:11:09 checking if wirking Jul 03 01:11:21 *working Jul 03 01:11:25 ! Jul 03 01:11:30 deepak: Even better. Jul 03 01:11:36 Prakhar: Ask. Jul 03 01:11:43 got it Jul 03 01:11:58 do we require -r if there's only single file to be deleted Jul 03 01:12:02 * stephaniewhiting has quit ("ChatZilla 0.9.82.1 [Firefox 2.0.0.14/2008040413]") Jul 03 01:12:09 i doubt! Jul 03 01:12:21 Jul 03 01:12:24 ^^^^^^ same question Jul 03 01:12:28 ?? Jul 03 01:12:31 Jul 03 01:13:16 bose_aritra, Prakhar: Depends on what you mean by a single file since a directory is also a single file. I think you meant a 'regular file', in which case -r is not needed. Jul 03 01:13:16 * Debashree (n=Debashre@61.2.164.244) has joined #dgplug Jul 03 01:13:43 yeah, i meant a single regular file Jul 03 01:13:46 thanks Jul 03 01:13:52 got it Jul 03 01:13:53 But it would not do any harm to give it. Since the question did mention regular file or directory providing it is safer. Jul 03 01:14:13 debashree banerjee Jul 03 01:14:26 neeraj kumar Jul 03 01:14:38 sorry replying late Jul 03 01:14:55 Ok. Jul 03 01:15:28 rm -i /tmp/fubar Jul 03 01:15:39 rm --preserve-root /tmp/fubar Jul 03 01:16:02 khushi: Ok. Jul 03 01:16:09 * kushal goes to check man page Jul 03 01:16:16 amrita: You will need to provide yes / no after that. Jul 03 01:16:42 only for removing more than three files Jul 03 01:16:54 * indradg_ (n=indradg@59.93.242.105) has joined #dgplug Jul 03 01:17:23 One word of caution: "take a deep breath and count from one to ten before doing: $ rm -rf *" Jul 03 01:17:37 :) Jul 03 01:17:52 amrita: -i and -I are different. Jul 03 01:18:03 ria, otherwise rm -f Jul 03 01:18:09 oops Jul 03 01:18:21 rishi, teaching the young uns to commit suicide?? Jul 03 01:18:28 ! Jul 03 01:18:29 Ok. So you must have noticed that most of the options are same for cp, mv, rm, etc.. Jul 03 01:18:30 rishi, i meant I Jul 03 01:18:50 eg., although -f, -i are interesting, I think we have already covered them. Jul 03 01:19:01 indradg_: Name please. Jul 03 01:19:20 amrita: Ok. Jul 03 01:19:40 Lets take a look at -r or -R or --recursive. Jul 03 01:19:59 We already know its used to delete directories recursively. Jul 03 01:20:05 ! Jul 03 01:20:13 Now here is an excercise: Jul 03 01:20:41 * t4num0y_cs3 (n=Neo@117.194.0.9) has joined #dgplug Jul 03 01:20:53 rishi, ! Jul 03 01:21:03 Prakhar: Ask. Jul 03 01:21:08 "rm -rf *" and "rm-rf /" refers to same thing? Jul 03 01:21:35 Prakhar: No. Jul 03 01:21:52 * is a relative path and / an absolute path. Jul 03 01:21:59 ok Jul 03 01:22:04 Jul 03 01:22:12 "rm -rf /" is not dangerous if you are not crazy enough to work as the root user. Jul 03 01:22:33 rishi, which many of them do Jul 03 01:22:40 :) Jul 03 01:22:55 :) Jul 03 01:22:56 like me but not now onwards Jul 03 01:22:57 But rm -rf * is dangerous because you start off in your home directory, which if blanked will cause a lot of pain. Jul 03 01:23:12 For all those who are working as root, please do: Jul 03 01:23:16 ok, i get your point Jul 03 01:23:18 # rm -rf /* Jul 03 01:23:30 ... to learn your lesson. Jul 03 01:23:48 rishi, nice point ,I should try that Jul 03 01:24:02 Now here is an excercise: Jul 03 01:24:08 $ mkdir foo Jul 03 01:24:14 $ touch foo/bar Jul 03 01:24:30 ls -ld foo Jul 03 01:24:44 $ ls -l foo Jul 03 01:24:51 $ chmod 100 foo Jul 03 01:25:01 $ ls -l foo Jul 03 01:25:12 Any doubts till now? Please try it out. Jul 03 01:25:39 Now here is the question: Jul 03 01:25:48 What will happen if I do: Jul 03 01:25:59 (i) $ ls foo Jul 03 01:26:04 (ii) rm -rf foo Jul 03 01:26:15 ... try to explain why this is so? Jul 03 01:26:27 * rishi waits for an answer Jul 03 01:27:23 * chiks has quit ("ChatZilla 0.9.83 [Firefox 3.0/2008052906]") Jul 03 01:27:36 Please try on the computer for those who are on Unix now. Jul 03 01:27:59 permission denied Jul 03 01:28:15 rishi:[root@localhost ~]# ls foo Jul 03 01:28:16 bar Jul 03 01:28:16 Jul 03 01:28:19 bose_aritra: For (i) or (ii) ? Jul 03 01:28:38 for both Jul 03 01:28:44 * bose_aritra checking again Jul 03 01:28:45 Permission denied Jul 03 01:28:46 rishi:'bar' means what Jul 03 01:28:51 ls foo will give bar Jul 03 01:29:19 ! Jul 03 01:29:32 ls -l foo is showing permission denied Jul 03 01:29:33 2 will remove foo and its contents Jul 03 01:29:52 [aritra@desktop ~]$ ls -l foo Jul 03 01:29:53 total 4 Jul 03 01:29:53 -rw-rw-r-- 1 aritra aritra 0 2008-07-03 01:29 bar Jul 03 01:29:54 arpita: Correct Jul 03 01:30:06 ria: Wrong Jul 03 01:30:28 susenj: (i) or (ii) ? Jul 03 01:30:34 * sunny_slls has quit ("Leaving") Jul 03 01:30:43 deepak: bar is a file Jul 03 01:30:44 both Jul 03 01:30:49 susenj: Correct Jul 03 01:31:01 Now why are they giving a permission denied? Jul 03 01:31:02 after rm -rf i cannot see foo Jul 03 01:31:16 rishi, ! Jul 03 01:31:22 ria: Did you do the chmod? Jul 03 01:31:30 bose_aritra: Speak. Jul 03 01:31:32 i and ii both show permission denied Jul 03 01:31:35 no Jul 03 01:31:35 [aritra@desktop ~]$ mkdir foo Jul 03 01:31:35 [aritra@desktop ~]$ touch foo/bar Jul 03 01:31:35 [aritra@desktop ~]$ ls -ld foo Jul 03 01:31:35 drwxrwxr-x 2 aritra aritra 4096 2008-07-03 01:29 foo Jul 03 01:31:35 [aritra@desktop ~]$ ls -l foo Jul 03 01:31:36 total 4 Jul 03 01:31:38 arpita: Correct. Jul 03 01:31:38 -rw-rw-r-- 1 aritra aritra 0 2008-07-03 01:29 bar Jul 03 01:31:39 rishi:since x permission is not there Jul 03 01:31:40 [aritra@desktop ~]$ chmod 100 foo Jul 03 01:31:42 [aritra@desktop ~]$ ls -l foo Jul 03 01:31:44 ls: cannot open directory foo: Permission denied Jul 03 01:31:46 [aritra@desktop ~]$ ls foo Jul 03 01:31:46 chmod 100 means foo is executable Jul 03 01:31:48 ls: cannot open directory foo: Permission denied Jul 03 01:31:50 [aritra@desktop ~]$ rm -rf foo Jul 03 01:31:54 rm: cannot remove `foo': Permission denied Jul 03 01:31:57 rishi, am getting this Jul 03 01:31:58 bose_aritra, EVER HEARD OF http://rafb.net/paste ? Jul 03 01:32:05 Jul 03 01:32:15 neither i got permission denied Jul 03 01:32:19 kushal, sorry for flooding. Jul 03 01:32:28 bose_aritra: Correct. Jul 03 01:32:30 rishi:x is needed to enter into as well as delete it Jul 03 01:32:43 Now I want the reason for the permission denied. Guesses will do, Jul 03 01:32:55 deepak: The x bit is still on. Jul 03 01:32:57 chmod 100 means"to make the file executable" Jul 03 01:33:07 if i am not wron Jul 03 01:33:09 100 means --x------ Jul 03 01:33:11 *wrong Jul 03 01:33:17 yes Jul 03 01:33:25 * indradg has quit (Connection timed out) Jul 03 01:33:27 ls -ld foo shows me x Jul 03 01:33:28 susenj: Correct. Jul 03 01:33:38 but not foo Jul 03 01:33:44 We only removed the read/write. Jul 03 01:33:49 its not executable Jul 03 01:34:02 so how can one see the contents of an executable Jul 03 01:34:06 ?? Jul 03 01:34:13 ria: What? It has x and its not executable? Jul 03 01:34:13 its ridiculous Jul 03 01:34:25 susenj: Why? Do: Jul 03 01:34:33 i am saying about ls -l Jul 03 01:34:34 $ cat /bin/ls Jul 03 01:34:40 rishi:x is missing here Jul 03 01:34:45 ls -l foo does not have x Jul 03 01:34:47 deepak: It can't be. Jul 03 01:34:49 ls foo will not show anything Jul 03 01:34:51 so not executable Jul 03 01:34:52 rishi, i'm not getting permission denied Jul 03 01:35:00 ls -ld is executable Jul 03 01:35:04 that's why permission denied Jul 03 01:35:09 Ok. Today's class is over. Jul 03 01:35:22 rishi, others part in both does not have read write permissions Jul 03 01:35:34 am i right a little bit,rishi? Jul 03 01:36:23 susenj: No. It will not show anything and permission denied are the same thing. That is not the reason. Jul 03 01:36:31 rishi, please help. Jul 03 01:36:45 ria: Yes, so? Keep guessing. Jul 03 01:36:46 * coolpyro_rishi has quit (Read error: 104 (Connection reset by peer)) Jul 03 01:36:47 * t4num0y_cs3 (n=Neo@117.194.0.9) has left #dgplug ("Leaving") Jul 03 01:36:57 * coolpyro_rishi (n=chatzill@202.63.119.36) has joined #dgplug Jul 03 01:37:10 See without read permission you can not list the contents of a directory. Jul 03 01:37:15 rishi, after doing rm -rf i cannot find the folder though Jul 03 01:37:23 That is why (i) gives a permission denied. Jul 03 01:37:25 mkdir foo Jul 03 01:37:40 * sunny_slls (i=Sunny@117.99.4.204) has joined #dgplug Jul 03 01:38:00 rishi:ls -ld foo is not giving permission denied why? Jul 03 01:38:00 neither i got permission denied Jul 03 01:38:16 When we do rm -rf foo, rm tries to read the contents of foo to delete them. It can't read the contents because foo does not have the read bit set. Jul 03 01:38:20 * sunny_slls has quit (Client Quit) Jul 03 01:38:30 That explains (ii). Jul 03 01:38:50 <--------CLASS ENDS----------->