lesson four
One of the tools Michiel has given me to help me learn is a book; “Linux Start Up Guide” by Fred Hantlemann. I’ve been reading some of it before i went to bed the last few nights (to be truthfully honest, mostly because reading just a couple of pages has me snoring before i know it. Its not boring or anything, more that.. well, mention words like “variables” and my eyes start closing of their own accord. annoying, really), and finally got to the point where, really, i had to start trying some of what i was reading if i was to make any sense of it (you know, the old “Tell Me I will forget, Show Me I will remember, Involve Me I will understand!”).
So Chapter 3 (”Operating Linux”) so far has had me using the whoami, the who am i, the id and the set commands, the ps -al command, the ls one (which i knew already) and ls /usr/bin | more, and more /var/log/debug which gave me a rude reply about not having access. well
to you too matey.
It then went into detail about how to move and copy files, using the cp and mv commands, and how to make a directory (mkdir).
Then it started in on Vi. Now, this i’d heard of: Michiel had gone to some effort to explain to me why emacs = bad and Vim (the uptodatebigbrother verson of Vi) is good. not that i was any the wiser, then, as i didn’t really understand what an editor was. to me, an editor is the person in charge of a magazine. So i went looking on the intertubewebthingie to see if i could understand it a bit better. Wikipedia was a start: it led me to a page on why Vi (pronounced Vee-eye, not Vie) was the greatest gift to man, and why some nutheads use Vi/Vim. (at which point i turned to Michiel and asked him, is Vi/Vim good? he said yes. so emacs is bad. at least, from his perspective. Do i agree? no idea. yet. :D) so i think i understand now, what an editor is. its a program that lets you write. you can write normal text (although you’d be better off using a word processor or something if that was all you wanted to do) but you can also write programs. However, there’s a catch. in order to execute (i.e. run) your new program you either have to use the command interpreter to execute the contents of it, or you can mark the file as an executable.
huh? okay.. whats the Command Interpreter? (reading these things is frustrating: you understand one thing and get 20 more questions). Well, that was the next bit of the book, funnily enough, and the bit that sent me back to the intertubesfount-of-all-info. According to the book, the job of a Command Interpreter is “to analyse, or interpret command lines entered by the user and start any programs cited”. well, hey, that sounds like konsole, which is what Michiel tells me to use when he wants me to do something (and i’m slowly getting less scared of). and this goes back to another conversation we had, where he tried (and failed, although not his fault) to explain the difference between konsole and Bash (as an example of a Command Interpreter). Wikipedia was my starting point (Its not for nothing i’m known as wikislut), although not terribly illuminating, it was thinking about what i’d read in the book and everything else i’d learned that finally clued me in: Bash will do a lot of the things Konsole does, but Bash does more than Konsole does too. Konsole will only run or execute files, Bash will do the analyzing part as well.
So.. to make a program you have to write it first in an editor like Vim (or the much hated emacs), then use a command interpreter to analyse it and get it to run. analyse.. meaning check it works? Maybe i’ve got my understanding totally wrong, but it seems like a terribly long winded way to go about it. why not one program that will do everything: write the code, check it for bugs, then execute it?
hmmmm. see what i mean? … understand something.. get more questions.. argh!!!
I’m going to go have a bath and think this through some more.
April 8, 2008 at 1:05 pm
okay, last night (very late last night) Michiel explained the whole .. why Editors and Command Interpreters aren’t in the same package. Actually, he said some Editors do have the ability to do the command interpreting thing from within the program, so that you can run and test it. however, the way to think of it is: you don’t want to be opening up a huge editorial program every time you want to just run your favorite bit of script, and that’s why they’re seperate. Another way to look at it is: you don’t write HTML within firefox, do you? you use something like dreamweaver. dreamweaver = the editor, firefox = the command interpreter. And that all makes sense to me now.
April 9, 2008 at 1:33 am
more /var/log/debug which gave me a rude reply about not having access.
The debug file containts some information (ok, ok, a lot of information) in regard of computer hardware. It’s one the many sources an admin may look to get a clue about why hardware isn’t working as it shoul be.
As for the whole “vi-versus-emacs” issue is a difficult one. Guess you have to figure out which one you use. Vi is definatly harder to get to use to, but rather powerful. I like it because what ever unix system I use, I can be pretty sure there is vi installed. Be it Solaris, HP/UX, Tru64, Linux etc.
As for the “command interpreter” I think you best just have to read “shell” or “bash”. It’s just a fancy word .. nothing more
[ okay it’s slightly more as there are different command interpreters that don’t functions as a shell (for example perl, python etc)
explain the difference between konsole and Bash….
Well you almost got it right there. The best way to look at Konsole is that it’s a “terminal emulator” or a “terminal window application” that uses the bash shell for displaying the stuff that bash does.
Konsole just add some fancy features such as tab’s, custom keybindings, colours etc etc etc to make working within Konsole a little bit more easier.
why not one program that will do everything: write the code, check it for bugs, then execute it?
Part of this is the Unix Philosophy. Basically it comes down to this:
1) Write programs that do one thing and do it well.
2) Write programs to work together.
3) Write programs to handle text streams, because that is a universal interface.”
Or in really short: “Do one thing, Do it well”
April 9, 2008 at 3:25 pm
The debug file containts some information (ok, ok, a lot of information) in regard of computer hardware. It’s one the many sources an admin may look to get a clue about why hardware isn’t working as it shoul be.
so next time some hardware isn’t working and you’re swearing over it, i can safely suggest you look at the debug file? or is this on the same lines as switching the computer on and off?
re: Vi vs emacs - i had a quick look at Vi. I’m not sure, at this point, if i want to get into the whole, writing my own script thing. i think my first aim should be maintaining my own box and a general understanding of whats what and what goes where and so on, so that i know where to look things up and understand some of the conversations that go on in ##woodchucks and ##slackware. After that, maybe, i can look at getting into scripting or coding or whatever. maybe. a big fat maybe. (and maybe i’ll be so good at scripting/coding that i start pointing out holes in your code. that would make you happy, wouldn’t it? (NOT)).
reading “shell” or “bash”.. you mean the book? the korn shell or bash book that you sweat over sometimes? uh-huh. not yet.
and i’ll go with the Unix Philosophy. sounds good. along with the KISS one.
April 9, 2008 at 3:42 pm
i can safely suggest you look at the debug file?
Changes are that if I have reached the muttering/swearing state. I already checked all those files [/var/log/{syslog,messages,debug,dmesg}] and so more. Most of the time it got past the stage where the information provided by the system is either just plain not working or not enough of an idea to go on to get it working.
re: Vi vs emacs - i had a quick look at Vi.
I think it’s mostly a case of actually using them. vi (be that nvi, elvis,vim,gvim) has a much steeper learning curve than emacs probably. However I feel that vi* is more powerful than emacs. Again, it does take some getting used to.
As for having to start coding, that’s not needed, but occasionally use vim/vi to write notes is a whole lot more quicker and effective than starting up OpenOffice writer so to speak. And you don’t want a full wordprocessor to make a couple of changes to a config file really. There are other issues at work besides just memory usage (such as [file] formatting, etc).
reading “shell” or “bash”.. you mean the book?
No, I had to reread what I meant (guess this is what I get for writing comments late at night).
While the book isn’t a bad read in itself and offers much inside view in how bash or rather the korn shell works, I really meant it in the way of “read instead of” i.e. replace “command interpreter in most cases with shell or bash”.