Jump to content

chris18

Members
  • Posts

    209
  • Credits

  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by chris18

  1. I have already posted the source...i just found it usefull and share it..lol ;D
  2. ("Ο Φάνης" - Αφοί Κατσιμίχα) Δυο χρόνια είχα να σε δω, και σε συνάντησα ξανά σ' ενα ISP. Περνούσες patches, service packs σ' ένα θηρίο και τα καλά σου φόραγες, σαν να' σουν πωλητής. ***** Δεν ήσουνα programmer, για να πω "καλά να πάθεις", μα ούτε web developer, για να πω "βάλε μυαλό". Solaris κι HP admin 2 χρόνια κι 6 μήνες, system shutdown έκανες, και είπες "άντε γεια". ***** Το ξέρω, ζήτησες δουλειά σε χιλια δύο αφεντικά, κι όλοι ζητούσανε να δουν συστάσεις, προϋπηρεσία. Μα μόλις είδανε κι αυτοί ότι δεν ήξερες ΝΤ, σε διώξανε σαν το σκυλί και δεν σ' αφήσανε να πεις μια δικαιολογία... ***** Και είπες στην αρχή "καλά", κι αλλού εζήτησες δουλειά. Κι αλλού ξανά, κι αλλού τα ίδια και τα ίδια. Μα ήσουν άτυχος πολύ, γιατί έπεσες και σ' εποχή που όλοι δουλεύανε ΝΤ κι εσύ είχες OpenBSD κι' αυτό το OS, το ξέρεις, φέρνει ανεργία. ***** Κι ερχόντουσαν και τα crash dumps κάθε που νύχτωνε, σε τυραννούσαν reinstalls μέσα στο βράδυ. Κι είναι μαρτύριο τρομερό, το βίτσιο αυτό το βρωμερό που σου' μαθέ το point n' click εκείνος ο κοντός απ' τον Πουλιάδη. ***** Σου λείπει το FreeBSD, το ξέρεις πως δε φταις εσύ. Φωτιές σου καίνε το κορμί, κουτάκι και εικόνα. Και έκανες υπομονή, γιατί φοβόσουν τα ΝΤ, τα λόγια μέσ' την μοναξιά και τα mails που ερχόντουσαν απ' τον Exchange Server. ***** Μέχρι να σου βγει η ψυχή, δε θα ξεχάσεις μια στιγμή, κάποια βραδιά που σκόνταψες πάνω στο UPS. Κι είπανε τ' άλλο το πρωί στο 15 το PC, ότι βιάσανε οι παλιοί τον sysadmin τον Μήτσο ***** Κι όταν σε βρήκαν παγωμένο στο VT σου, είπαν "αυτός είναι από ώρα πια νεκρός"... Και κάποιος έτρεξε τηλέφωνο να πάρει. ***** Πέντε βδομάδες τώρα υπέφερες το ξέρω. Το ξέρω, σου έλειψε το /bin/tcsh. ***** Και μου 'λεγες "εκεί ξανά δεν θα γυρίσω, βαρέθηκα blue screens κάθε λεπτό, σαν άνθρωπος κι εγώ θέλω να ζήσω"... ***** Δυο χρόνια είχα να σε δω, και σε συνάντησα ξανά σε ISP. Περνούσες patches, service packs σ' ένα θηρίο και τα καλά σου φόραγες, σαν να' σουν πωλητής.
  3. One day στην λιακάδα sitting on the πρασινάδα where the flowers ανθούσαν αnd the horses χλιμιντρούσαν say ο Μήτρος to Κρουστάλλω -Do you μ' απατάς με άλλο; κι η Κρουστάλλω σαν το hear τηνε πιάνει μέγας fear because τόπε η Μαγδάλω ότι did it μ' έναν Γάλλο. αnd the girl πονηρεμένη lay down σαν πεθαμένη -Μήτρο μ' if you don't believe me με το καριοφύλι kill me. and the Μήτρος που ήταν θύμα την επίστεψε the βλήμα.
  4. Έχω κάτσει και σβήνω τον παλιό μου σκληρό που τον είχα αγοράσει απ' το Πλαίσιο θαρρώ Μεσ' τα clusters ήταν δεδομένα σωρός και τα Windows μπήκαν από πάνω απ' το DOS Τόσες κρύες στιγμές στου mp3 τις αρχές με το napster παλιά και μετά απ' το Kazaa Μου άνοιγε παραθύρια και μ' ελάχιστη RAM να δουλεύει σκληρά κι ούτε ένα underun Τον παλιό μου σκληρό κι έσβηναν τα αρχεία χάνονταν ένα ένα μεσ' τον κάδο τα 'ριχνα με τα shift πατημένα Και μια μέρα τρελή ένας φίλος δικός μου μου 'φερε τα XP μου 'πε βάλτα κι εσύ Πως περάσαν τα χρόνια πόσο λίγες στροφές Τα XP δε χωράνε το δοκίμασα χτες Τον παλιό μου σκληρό Τον χαρίζω σε σένα Να προσέχεις μικρή μου Έχει sectors χαμένα …Έχει sectors χαμένα
  5. They haven't changed anything,maybe you can't lvl it in your server only,or you are doing something wrong
  6. (Cuz in the first post i wasn't allowed to write more,the rest is here) Information about what color and stage you need for desired SA for your weapon is here Grade Weapon Name (Crystal Stage) Red Crystal Green Crystal Blue Crystal Blunt C Stick of Faith (5) Mana Up Magic Hold Magic Shield C Battle Axe (5) Anger Rsk.Focus Haste C Big Hammer (5) Health Rsk.Focus Haste C Silver Axe (5) Anger Rsk.Focus Haste C Skull Graver (5) Anger Health Rsk.Focus C Dwarven War Hammer (6) Anger Health Haste C Club of Nature (7) Magic Hold Magic Mental Shield Acumen C Mace of The Underworld (7) Mana Up Magic Silence Conversion C Nirvana Axe (7) Magic Poison Magic Power Magic Weakness C Stick of Eternity (7) Empower Rsk., Evasion Bless the Body C War Axe (7) Anger Health Haste C Yaksa Mace (8 ) Anger Health Rsk. Focus B Heavy War Axe (9) Anger Health Rsk. Focus B Art of Battle Axe (10) Health Rsk. Focus Haste B Deadman's Glory (10) Anger Health Haste A Meteor Shower (11) Focus Critical Bleed Rsk. Haste A Elysian Axe (12) Health Anger Critical Drain S Arcana Mace (13) Acumen MP Regeneration Mana Up S Basalt Battlehammer (13) HP Drain Health HP Regeneration Two-Handed Blunts C Crystal Staff (5) Rsk. Evasion Mana Up Bodily Blessing C Heavy Doom Axe (5) Magic Poison Magic Weakness Magic Chaos C Heavy Doom Hammer (5) Magic Regeneration Mental Shield Magic Hold C Cursed Staff (6) Magic Hold Magic Poison Magic Weakness C Inferno Staff (7) Acumen Magic Silence Magic Paralyze C Paagrio Hammer (7) Rsk. Evasion Magic Poison Magic Weakness C Paradia Staff (7) Magic Regeneration Mental Shield Magic Hold C Sage's Staff (7) Magic Hold Magic Poison Magic Weakness C Paagrio Axe (7) Mana Up Magic Weakness Magic Chaos C Deadman's Staff (8 ) Magic Regeneration Mental Shield Magic Hold C Demon's Staff (8 ) Magic Poison Magic Weakness Magic Chaos C Ghoul's Staff (8 ) Rsk. Evasion Mana Up Bodily Blessing B Sprite's Staff (9) Magic Regeneration Mental Shield Magic Hold B Staff of Evil Spirit (10) Magic Focus Bodily Blessing Magic Poison A Dasparion's Staff (11) Mana Up Conversion Acumen A Branch of The Mother Tree (12) Conversion Magic Damage Acumen S Imperial Staff (13) Empower MP Regeneration Magic Hold S Dragon Hunter Axe (13) HP Regeneration Health HP Drain Bow C Crystallized Ice Bow (5) Guidance Evasion Quick Recovery C Elemental Bow (5) Guidance Miser Quick Recovery C Noble Elven Bow (6) Evasion Miser Cheap Shot C Akat Long Bow (7) Guidance Evasion Miser C Eminence Bow (8 ) Guidance Miser Cheap Shot B Dark Elven Long Bow (9) Evasion Critical Bleed Miser B Bow of Peril (10) Guidance Quick Recovery Cheap Shot A Carnage Bow (11) Light Critical Bleed Mana Up A Soul Bow (12) Cheap Shot Quick Recovery Critical Poison S Draconic Bow (13) Cheap Shot Focus Critical Slow Dagger C Cursed Dagger (5) Critical Bleed Critical Poison Rsk. Haste C Dark Elven Dagger (5) Focus Back Blow Rsk. Haste C Soulfire Dirk (6) Magic Hold Magic Silence Mana Up C Stiletto (6) Critical Bleed Critical Poison Rsk. Haste C Dark Screamer (7) Evasion Focus Critical Bleed C Grace Dagger (7) Evasion Focus Back Blow C Crystal Dagger (8 ) Critical Bleed Critical Poison Critical Damage B Hell Knife (9) Mental Shield Magic Weakness Magic Regeneration B Kris (9) Evasion Focus Back Blow B Demon's Sword (10) Critical Bleed Critical Poison Critical Damage A Bloody Orchid (11) Focus Back Blow Critical Bleed A Soul Separator (12) Guidance Critical Damage Rsk. Haste S Angel Slayer (13) Crt. Damage HP Drain Haste Fists C Chakram (5) Critical Drain Critical Poison Rsk. Haste C Fist Blade (6) Rsk. Evasion Rsk. Haste Haste C Knuckle Duster (8 ) Rsk. Evasion Rsk. Haste Haste C Great Pata (8 ) Critical Drain Critical Poison Rsk. Haste B Arthro Nail (9) Critical Poison Rsk. Evasion Rsk. Haste B Bellion Cestus (10) Critical Drain Critical Poison Rsk. Haste A Blood Tornado (11) Haste Focus Anger A Dragon Grinder (12) Rsk. Evasion Guidance Health S Demon Splinter (13) Focus Health Crt. Stun Pole C Body Slasher (5) Critical Stun Long Blow Wide Blow C Orcish Glaive (5) Anger Critical Stun Long Blow C Scythe (5) Anger Critical Stun Light C Bec de Corbin (6) Critical Stun Long Blow Light C Poleaxe (7) Wide Blow Long Blow Critical Stun C Scorpion (7) Anger Critical Stun Long Blow C Widow Maker (7) Critical Stun Long Blow Wide Blow C Orcish Poleaxe (8 ) Critical Stun Long Blow Wide Blow B Great Axe (9) Anger Critical Stun Light B Lance (10) Anger Critical Stun Long Blow A Halberd (11) Haste Critical Stun Wide Blow A Tallum Glaive (12) Guidance Health Wide Blow S Saint Spear (13) Health Guidance Haste Sword C Stormbringer (5) Critical Anger Focus Light C Katana (6) Focus Critical Damage Haste C Raid Sword (6) Focus Critical Drain Critical Poison C Shamshir (6) Guidance Back Blow Rsk. Evasion C Spirit Sword (6) Critical Damage Critical Poison Haste C Homunkulus's Sword (7) Acumen Conversion Magic Paralyze C Sword of Whispering Death (7) Empower Magic Power Magic Silence C Caliburs (7) Guidance Focus Critical Damage C Sword of Delusion (7) Focus Health Rsk. Haste C Sword of Limit (7) Guidance Critical Drain Health C Sword of Nightmare (7) Health Focus Light C Tsurugi (7) Focus Critical Damage Haste C Samurai Longsword (8 ) Focus Critical Damage Haste B Sword of Valhalla (9) Acumen Magic Weakness Magic Regeneration B Keshanberk (9) Guidance Focus Back Blow B Sword of Damascus (10) Focus Critical Damage Haste A Elemental Sword (11) Magic Power Magic Paralyze Empower A Tallum Blade (11) Critical Poison Haste Anger A Sword of Miracles (12) Magic Power Magic Silence Acumen A Dark Legion's Edge (12) Critical Damage Health Rsk. Focus S Forgotten Blade (13) Haste Health Focus Two-Handed Swords C Flamberge (5) Critical Damage Focus Light C Berserker Blade (8 ) Focus Critical Damage Haste B Great Sword (9) Health Critical Damage Focus A Dragon Slayer (12) Health Critical Bleed Critical Drain S Heaven's Divider (13) Haste Health Focus Source:pmfun.com
  7. Monster Name(Level) Type Crystal Stage Crystal Stage:2 Nos(40) Aggressive 2 Timak Orc(40) Passive 2 Blade Stakato(41) Passive 2 Light Worm(41) Aggressive 2 Timak Orc Archer(41) Passive 2 Timak Orc Troop Archer(41) Passive 2 Blade Stakato Worker(42) Passive 2 Timak Orc Soldier(42) Aggressive 2 Blade Stakato Warrior(43) Aggressive 2 Timak Orc Troop Warrior(43) Passive 2 Timak Orc Warrior(43) Passive 2 Crystal Stage:3 Blade Stakato Drone(44) Passive 3 Timak Orc Shaman(44) Passive 3 Timak Orc Troop Shaman(44) Passive 3 Timak Orc Overlord(45) Aggressive 3 Timak Orc Troop Leader(45) Passive 3 Water Giant(45) Aggressive 3 Forest Of Mirrors Ghost(46) Aggressive 3 Light Bringer(46) Aggressive 3 Queen Undine Lad(46) Passive 3 Unpleasant Humming(46) Aggressive 3 Unpleasant Humming(46) Aggressive 3 Unpleasant Humming(46) Aggressive 3 Crystal Stage:4 Death Flyer(47) Passive 4 Death Flyer(47) Passive 4 Death Flyer(47) Passive 4 Eva's Seeker(47) Passive 4 Forest Of Mirrors Ghost(47) Aggressive 4 Fiend Archer(48) Aggressive 4 Fiend Archer(48) Aggressive 4 Forest Of Mirrors Ghost(48) Aggressive 4 Garden Guard(48) Passive 4 Theeder Piker(48) Aggressive 4 Mirror(49) Passive 4 Musveren(49) Passive 4 Musveren(49) Passive 4 Musveren(49) Passive 4 Theeder Mage(49) Passive 4 Crystal Stage: 5 Doll Master(50) Aggressive 5 Garden Guard Leader(50) Aggressive 5 Harit Lizardman(50) Passive 5 Zaken's Guard(50) Aggressive 5 Zaken's Guard(50) Aggressive 5 Zaken's Royal Guard(50) Aggressive 5 Harit Lizardman Grunt(51) Passive 5 Kaim Vanul(51) Passive 5 Kaim Vanul(51) Passive 5 Kaim Vanul(51) Passive 5 Harit Lizardman Archer(52) Aggressive 5 Pirate Zombie Captain(52) Aggressive 5 Pirate's Zombie Captain(52) Aggressive 5 Pirate Zombie Captain(60) Aggressive 5 Crystal Stage: 6 Doll Blader(53) Passive 6 Doll Blader(53) Passive 6 Doll Blader(53) Passive 6 Sairon's Doll(53) Passive 6 Sairon's Puppet(53) Passive 6 Sairon(54) Aggressive 6 Vale Master(54) Aggressive 6 Vale Master(54) Aggressive 6 Vale Master(54) Aggressive 6 Halingka(55) Passive 6 Yintzu(56) Aggressive 6 Crystal Stage: 7 Paliote(57) Passive 7 Hamrut(58) Aggressive 7 Crystal Stage: 8 Kranrot(59) Aggressive 8 Doom Servant(60) Aggressive 8 Crystal Stage: 9 Doom Guard(61) Passive 9 Doom Archer(62) Aggressive 9 Doom Guard(66) Passive 9 Doom Archer(67) Passive 9 Crystal Stage: 10 Doom Trooper(63) Passive 10 Doom Warrior(64) Passive 10 Doom Knight(65) Aggressive 10 Erin Ediunce(66) Aggressive 10 Malruk Knight(66) Aggressive 10 Malruk Berserker(67) Aggressive 10 Platinum Tribe Soldier(67) Aggressive 10 Malruk Lord(68) Aggressive 10 Platinum Tribe Archer(68) Aggressive 10 Pytan Knight(68) Passive 10 Limal Karinness(69) Aggressive 10 Platinum Tribe Warrior(69) Aggressive 10 Pytan(69) Aggressive 10 Karik(70) Aggressive 10 Messenger Angel(70) Aggressive 10 Messenger Angel(70) Aggressive 10 Platinum Tribe Shaman(70) Aggressive 10 Platinum Guardian Archer(71) Aggressive 10 Platinum Tribe Overlord(71) Aggressive 10 Guardian Angel(72) Aggressive 10 Platinum Guardian Warrior(72) Aggressive 10 Platinum Guardian Shaman(73) Aggressive 10 Seal Angel(73) Aggressive 10 Seal Angel(73) Aggressive 10 Guardian Archangel(74) Aggressive 10 Guardian Archangel(74) Aggressive 10 Platinum Guardian Prefect(74) Aggressive 10 Platinum Guardian Chief(75) Aggressive 10 Seal Archangel(75) Aggressive 10 Seal Archangel(75) Aggressive 10 Crystal Stage: 11, 12 Zaken(60) Passive 11, 12 Beast Lord Behemoth(70) Passive 11, 12 Meanas Anor(70) Passive 11, 12 Roaring Skylancer(70) Passive 11, 12 Eilhalder Von Hellmann(71) Passive 11, 12 Antharas Priest Cloe(74) Passive 11, 12 Krokian Padisha Sobekk(74) Passive 11, 12 Baium(75) Passive 11, 12 Anakim(80) Passive 11, 12 Lilith(80) Passive 11, 12 Sailren(87) Passive 11, 12 Tyrannosaurus(87) Aggressive 11, 12 Tyrannosaurus(87) Aggressive 11, 12 Tyrannosaurus(87) Aggressive 11, 12 Crystal Stage: 13 Anakazel(78) Passive 13 Antharas (79) Passive 13 Ember(85) Passive 13 Scarlet Van Halisha(85) Passive 13 Valakas(85) Passive 13 Scarlet Van Halisha(90) Passive 13 Quick Crystal Leveling Guide You can get soul crystals of any of the three colors for free (well actually 1 crystal costs 50k SP) by asking the master of the mage guild in Giran, Oren or Aden about Enhance your weapon quest. You will also get a list of mobs on which you can level the soul crystal. Then you have to level up the crystal by yourself. The other way to obtain a soul crystal is to buy it from other players ;) While talking to NPC about the quest you can receive only 1 crystal at a time. To obtain more you must either drop it on the ground, trade to someone else or put it in warehouse, then talk to NPC again. Of course there is no limit for crystal count you can carry. Leveling a crystal up to stage 10 Leveling a soul crystal is done by fighting any of the mobs on the list, an when it is at half health or below, use the soul crystal (right click in inventory, or move it to your quick bar and use it from there). No matter who damages the monster, you must use the crystal when HP is below 50% and do the last hit. If monster gets (self)healed, regenerated, etc. and it's HP goes above half hit points, you have to reduce it again and then use the crystal once more. It's up to you do decide if you level the crystals in stages by doing the low crystal levels on low level monsters, and so on, or simply don't waste time and go to harder mobs and do all levels there. If more than one player uses a soul crystal on the monster at the same time, the one who gets last hit is the one that gets a level attempt on that mob. Soul Crystals of lower levels (up to maybe 7) are not that hard to get. Levels 8 and 9 are still manageable. At stage 10, leveling becomes a real pain - prepare yourself to break many dozens of soul crystals before you succeed - actually it's the matter of luck ;) Important: You must not have more than one soul crystal in your inventory when leveling it, or it won't work. So either drop the unnecessary crystals on the ground somewhere hidden, or give them to a friend to carry them for you. After the death of the mob, there are four possible results: - Nothing happens: You have done something wrong: used the crystal too early, didn't get the last hit, low level mob (deep blue), wrong mob or you don't have the quest Enhance your weapon. - The soul crystal resonates: Make sure you have only one crystal in your inventory. - The soul crystal was not able to absorb a soul: You did all right but no luck - try again, the crystal stays. - The soul crystal succeeded in absorbing a soul: Hooray! You did it - you leveled up the crystal by 1 level. It will be replaced with a higher stage crystal (note, the crystal will be removed from quick bar). - The soul crystal shatters: You did all right but no luck - the crystal is destroyed and all is lost. Get a new crystal in order to continue. - The soul crystal is refusing to absorb a soul: The monster level is too low, move to higher mobs. Leveling a crystal to stages 11, 12 and 13 - It can be leveled only on several Raid Bosses (see table above). - The whole party can level up it's crystals at the same time. No need to use it on raid or do anything else. Only make sure there is one soul crystal stage 10, 11 or 12 in your inventory, and your party does the last hit. Thus way you can level up 9 crystals. - The crystal can never break.
  8. Grats Ekoice for your second beginning :)
  9. No Ekoice,you thing correct,Maxtor is Warmaster.Also you can log 2 accs with the same computer
  10. Poli xlomo :D .Kapote mporouses na bgeis me hlapex alla tora yok :P
  11. (Because in the first post i wasn't allowed to write more,the rest is here.) Loops Sequential execution and conditionals are only two of the three fundamental building blocks of programming. The third is the loop. In the previous section I proposed a solution for checking if the spam was heated, but it was quite clearly inadequate. What if the spam wasn’t finished the next time we checked either? How could we know how many times we needed to check it? The truth is, we couldn’t. And we shouldn’t have to. We should be able to ask the computer to keep checking until it was done. How do we do that? You guessed it — we use a loop, or repeated execution. Python has two loop types: while-loops and for-loops. For-loops are perhaps the simplest. For instance: for food in “spam”, “eggs”, “tomatoes”: print “I love”, food This means: For every element in the list “spam”, “eggs”, “tomatoes”, print that you love it. The block inside the loop is executed once for every element, and each time, the current element is assigned to the variable food (in this case). Another example: for number in range(1,100): print “Hello, world!” print “Just”, 100 - number, “more to go…” print “Hello, world” print “That was the last one… Phew!” The function range returns a list of numbers in the range given (including the first, excluding the last… In this case, [1..99]). So, to paraphrase this: The contents of the loop is executed for each number in the range of numbers from (and including) 1 up to (and excluding) 100. (What the loop body and the following statements actually do is left as an exercise.) But this doesn’t really help us with our cooking problem. If we want to check the spam a hundred times, then it would be quite a nice solution; but we don’t know if that’s enough — or if it’s too much. We just want to keep checking it while it is not hot enough (or, until it is hot enough — a matter of point-of-view). So, we use while: # Spam-cooking program # Fetch the function *sleep* from time import sleep print “Please start cooking the spam. (I’ll be back in 3 minutes.)” # Wait for 3 minutes (that is, 3*60 seconds)… sleep(180) print “I’m baaack :)” # How hot is hot enough? hot_enough = 50 temperature = input(“How hot is the spam? “) while temperature < hot_enough: print “Not hot enough… Cook it a bit more…” sleep(30) temperature = input(“OK. How hot is it now? “) print “It’s hot enough - You’re done!” New things in this example… 1. Some useful functions are stored in modules and can be imported. In this case we import the function sleep (which sleeps for a given number of seconds) from the module time which comes with Python. (It is possible to make your own modules too…) Exercise 2 Write a program that continually reads in numbers from the user and adds them together until the sum reaches 100. Write another program that reads 100 numbers from the user and prints out the sum. Bigger Programs — Abstraction If you want an overview of the contents of a book, you don’t plow through all pages — you take a look at the table of contents, right? It simply lists the main topics of the book. Now — imagine writing a cookbook. Many of the recipes, like “Creamy Spam and Macaroni” and “Spam Swiss Pie” may contain similar things, like spam, in this case - yet you wouldn’t want to repeat how to make spam in every recipe. (OK… So you don’t actually make spam… But bear with me for the sake of example :)). You’d put the recipe for spam in a separate chapter, and simply refer to it in the other recipes. So — instead of writing the entire recipe every time, you only had to use the name of a chapter. In computer programming this is called abstraction. Have we run into something like this already? Yup. Instead of telling the computer exactly how to get an answer from the user (OK - so we couldn’t really do this… But we couldn’t really make spam either, so there… :)) we simply used input - a function. We can actually make our own functions, to use for this kind of abstraction. Let’s say we want to find the largest integer that is less than a given positive number. For instance, given the number 2.7, this would be 2. This is often called the “floor” of the given number. (This could actually be done with built-in Python function int, but again, bear with me…) How would we do this? A simple solution would be to try all possibilities from zero: number = input(“What is the number? “) floor = 0 while floor <= number: floor = floor+1 floor = floor-1 print “The floor of”, number, “is”, floor Notice that the loop ends when floor is no longer less than (or equal to) the number; we add one too much to it. Therefore we have to subtract one afterwards. What if we want to use this “floor”-thing in a complex mathematical expression? We would have to write the entire loop for every number that needed “floor”-ing. Not very nice… You have probably guessed what we will do instead: Put it all in a function of our own, called “floor”: def floor(number): result = 0 while result <= number: result = result+1 result = result-1 return result New things in this example… 1. Functions are defined with the keyword def, followed by their name and the expected parameters in parentheses. 2. If the function is to return a value, this is done with the keyword return (which also automatically ends the function. Now that we have defined it, we can use it like this: x = 2.7 y = floor(2.7) After this, y should have the value 2. It is also possible to make functions with more than one parameter: def sum(x,y): return x+y Exercise 3 Write a function that implements Euclid’s method for finding a common factor of two numbers. It works like this: 1. You have two numbers, a and b, where a is larger than b 2. You repeat the following until b becomes zero: 3. a is changed to the value of b 4. b is changed to the remainder when a (before the change) is divided by b (before the change) 5. You then return the last value of a Hints: 1. Use a and b as parameters to the function 2. Simply assume that a is greater than b 3. The remainder when x is divided by z is calculated by the expression x % z 4. Two variables can be assigned to simultaneously like this: x, y = y, y+1. Here x is given the value of y (that is, the value y had before the assignment) and y is incremented by one More About Functions How did the exercise go? Was it difficult? Still a bit confused about functions? Don’t worry — I haven’t left the topic quite yet. The sort of abstraction we have used when building functions is often called procedural abstraction, and many languages use the word procedure along with the word function. Actually, the two concepts are different, but both are called functions in Python (since they are defined and used in the same way, more or less.) What is the difference (in other languages) between functions and procedures? Well — as you saw in the previous section, functions can return a value. The difference lies in that procedures do not return such a value. In many ways, this way of dividing functions into two types — those who do and those who don’t return values — can be quite useful. A function that doesn’t return a value (a “procedure”) is used as a “sub-program” or subroutine. We call the function, and the program does some stuff, like making whipped cream or whatever. We can use this function in many places without rewriting the code. (This is called code reuse — more on that later.) The usefulness of such a function (or procedure) lies in its side effects — it changes its environment (by mixing the suger and cream and whipping it, for instance…) Let’s look at an example: def hello(who): print “Hello,”, who hello(“world”) # Prints out “Hello, world” Printing out stuff is considered a side effect, and since that is all this function does, it is quite typical for a so-called procedure. But… It doesn’t really change its environment does it? How could it do that? Let’s try: # The *wrong* way of doing it age = 0 def setAge(a): age = a setAge(100) print age # Prints “0” What’s wrong here? The problem is that the function setAge creates it own local variable, also named age which is only seen inside setAge. How can we avoid that? We can use something called global variables. Note: Global variables are not used much in Python. They easily lead to bad structure, or what is called spaghetti code. I use them here to lead up to more complex techniques - please avoid them if you can. By telling the interpreter that a variable is global (done with a statement like global age) we effectively tell it to use the variable outside the function instead of creating a new local one. (So, it is global as opposed to local.) The program can then be rewritten like this: # The correct, but not-so-good way of doing it age = 0 def setAge(a): global age age = a setAge(100) print age # Prints “100” When you learn about objects (below), you’ll see that a more appropriate way of doing this would be to use an object with an age property and a setAge method. In the section on data structures, you will also see some better examples of functions that change their environment. Well — what about real functions, then? What is a function, really? Mathematical functions are like a kind of “machine” that gets some input and calculates a result. It will return the same result every time, when presented with the same input. For instance: def square(x): return x*x This is the same as the mathematical function f(x)=x2. It behaves like a nice function, in that it only relies on its input, and it does not change its environment in any way. So — I have outlined two ways of making functions: One type is more like a procedure, and doesn’t return a result; the other is more like a mathematical function and doesn’t do anything but returning a result (almost). Of course, it is possible to do something in between the two extremes, although when a function changes things, it should be clear that it does. You could signal this through its name, for instance by using only a noun for “pure” functions like square and an imperative for procedure-like functions like setAge. More Ingredients — data structures Well — you know a lot already: How to get input and give output, how to structure complicated algorithms (programs) and to perform arithmetic; and yet the best is still to come. What ingredients have we been using in our programs up until now? Numbers and strings. Right? Kinda boring… No let’s introduce a couple of other ingredients to make things a bit more exciting. Data structures are ingredients that structure data. (Surprise, surprise…) A single number doesn’t really have much structure, does it? But let’s say we want more numbers put together to a single ingredient — that would have some structure. For instance, we might want a list of numbers. That’s easy: [3,6,78,93] I mentioned lists in the section on loops, but didn’t really say much about them. Well — this is how you make them. Just list the elements, separated by commas and enclosed in brackets. Let us jump into an example that calculates primes (numbers divisible only by themselves or 1): # Calculate all the primes below 1000 # (Not the best way to do it, but…) result = [1] candidates = range(3,1000) base = 2 product = base while candidates: while product < 1000: if product in candidates: candidates.remove(product) product = product+base result.append(base) base = candidates[0] product = base del candidates[0] result.append(base) print result New things in this example… 1. The built-in function range actually returns a list that can be used like all other lists. (It includes the first index, but not the last.) 2. A list can be used as a logic variable. If it is not empty, then it is true — if it is empty, then it is false. Thus, while candidates means “while the list named candidates is not empty” or simply “while there are still candidates”. 3. You can write if someElement in someList to check if an element is in a list. 4. You can write someList.remove(someElement) to remove someElement from someList. 5. You can append an element to a list by using someList.append(something). Actually, you can use + too (as in someList = someList+[something]) but it is not as efficient. 6. You can get at an element of a list by giving its position as a number (where the first element, strangely, is element 0) in brackets after the name of the list. Thus someList[3] is the fourth element of the list someList. (More on this below.) 7. You can delete variables by using the keyword del. It can also be used (as here) to delete elements from a list. Thus del someList[0] deletes the first element of someList. If the list was [1,2,3] before the deletion, it would be [2,3] afterwards. Before going on to explaining the mysteries of indexing list elements, I will give a brief explanation of the example. This is a version of the ancient algorithm called “The Sieve of Erastothenes” (or something close to that). It considers a set (or in this case, a list) of candidate numbers, and then systematically removes the numbers known not to be primes. How do we know? Because they are products of two other numbers. We start with a list of candidates containing numbers [2..999] — we know that 1 is a prime (actually, it may or may not be, depending on who you ask), and we wanted all primes below 1000. (Actually, our list of candidates is [3..999], but 2 is also a candidate, since it is our first base). We also have a list called result which at all times contains the updated results so far. To begin with, this list contains only the number 1. We also have a variable called base. For each iteration (“round”) of the algorithm, we remove all numbers that are some multible of this base number (which is always the smallest of the candidates). After each iteration, we know that the smallest number left is a prime (since all the numbers that were products of the smaller ones are removed — get it?). Therefore, we add it to the result, set the new base to this number, and remove it from the candidate list (so we won’t process it again.) When the candidate list is empty, the result list will contain all the primes. Clever, huh? Things to think about: What is special with the first iteration? Here the base is 2, yet that too is removed in the “sieving”? Why? Why doesn’t that happen to the other bases? Can we be sure that product is always in the candidate list when we want to remove it? Why? Now — what next? Ah, yes… Indexing. And slicing. These are the ways to get at the individual elements of Python lists. You have already seen ordinary indexing in action. It is pretty straightforward. Actually, I have told you all you need to know about it, except for one thing: Negative indices count from the end of the list. So, someList[-1] is the last element of someList, someList[-2] is the element before that, and so on. Slicing, however, should be new to you. It is similar to indexing, except with slicing you can target an entire slice of the list, and not just a single element. How is it done? Like this: food = [“spam”,”spam”,”eggs”,”sausages”,”spam”] print food[2:4] # Prints “[‘eggs’, ‘sausages’]” More Abstraction — Objects and Object-Oriented Programming Now there’s a buzz-word if ever there was one: “Object-oriented programming.” As the section title suggests, object-oriented programming is just another way of abstracting away details. Procedures abstract simple statements into more complex operations by giving them a name. In OOP, we don’t just treat the operations this way, but objects. (Now, that must have been a big surprise, huh?) For instance, if we were to make a spam-cooking-program, instead of writing lots of procedures that dealt with the temperature, the time, the ingredients etc., we could lump it together into a spam-object. Or, perhaps we could have an oven-object and a clock-object too… Now, things like temperature would just be attributes of the spam-object, while the time could be read from the clock-object. And to make our program do something, we could teach our object some methods; for instance, the oven might know how to cook the spam etc. So — how do we do this in Python? Well we can’t just make an object directly. Instead of just making an oven, we make a recipe describing how ovens are. This recipe then describes a class of objects that we call ovens. A very simple oven class might be: class Oven: def insertSpam(self, spam): self.spam = spam def getSpam(self): return self.spam Now, does this look weird, or what? New things in this example… 1. Classes of objects are defined with the keyword class. 2. Class names usually start with capital letters, whereas functions and variables (as well as methods and attributes) start with lowercase letters. 3. Methods (i.e. the functions or operations that the objects know how to do) are defined in the normal way, but inside the class block. 4. All object methods should have a first parameter called self (or something similar…) The reason will (hopefully) become clear in a moment. 5. Attributes and methods of an object are accessed like this: mySpam.temperature = 2, or dilbert.be_nice(). I would guess that some things are still a bit unclear about the example. For instance, what is this self thing? And, now that we have an object recipe (i.e. class), how do we actually make an object? Let’s tackle the last point first. An object is created by calling the classname as if it were a function: myOven = Oven() myOven now contains an Oven object, usually called an instance of the class Oven. Let’s assume that we have made a class Spam as well; then we could do something like: mySpam = Spam() myOven.insertSpam(mySpam) myOven.spam would now contain mySpam. How come? Because, when we call one of the methods of an object, the first parameter, usually called self, always contains the object itself. (Clever, huh?) Thus, the line self.spam = spam sets the attribute spam of the current Oven object to the value of the parameter spam. Note that these are two different things, even though they are both called spam in this example. Answer to Exercise 3 Here is a very concise version of the algorithm: def euclid(a,b): while b: a,b = b,a % b return a References [1] Recipe for Fiesta Spam Salad taken from the Hormel Foods Digital Recipe Book
  12. Instant Hacking This is a short introduction to the art of programming, with examples written in the programming language Python. This page is not about breaking into other people’s computer systems etc. I’m not into that sort of thing, so please don’t email me about it. Note: To get the examples working properly, write the programs in a text file and then run that with the interpreter; do not try to run them directly in the interactive interpreter — not all of them will work. (Please don’t ask me on details on this. Check the documentation or send an email to help@python.org). The Environment To program in Python, you must have an interpreter installed. It exists for most platforms (including Macintosh, Unix and Windows). More information about this can be found on the Python web site. You also should have a text editor (like emacs, notepad or something similar). What is Programming? Programming a computer means giving it a set of instructions telling it what to do. A computer program in many ways resembles recipes, like the ones we use for cooking. For example [1]: Fiesta SPAM Salad Ingredients: Marinade: 1/4 cup lime juice 1/4 cup low-sodium soy sauce 1/4 cup water 1 tablespoon vegetable oil 3/4 teaspoon cumin 1/2 teaspoon oregano 1/4 teaspoon hot pepper sauce 2 cloves garlic, minced Salad: 1 (12-ounce) can SPAM Less Sodium luncheon meat, cut into strips 1 onion, sliced 1 bell pepper, cut in strips Lettuce 12 cherry tomatoes, halved Instructions: In jar with tight-fitting lid, combine all marinade ingredients; shake well. Place SPAM strips in plastic bag. Pour marinade over SPAM. Seal bag; marinate 30 minutes in refrigerator. Remove SPAM from bag; reserve 2 tablespoons marinade. Heat reserved marinade in large skillet. Add SPAM, onion, and green pepper. Cook 3 to 4 minutes or until SPAM is heated. Line 4 individual salad plates with lettuce. Spoon hot salad mixture over lettuce. Garnish with tomato halves. Serves 4. Of course, no computer would understand this… And most computers wouldn’t be able to make a salad even if they did understand the recipe. So what do we have to do to make this more computer-friendly? Well — basically two things. We have to (1) talk in a way that the computer can understand, and (2) talk about things that it can do something with. The first point means that we have to use a language — a programming language that we have an interpreter program for, and the second point means that we can’t expect the computer to make a salad — but we can expect it to add numbers, write things to the screen etc. Hello… There’s a tradition in programming tutorials to always begin with a program that prints “Hello, world!” to the screen. In Python, this is quite simple: print “Hello, world!” This is basically like the recipe above (although it is much shorter!). It tells the computer what to do: To print “Hello, world!”. Piece of cake. What if we would want it to do more stuff? print “Hello, world!” print “Goodbye, world!” Not much harder, was it? And not really very interesting… We want to be able to do something with the ingredients, just like in the spam salad. Well — what ingredients do we have? For one thing, we have strings of text, like “Hello, world!”, but we also have numbers. Say we wanted the computer to calculate the area of a rectangle for us. Then we could give it the following little recipe: # The Area of a Rectangle # Ingredients: width = 20 height = 30 # Instructions: area = width*height print area You can probably see the similarity (albeit slight) to the spam salad recipe. But how does it work? First of all, the lines beginning with # are called comments and are actually ignored by the computer. However, inserting small explanations like this can be important in making your programs more readable to humans. Now, the lines that look like foo = bar are called assignments. In the case of width = 20 we tell the computer that the width should be 20 from this point on. What does it mean that “the width is 20”? It means that a variable by the name “width” is created (or if it already exists, it is reused) and given the value 20. So, when we use the variable later, the computer knows its value. Thus, width*height is essentially the same as 20*30 which is calculated to be 600, which is then assigned to the variable by the name “area”. The final statement of the program prints out the value of the variable “area”, so what you see when you run this program is simply 600 Note: In some languages you have to tell the computer which variables you need at the beginning of the program (like the ingredients of the salad) — Python is smart enough to figure this out as it goes along. Feedback OK. Now you can perform simple, and even quite advanced calculations. For instance, you might want to make a program to calculate the area of a circle instead of a rectangle: radius = 30 print radius*radius*3.14 However, this is not significantly more interesting than the rectangle program. At least not in my opinion. It is somewhat inflexible. What if the circle we were looking at had a radius of 31? How would the computer know? It’s a bit like the part of the salad recipe that says: “Cook 3 to 4 minutes or until SPAM is heated.” To know when it is cooked, we have to check. We need feedback, or input. How does the computer know the radius of our circle? It too needs input… What we can do is to tell it to check the radius: radius = input(“What is the radius?”) print radius*radius*3.14 Now things are getting snazzy… input is something called a function. (You’ll learn to create your own in a while. input is a function that is built into the Python language.) Simply writing input won’t do much… You have to put a pair of parantheses at the end of it. So input() would work — it would simply wait for the user to enter the radius. The version above is perhaps a bit more user-friendly, though, since it prints out a question first. When we put something like the question-string “What is the radius?” between the parentheses of a function call it is called passing a parameter to the function. The thing (or things) in the parentheses is (or are) the parameter(s). In this case we pass a question as a parameter so that input knows what to print out before getting the answer from the user. But how does the answer get to the radius variable? The function input, when called, returns a value (like many other functions). You don’t have to use this value, but in our case, we want to. So, the following two statements have very different meanings: foo = input bar = input() foo now contains the input function itself (so it can actually be used like foo(“What is your age?”); this is called a dynamic function call) while bar contains whatever is typed in by the user. Flow Now we can write programs that perform simple actions (arithmetic and printing) and that can receive input from the user. This is useful, but we are still limited to so-called sequential execution of the commands, that is — they have to be executed in a fixed order. Most of the spam salad recipe is sequential or linear like that. But what if we wanted to tell the computer how to check on the cooked spam? If it is heated, then it should be removed from the oven — otherwise, it should be cooked for another minute or so. How do we express that? What we want to do, is to control the flow of the program. It can go in two directions — either take out the spam, or leave it in the oven. We can choose, and the condition is whether or not it is properly heated. This is called conditional execution. We can do it like this: temperature = input(“What is the temperature of the spam?”) if temperature > 50: print “The salad is properly cooked.” else: print “Cook the salad some more.” The meaning of this should be obvious: If the temperature is higher than 50 (centigrades), then print out a message telling the user that it is properly cooked, otherwise, tell the user to cook the salad some more. Note: The indentation is important in Python. Blocks in conditional execution (and loops and function definitions — see below) must be indented (and indented by the same amount of whitespace; a tab counts as 8 spaces) so that the interpreter can tell where they begin and end. It also makes the program more readable to humans. Let’s return to our area calculations. Can you see what this program does? # Area calculation program print “Welcome to the Area calculation program” print “–––––––––––––” print # Print out the menu: print “Please select a shape:” print “1 Rectangle” print “2 Circle” # Get the user’s choice: shape = input(“> “) # Calculate the area: if shape == 1: height = input(“Please enter the height: “) width = input(“Please enter the width: “) area = height*width print “The area is”, area else: radius = input(“Please enter the radius: “) area = 3.14*(radius**2) print “The area is”, area New things in this example: 1. print used all by iself prints out an empty line 2. == checks whether two things are equal, as opposed to =, which assigns the value on the right side to the variable on the left. This is an important distinction! 3. ** is Python’s power operator — thus the squared radius is written radius**2. 4. print can print out more than one thing. Just separate them with commas. (They will be separated by single spaces in the output.) The program is quite simple: It asks for a number, which tells it whether the user wants to calculate the area of a rectangle or a circle. Then, it uses an if-statement (conditional execution) to decide which block it should use for the area calculation. These two blocks are essentially the same as those used in the previous area examples. Notice how the comments make the code more readable. It has been said that the first commandment of programming is: “Thou shalt comment!” Anyway — it’s a nice habit to acquire. Exercise 1 Extend the program above to include area calculations on squares, where the user only has to enter the length of one side. There is one thing you need to know to do this: If you have more than two choices, you can write something like: if foo == 1: # Do something… elif foo == 2: # Do something else… elif foo == 3: # Do something completely different… else: # If all else fails… Here elif is a mysterious code which means “else if” :). So; if foo is one, then do something; otherwise, if foo is two, then do something else, etc. You might want to add other options to the programs too — like triangles or arbitrary polygons. It’s up to you.
  13. I thing the old one's colors are better :)
  14. That kind of topic has already been posted... Topic Locked
  15. (Because in the first post i wasn't allowed to write more,the rest is here.) 4.0 - Running Linux I bet you're glad to finish that installation! Now you're finally ready to run the system. If you decided to create a boot disk, insert that into the disk drive. If you decided to install LILO, just sit tight for now. Regardless of what you did, reset your computer. If you used LILO, you will get a prompt to load Linux or Windows. If you used a boot disk, the system will startup automatically. After the system starts up, the will get prompted for a user name and password. This will look different depending on how you configured it in the installation. If you chose to start the X Windows GUI automatically, the username and password screen will look like it does in Windows (well, sort of. X-Windows is much cooler, unless you're using some lame version of it or some lame window manager). If you chose not to load the X Windows interface at startup (like most advanced users will), you'll be presented with a text-based interface. The text-based interface (the command console) is much faster than the graphical system, but this also means you cannot view any graphics until you start X-Windows (this is a good time to mention that most people just call it X). Anyway, you can always run a command console from an X window (usually called an "XTerm", which stands for X Terminal). Anyway, the login screen will look pretty much the same regardless of whether you are using RedHat or Mandrake. If you're wondering what to type in the username box, that's easy. Your username is 'root' (remember?). The password is the one that you selected at installation. 5.0 - Using Linux 5.1 - Intro To The Console Even though you'll probably be able to do everything with ease using the X Windows GUI, there is still some stuff you should know. First off, don't rely on a GUI for everything! That is very important because you will learn a lot by using the console. The console is more powerful and can do a lot of things you would REALLY like if you'll just grab a good basic Unix book and start learning. After you do, you'll find yourself often opening an XTerm window to run some console commands which you cannot run from X. If you selected to start the GUI interface when Linux loads up, there are still lots of ways to get to the console. The console prompt should look somewhat like this (if you're logged in as root): [root@localhost.localdomian]# The first part identifies who you are, and the '#' is the actual prompt. Any almost and UNIX type system, the '#' means you are root. On non-root bash consoles (BASH - Bourne Again Shell. BASH is the most popular text-based shell. Confused? Don't worry, we'll get to that in a second) this will be replaced with a $. Anyway, you can change the prompt, but we won't get into that now. 5.11 - Shells You use a shell everytime you're in the Linux console. What a shell is, is the program that communicates between you and the Kernel (the kernel is the core of the system). Let's think of it as an interpreter for for two people who are trying to have a meeting, except they don't speak the same language. One speaks English and the speaks, oh let's say Hebrew (about half the members of Black Sun Research Facility (blacksun.box.sk if you don't know the URL yet. Also, if you havn't noticed, I'm a member of BSRF) are from Israel). To communicate with each other they need a guy who speaks both English and Hebrew. If the English guy wants to tell the Hebrew guy something, he tells it to the interpreter in English, and then the interpreter tells it to the other guy in Hebrew, and vice versa. Well anyway, getting back to the subject, this is the case with Linux. Your language is the Linux commands, and the Kernel speaks it's own very complex language. When you want to talk to the Kernel, you tell shell in your language, and the shell tells it to the Kernel in it's language. On any Linux system, there a few shells. Some of them are: ash bash bsh csh tcsh zsh The most popular and powerful shell is 'bash' (borne again shell). We won't go that much into shells, because you don't need to know that much about them just yet. 5.2 - Navigating The File System The most important thing to know when using the console is how to navigate the file system without a graphical program. The first thing to understand about this is that the bottom directory, the directory that everything else is a subdirectory of is '/'. It's like 'C:' in Windows. Ok, you start at the console and as a default you're either in your home directory (every user has a home directory which contains his personal configurations files). Now you want to navigate to another directory. But wait, you don't know any other directories! You'll a directory listing for this, right? To do this type 'ls' at the prompt. 'ls' is the equivlant to 'dir' in MS-DOS, and stands for list. You'll get a list of files and folders. To make the list a bit more readable, try ls -Fla. The -a shows files which start with a period (for example: .Xclients-default). The -l displays file permissions and displays everything in neat columns. The -F option adds a / after a directory and a * after an executable file. I also suggest using ls -Fla --color to let the system color-code different files (may not be available on some systems). Anyway, now that you what directories there are, you need to know how to get into them. Luckily, you use the same command as you you use in MS-DOS, the 'cd' (change directory) command. Let's say you're at the bottom directory, '/' and you want to get to '/root'. You simply type 'cd root'. There is no need to type 'cd /root', because you're already in '/'. Now let's say you want to get to '/root/bin'. This would be done by typing 'cd bin'. There is no need to type 'cd /root/bin' (the "full path" of the directory), since you're already in '/root'. Instead, you can use a "relative path", which is a path that is relative to the current directory you're in. Type pwd to find out where you are (pwd stands for print working directory). Now let's say you're in '/root/bin' and you want to get to '/usr'. You would type 'cd /usr'. This is to signify that the 'usr' directory is under '/', not '/root/bin', or even '/root'. Got it? Ok, just one more thing. If you're in a subdirectory, and you want to get to the top directory, just type 'cd ..'. Let's say you're in '/root/bin', and you want to get to '/root'. You could just type 'cd /root', but hey, '/root' is five characters! If you want to save precious miliseconds, just type 'cd ..', since '/root' is the directory in which '/root/bin' is a subdirectory of. So in other words, . is the current directory, .. is one directory above, ... is two directories above etc'. 5.3 - Basic File and Directory Commands There are lots of file and directory commands in Linux, but we'll start with directory commands because they're easier. First off, you have 'mkdir'. 'mkdir' stands for make directory and the context is: mkdir the_directory_you_want_to_make Some rulse apply. If you're '/', it will make the new directory under '/'. If you're in '/usr', it will make the directory under '/usr'. Of course though, if you're in '/' and you want to make a directory called 'stuff' under '/usr', you would simply type '/usr/stuff'. The next command is the 'rm' command. It works with files and direcotires and is used to delete some, it stands for 'remove'. If you want to remove a file called 'this.gif', you would go to the directory where that file is and type 'rm this.gif'. Or let's say again you're in '/' and 'this.gif' is in '/usr', you would type 'rm /usr/this.gif'. It works the same way with a directory. Next are the 'cp' and 'mv' commands. They're both relativley simple, but we'll start with 'cp'. 'cp' stands for copy, and is used to copy a file from directory to another. The context is: cp /directory_where_it_is/filename /directory_where_you_want_to_copy_it Of course if you're already in the directory where the file is, all you need to type is: cp filename /directory_where_you_want_to_copy_it 'mv' works the exact same way, except it moves the file instead of copying it. This means it deletes in from the original directory and puts it in the new one. 5.4 - Finding and Viewing Commands To find a file, oyu use the 'find' command. It then followed by the directory where you want to start looking, then the '-name' arguement to say that you're searching for a filename. Next you type the name of the file. Let's say you're looking for the 'this.gif' in the '/usr' directory, the context would look like this: find /usr -name this.gif The find command doesn't stop at filenames, it can also search a file for a paticular string of text. It has the same context as the find file command except you put quotes and asteriks around the string of text. So if you wanted to search the '/usr' directory for a file containing the string 'hello', you would type find /usr -name "*hello*" Ok, once you find a file, you want to view it right? Well, you could open the file with a text editor, but we haven't learned to use tetx editors yet, and anyway if the file you want to view is important you might accidently change it and save it using a text editor. That's what the 'cat' command is for. Let's say you want to view a file called 'stuff.txt' in '/root'. You would navigate to the '/root' directory and type 'cat stuff.txt'. Or from any directory, type 'cat /root/stuff.txt' -= For more commands, buy a good basic Unix book =- 5.5 - linuxconf There are lots of commands in Linux for configuring everything to user passwords, networks, and the message that comes up when you start Linux. With so many things to configure, luckily there is one program that does it all. Just type 'linuxconf' at the command prompt, and you'll be brought to the Linux Configuration program. 5.6 - Mounting 5.61 - Mounting Drives In Linux, drives not only have to be physically mounted to the computer, but mounted in software too. In the KDE and GNOME GUIs, you can easily mount a CD-ROM or disk drive by clicking on the 'CD-ROM' or 'Disk Drive' icons on the desktop. 5.62 - How to mount Remember earlier in this tutorial when we went over how a hard drive partition is almost like a separate hard drive? Well, just like a separate drive, partitions also have to be mounted. The main use in this is being able to mount Windows partition and access Windows files in Linux. Obviously, Windows software will not run under Linux but there is still a use for accessing Windows files in Linux. Let's say you can't use the internet in Linux. You ISP only allows to dialup with software and they don't make it for Linux, you're not used to Linux yet so you don't want to use the net in it yet. This is a down point, but it doesn't mean you can't download Linux files to use. All you have to do is download the files in Windows and access them in Linux. To mount a windows partition in Linux, yhe first thing you must do is create a directory in Linux where you will mount the windows partition to reside. Go into file manager (it should be under utilities no matter what distribution you're using) and create a new directory under '/'. Call anything, I suggest calling it 'windows'. Now exit file manager and go into 'terminal' (should also be under utilities). Terminal will give you a command prompt just like MS-DOS. This is what you would have to do everything from if there were no X Windows GUI. The command to use is simply enough- 'mount'. But don't type it just yet, you need to give the system more info. The full command is mount -t vfat /dev/xxxx /yyyyyyy (yes there is a space between 'xxxx' and '/') Or mount -t vfat32 /dev/xxxx /yyyyyyy in case this is a FAT32 partition. Where 'yyyyyyy' is the directory you just created, and 'xxxx' is the device name of the partition where Windows resides. It is usually hda1 or something. There, now just go into file manager and click on the directory you created and you will have all the files that are on your windows partition. When you're done, don't forget to unmount the drive by typing: umount /dev/xxxx /yyyyyyy Each time you want to access your windows files, just mount the partition (unless they're set for automount. Edit /etc/fstab, find the line that represents your Windows partition and look for a place with says noauto. If you find the word noauto, change it into defaults. If you don't, your Windows partition will probably get automounted whenever you boot-up Linux). When you're done with them, just unmount the partition. 5.7 - Runlevels While Windows is booting, have you ever pressed the F8 key? Well, if you have, you're probably familiar with a screen that pops up giving you a list of ways you can load Windows. There's safe mode, command prompt, step-by-step confirmation, etc. Linux has something just like that, and they're called 'runlevels'. There are six runlevels in all, and some are pretty much the same. A runlevel is a list of commands to load-up as soon as you start up Linux (there's a mini-tutorial about runlevels at blacksun.box.sk/byteme.html). Your default runlevel is probably 5. If you configured the GUI to start up when you boot the system, and if your default runlevel is 5, then that is the runlevel configured to boot the GUI when it starts up...simple, right? Well anyway, if you use linuxconf to change your default runlevel to 2 or 3 or something, then you change it so that the GUI won't start as soon as the system boots....all without touching the actual runlevel. When you want to change it back, just use linuxconf to set the default runlevel back to 5. Now let's say you only want to load it without the GUI coming up once. Instead of having to change the configuration in linuxconf, and then changing it back, you can load Linux into another runlevel. Suppose You want to load runlevel 2...not for any paticular reason, just because it's not configured to load the GUI when it boots up, and well, you like the number 2. To do this, as soon LILO comes up (whether it's on your computer, or your boot disk), you have the option to type something next to 'boot:'. Just type 'linux x'. 'x' refers to the number of the runlevel, in this case the number 2, so you type 'linux 2', and press enter. This will load Linux without loading the GUI. When you restart Linux, it will load the default runlevel again. For an interesting runlevels-related local hack, read the Byte-Me mini-tutorial about runlevels at blacksun.box.sk/byteme.html. You are now officially a Linux user. Check out www.linuxlinks.com for links to some great Linux sites. The best way to learn about Linux is by messing around with it. In an hour of playing with Linux you can learn a
  16. Linux- sometimes referred to by the press as 'Windows NT's worst enemy'. Wired Magazine once called it 'The greatest story never told'. This is a perfect definition because the story behind Linux is indeed a great one, yet it is unknown to so many people. Let's start at the beginning. Back when 'Stayin' Alive' was still topping the charts, and Microsoft was a spec in the world of computers, AT&T produced a multi-user operating system and labeled it 'UNIX'. Throughout the years, UNIX caught on and many different versions of it began to come out. A popular one, called 'Minix' (mini-UNIX) was available for use at The University of Helsinki in Finland. A student at the University named Linus Torvalds believed he could create an operating system superior to Minix. In 1991 he started his new operating system as a side project, but it soon developed into a full-time hobby until 1994 when the first official version of the operating system was released. You're probably now saying 'so what's the big deal about Linux? Isn't it just another operating system?' Absolutely not! First of all, Linux is released under something called 'open source license'. Open source is really more of an idea than a thing. Linux is released with all the source code and files that it was made with. This means a few things. Anyone who is good at programming can mess with the Linux code and release his own version of it. This also means that even though if you buy Linux in a store it will cost money, you're not paying for the actual Linux itself. Your money goes to the price of packaging, the extra software that comes with the operating system, and technical support. The second, and most important reason that Linux is a big deal is because it's a much more stable operating system than Windows. It runs on any system; even bottom of the line 386's from before Linux even came out. Programs running under Linux almost never crash, and in the off chance that one does because of bad programming by the program author, it will not take the operating system down with it. Another important reason Linux is good is that it is secure. It is much harder to bring down by a hacker than Windows is (for further reading, read the 'Basic Unix Security Guide' by R a v e N at blacksun.box.sk). This is just an extremely short list of the reasons why Linux is so great. For further reading check out www.linux.org This tutorial is for Windows users who want to migrate to Linux. This is written for Redhat or Mandrake Linux (the two most easy-to-install and user-friendly Linux distributions), but the information here will most probably help you with whatever distribution you are using. The only problem with this is that Mandrake and RedHat are relativley simple to install, and some other distrobutions are much more complex. I highly suggest you buy Linux-Mandrake rather than RedHat. Mainly because it is cheaper and comes with more software, but as you read through this tutorial, you'll see more reasons why I recommend Mandrake. The first thing you're going to have to do with your new operating system is install it- but you can't do that so quickly. 2.0 - Preparation If you already have Microsoft Windows on your system and you want it to co-exist with Linux, you are going to have to create another hard drive partition. What a hard drive partition is a totally separate part of a hard drive. If two hard drive partitions weren't physically part of the same disc, they would be two different hard drives. Anyway, the reason for this is that Windows and Linux are totally different in the way they access hard drives and handle files. If they are using each other's hard drive space the two operating systems can conflict and cause major problems for your computer. Well, as I was saying, you need to create a hard drive partition reserved for Linux. There are MS-DOS programs that do this, but they are "lethal" partition making programs. By this I mean that while making a new partition, they can destroy or at least corrupt files on another partition. If you want to make a partition for Linux, without killing your Windows files you need a "non-lethal" partition program. If you get Linux-Mandrake, a "non-lethal" partition program is included with it (this is just one of the reasons why I recommend Mandrake over RedHat). Well with all this talk of partitions and hard drives, you must be wondering roughly how much hard drive space you'll need for Linux. If you want the complete system with everything, you'll need about 1.5 gigabyte+ hard drive space. However it is possible to productively run a full Linux distribution (there are "miniature" Linux distributions that range from around 2 to 35 megabytes, and there's also Trinux, which runs from two 1.44MB floppy disks! Get it from www.trinux.org) to with as little as 150 megabytes. Trust me, you don't want EVERYTHING. Linux comes with tons of software you'll probably won't need. For example: Linux comes with a variety of network servers - a web server, a Sendmail server, a telnet server, an FTP server etc'. If you choose not to install something and then regret, you can still get it later off the original installation CD. So anyway, if you have sufficient hard drive space, and a "non-lethal" partition program, you're ready to proceed to the next step: installation. ***Even if you're using a "non-lethal" partition program, I suggest you backup your Windows files just in case something goes wrong.*** 3.0 - Installation Now that your computer is ready for Linux, you're ready to install it. When you bought the software, it probably came with a few CD's and a disk. The disk is boot disk for the Linux installation program. You pop in the disk, reset your computer, the installation program begins, and you're ready to install Linux. The only thing is that the installation program will take a while to load since it's from a disk. **The stuff on the disk is probably just a duplicate of some of the stuff on the first CD. If your computer is capable of booting from a CD (and most newer ones are, otherwise, check your manual) then instead of putting the disk in your computer then rebooting, put in the first CD as it will load much quicker. Of course, you'll need to mess with your BIOS configurations first, but that's no big deal. Hit del when your computer boots up (after it tells you how much RAM you have) and mess around with it until you can find out how to make your computer attempt to boot from your CD drive first. This differs from different BIOS systems.** 3.1 - Ok..You're finally ready to install Linux. The first few questions the install program asks you are self explanatory, just things like your language and stuff. One thing you might get stumped on is when you are prompted on whether you have any SCSI adapters or not. An SCSI adapter can be anything such as a mouse, printer, scanner, etc. It all depends if you have an SCSI controller. Chances are, you don't have any SCSIs, but check your manual to be sure. Also, if you are completely sure that your copy of Microsoft Windows is properly-configured, you can quit the installation program at any time, return to Windows, run control panel, click on system and find out all the information you'll need about your system's hardware. 3.2 - More Partition Stuff The next thing you might have trouble with is a dialog box that appears asking you some questions about your hard drive partitions. The name of the dialog box should 'Disk Setup'. There should be three buttons on the bottom of the box. One labeled 'Disk Druid', another labeled 'fdisk', and the last is the back button. Since you already set up your partitions, select 'Disk Druid'. If you originally only had one partition with windows, then the top of the screen should look something like this: Mount Point Device Requested Actual Type hda1 ??MB ??MB Win95 hda2 ??MB ??MB Linux Swap hda3 ??MB ??MB Linux Native Mount point should be blank. 'Device' is the name of the partition 'Requested' is the amount of hard drive space you wanted for the partition 'Actual' is the amount of hard drive space that is really in the partition 'Type' is what's in the partition **The 'requested' and 'actual' sections for the 'Linux Swap" type should be the amount of RAM you have.** **It looks confusing, but in reality if it is simple. Don't worry if your screen doesn't look exactly like my diagram, it probably won't.** What you should do now is select the 'Linux Native' section (by pressing tab to get to that part of the screen, then using the arrow keys) and then press tab again until the 'edit' button is highlighted. Pressing spacebar will bring up another dialog box. In the space provided, put a slash (/) then press OK. Now you're back at the main screen. Press tab to get to OK, and then press spacebar. **what you're actually doing here is telling the computer to put the root directory, signified by the slash, in the Linux Native partition. The root directory '/', is similar to 'C:' in DOS/Windows.** Next you come to a screen asking which partitions to format. Select the one that 'Linux Native' is in. You should select the '/dev/xxxx/' partition where 'xxxx' is the name of the device that the Linux Native partition is under. This is where you put the '/' on the last screen. If the Linux Native partition device was hda3 then choose '/dev/hda3', if it was hda6, then choose '/dev/hda6', you get the point. **IT IS VERY IMPORTANT THAT YOU DO NOT SELECT THE WRONG PARTITION TO FORMART!** 3.3 - Selecting What to Install Suppose you had three hard drives on Windows - c:, d: and e:, and you want to install Linux on d:. Windows assigns the letter c to the first hard drive it finds that has a DOS/Windows file partition, d to the second DOS/Windows-compatible hard drive etc', so this might help you out determining which device to choose. Also, if you turn d: into the Linux hard drive, it will disappear from DOS/Windows, and e: will turn into d:. You're not finished yet, but take a sigh of relief, the hardest part is over. Next comes the screen asking which packages to install. Some of the most important ones are selected already. If you have a lot of hard drive space, select all the other packages. Otherwise, just select the others that you think are important. Definitely select 'KDE' and 'GNOME'. Those are window manager programs for the X-Windows system (a GUI - Graphical User Interface), and we'll deal with them later. Anyway, newer versions always come with new software and/or updates for old software. Press OK and the Linux installation begins! 3.4 - Misc. Configurations After everything has been installed, you are prompted for more things. The first should be what resolution your monitor is. Most people would like to use the same resolution they use on Windows, so if you don't know which resolution you were using until now, switch back to Windows, right-click on your desktop area, click properties and find the settings tab. You should see your current resolution there. This would probably be the same resolution you would want to use on Windows. If you want a higher resolution, consult your monitor's manual to find out how high you can go. Next is the mouse configuration. If your mouse is not on the list, select 'Generic PS/2 Mouse'. There are more such as clock set and time zone but those are self-explanatory. After this, comes the services screen. These are the things that will startup when you run Linux. Then it will prompt you for if you want the X-Windows interface to run when you start Linux. If you are a Linux newbie (and you probably are, unless you weren't reading this guide), I suggest you do this. X windows is the GUI system, as explained before. The last configuration is the printer. This is self-explanatory. 3.5 - Configuring Users Ok...you're almost done; the configurations are pretty much finished. Now you will be prompted to create a password for the root operator. Even though it is still very popular on single home users, Linux is a multi-user operating system. Even if you'll be the only person using your computer, having a multi-user system is quite benefical. For example: you can use a less-privileged user to prevent yourself from doing stupid things and messing things up. You can run sensitive software which can be broken to (say, some sort of a server. For example: a Sendmail server for outgoing mail if you're planning to let people sent mail from your machine, or a web server if you want to serve a website off your computer) as a less-privileged user, so if someone will manage to exploit some hole in this software, he will have very limited privileges (up to what the program needs to run properly) and he won't be able to do much, or nothing at all in most cases (he won't have read access to password files, he won't have write access to the website's files so he won't be able to alter them etc'). On any UNIX-based system (and there are many) the main user is called 'root'. The root has supreme power over the system and supreme power over all the other users. In fact, he has unlimited power (unless he or another root-privileged user chooses to impose access limits, but root-privileged users can always restore their rights to the fullest). My root password is a particularly simple one. Mainly because I am the only one who uses Linux on my computer (and besides that I trust my own family!) and that my Linux system is not connected to the Internet (so hackers [or crackers I should say] would have no way to get into my system). Make your password anything not to complicated that you'll forget it, but something that is very hard to guess. After you're done making a password for the root user, you're prompted to create an unprivileged, or ordinary user account. You make the user name, credentials, and password. It may seem pointless at first to create another user- especially an unprivileged one if you are the only one who is going to be using Linux. However there is a big advantage to it. As a root user, you can do anything to the system, including seriously messing it up. Nothing will stop you because you are root. An ordinary user account is like security so if you mess up, the system will stop you. 3.6 - Booting Configurations Next you are asked if you want to create a boot disk. I strongly recommend this because it will put the Linux boot stuff on the disk, not your computer. If you put the Linux boot stuff on a computer with windows, it may conflict with the windows boot stuff in case you ever reinstall Windows (go to blacksun.box.sk/byteme.html and read #18 for a good example). The Linux 'boot stuff' I'm talking about is a program called 'LILO'. That's short for 'Linux Loader'. Anyway LILO installs itself to the boot sector of the computer. The problem is that Windows also installs stuff to the boot sector. LILO can install over Windows and let you choose to either boot up Linux or Windows whenever you start up your computer. If you choose Windows, it'll use Windows' "boot stuff". Anyway, in my opinion, when the install program asks you to create a boot disk, click Ok, then follow the directions to create a boot disk. Oh yeah, by the way, when you make a boot disk, it puts LILO on that disk. When it asks you to install LILO, just press Skip (unless you want to install LILO, which most users will). Congratulations! You're done installing Linux! When the installation program ends, take the installation boot disk out of the drive. If you booted the installation from CD, don't forget to take that out too.
  17. Κράσαρ' ο σέρβερ, μάνα μου Πέσαν όλα τα fora βλαστήμησ' ο συντηρητής κι οι bloggers τάδαν όλα Όμως τι φταίει ο δυστυχής πούχε τον Gates πατέρα; Aς βάζαν Linux σταθερό να τρέχει νύχτα μέρα Τώρα τ' αρχεία χάθηκαν πάνε, τα πήρε ο διάλος κι ας τρέχουνε προγράμματα να δουν αν φταίει άλλος Πάνε και τα template μας τα πολυπαινεμένα αντίο και στα κείμενα τα δύσκολα γραμμένα Γιατί καλό ?ναι το backup όλοι πλέον το μάθαν κι αν τόξεραν νωρίτερα ... κάποτε θα το κάναν! Αχός βαρύς ακούγεται, πολύ καντίλι πέφτει μανα μ' ο server κράσαρε κι άλλο πια δεν αντέχει Τα monitor εσβήσανε Οι δίσκοι σταματήσαν Ολα τα sites πέσανε και τα ρολά τα κλείσαν Μάνα ο σέρβερ κράσαρε, και δεν το λέω για αστείο, τον έβλεπα και έλιωνα, στα ράφια του Πλαισίου. Μάνα ο σερβερ κράσαρε κράσαρε κι η ζωή μας, παν' τα ωραία mp3, πάει η δικτύωσή μας Μανούλα μου σου το' χα πει μην παίζουμε με την ΔΕΗ, αν είχαμε ένα UPS, θα ήταν όλα σαν εψές. Σύρε admin μου αψηλέ, Σύρε admin κιμπάρη, Να δεις σαν τι εγίνηκε Και τούτη η μπόρα εφάνη Κινάνε δυο τεχνικοί Με τον admin αντάμα Να παν' να φτιάξουν τη ζημιά Να κάμουνε το θάμα Η μέρα έφυγε βαριά Στου server το κιβούρι Μας μες στην άγρια νυχτιά Εφάνη κελεπούρι Ο server μανα μ' φτιάχτηκε Ο server δεν κρασάρει Ο sysadmin εχάρηκε Το ίδιο και οι κουμπάροι (;;; )
  18. [-Introduction-] Netcat is a windows/unix network tool. Known as the tcp/ip "Swiss Army Knife". With Netcat it is possible to listen on a port and wait for incoming TCP/UDP connections and set a connection timeout in seconds. It is also possible to set up netcat to answer telnet connections also, so that people who don´t have netcat can use any telnet client to connect. You can even scan for open ports with this nice little tool, among some other things. Read the full article in the attached file. ps: Replaced txt with RTF version as it was messed up when viewed in the webbrowser Link to rapidshare uploaded tut. : http://rapidshare.com/files/31924867/NC_Hack.rtf.html
  19. Port Scanner Netcat can be a port scanner. It does not have as many features as say nmap, but if you just want to see what ports are open on a given machine, you can simply do: nc -v -w 1 localhost -z 1-3000 The command above will scan all the ports in the range 1-3000 on localhost. File Transfer Let's say you want to transfer a big zip file from machine A to machine B but neither one has FTP, and using email or IM is out of the question due to file size, or other restrictions. What do you do? You can use netcat as a makeshift file transfer software. On machine B do the following, where 1337 is some unused port on which you want to send the file: nc -lp 1337 > file.zip Assuming that the IP of machine B is 10.48.2.40 go to machine A and do: nc -w 1 10.48.2.40 1337 < file.zip That's it. The file will be magically transfered over the network socket. Chat Server Have you even needed an improvised one-on-one chat? Netcat can do that too. You simply start listening to connections on some port like this: nc -lp 1337 Then on another machine simply connect to that port: nc 10.48.2.40 1337 Now start typing on either machine. When you press enter, the line will immediately show up on the other machine. Telnet Server Nectat can also be used to set up a telnet server in a matter of seconds. You can specify the shell (or for that matter any executable) you want netcat to run at a successful connection with the -e parameter: nc -lp -e /bin/bash On windows you can use: nc -lp -e cmd.exe Then on a client machine simply connect to port 1337 and you will get full access to the shell, with the permissions of the user who ran nc on the server. Spoofing HTTP Headers You can use netcat to connect to a server using completely spoofed headers. You can actually type out your user agent, referrer and etc. It's useful when you want to generate bunch of hits that can be easily found in the logs or something like that: nc google.com 80 GET / HTTP/1.1 Host: google.com User-Agent: NOT-YOUR-BUSINESS Referrer: YOUR-MOM.COM Note that your request won't be sent until you generate a blank line. So hit return twice when your are done typing. You will get a response of headers and HTML streaming down your screen: HTTP/1.1 200 OK Cache-Control: private Content-Type: text/html; charset=ISO-8859-1 Set-Cookie: PREF=ID=79f8f28c854d90ec:TM=1186369443:LM=1186369443:S=UIiTvi68MtmbcmGl; expires=Sun, 1 -Jan-2038 19:14:07 GMT; path=/; domain=.google.com Server: GWS/2.1 Transfer-Encoding: chunked Date: Mon, 06 Aug 2007 03:04:03 GMT 738 I deleted the HTML that followed the response - but you get the idea. It is also a good way of looking at headers. Some sites have nice surprises there (like slashdot's X-Bender and X-Fry headers). Seriously, check them out! Web Server I think this is my favorite trick. Did you ever need to set up simple makeshift webserver that would serve a single page? I know I did. In the past when my web server at work melted down, I set up laptop with this simple script: while true; do nc -l -p 80 -q 1 < error.html; done The error.html page was just a very simple error message notifying our users about the outage, and giving them an estimate of when it would be fixed. It took me 3 minutes to set up, and probably saved us many angry support calls. Cloning Hard Drive Partitions Over the Network This trick was submitted by Craig in the comments. On a system you want to clone do: dd if=/dev/sda | nc 192.168.0.1 9000 Where 9000 is some random port. On the receiving side di: nc -l -p 9000 | dd of=/dev/sda Of course you need to have the cloned partitions unmounted on both systems. So if you are cloning / you will have to boot from a live distro like Knoppix. Note that you can use this technique to clone NTFS partitions as well - just need to use a live Linux distro on both sides. Summary Despite being able to do all that netcat still conforms to the Unix philosophy of doing one thing, and doing it well. Netcat was designed for a single purpose - to read and write data packets over network sockets. And because of it's singular purpose it can be used in such a myriad of ways. It is ironic, but it is of ten the case that the more features you add to your application, the more specialized it gets. And of course, GUI is the ultimate functionality killer. If netcat had a GUI I doubt it would be half as useful as it is right now. Source: http://www.terminally-incoherent.com/blog/2007/08/07/few-useful-netcat-tricks/
  20. Proxy finder is the best way to find proxys 8). It can find 10000 proxys in 2 minutes....you can find it on http://www.proxy-tool.com/
×
×
  • Create New...