Linuxin perusteet

Linux is inspired by the Unix operating system which first appeared in 1969, and has been in continous use and development ever since. Many of the design conventions behind Unix also exist in Linux and are central to understanding the basics of the system.

Unix was primarily oriented towards the command line interface, and that legacy is carried on in Linux. Thus, the graphical user interface with its windows, icons and menus are built on top of a basic command line interface. Furthermore, this means that the Linux file system is structured to be easily manageable and accessible from the command line.

Hakemistot ja Tiedostojärjestelmät

Linux ja Unix tiedostojärjestelmät ovat järjestetty hierarkiseen, puumaiseen rakenteeseen. Korkein taso järjestelmässä on / tai juuri (root) - hakemisto. Unix ja Linux - filosofiassa, kaikki ovat kansioita, mukaanlukien kovalevyt, osiot ja siirrettävät sekä irroitettavat levyt. Tämä tarkoittaa että kaikki muut tiedostot ja kansiot (mukaanlukien toiset levyt ja osiot) ovat juurikansion alla.

Esimerkiksi, /home/matias/juustot.odt näyttää koko polun juustot.odt-tiedostoon, joka sijaitsee matias - hakemistossa, joka on home - hakemistossa, joka taas vuorostaan on juurihakemistossa (/)

Juurihakemiston (/) alapuolella on sarja tärkeitä järjestelmähakemistoja, jotka ovat yhteisiä useimmissa Linux - jakeluversioissa. Seuraava on lista yleisistä hakemistoista jotka ovat heti juurihakemiston (/) alla:

  • /bin - tärkeät binäärisovellukset

  • /boot - käynnistyksen asetustiedostot

  • /dev - laitetiedostot

  • /etc - asetustiedostoja, käynnistysskriptejä ym.

  • /home - paikalliset käyttäjienkoti kansiot

  • /lib - järjestelmäkirjastot

  • /lost+found - provides a lost+found system for files that exist under the root (/) directory

  • /media - liitetyt (käyttövalmiit) siirrettävät mediat kuten CD:t, digitaalikamerat, jne.

  • /mnt - järjestelmään liitetyt tiedostojärjestelmät

  • /opt - provides a location for optional applications to be installed

  • /proc - special dynamic directory that maintains information about the state of the system, including currently running processes

  • /root - root user home directory, pronounced 'slash-root'

  • /sbin - tärkeät järjestelmäbinäärit

  • /sys - järjestelmätiedostot

  • /tmp - väliaikaistiedostot

  • /usr - ohjelmat ja tiedostot, jotka ovat käytettävissä jokaisella käyttäjällä

  • /var - muuttuvia tiedostoja, kuten lokeja ja tietokantoja

Oikeudet

Linux-järjestelmän kaikille tiedostoille on määritelty käyttöoikeudet, joiden mukaisesti eri käyttäjät saavat lukea, muokata tai suorittaa tiedostoja. Pääkäyttäjällä "root" on oikeudet kaikkiin tiedostoihin. Jokaiseen tiedostoon liittyy tieto sen omistajasta ja käyttäjäryhmästä.

Jokainen tiedosto turvataan seuraavalla kolmella käyttöoikeusryhmällä, tärkeysjärjestyksessä:

  • käyttäjä

    tiedoston omistaja

  • ryhmä

    tiedostoon liitetty käyttäjäryhmä

  • muu

    kaikki muut käyttäjät

Jokaisen käyttöoikeusryhmän sisällä ovat varsinaiset oikeudet. Oikeudet sekä niiden vaikutukset tiedostoihin ja kansioihin on lueteltu alla:

  • luku

    tiedostoja voidaan näyttää/avata

    kansion sisältö voidaan näyttää

  • kirjoitus

    tiedostoja voi muokata tai poistaa

    kansion sisältöä voidaan muokata

  • suoritus

    suoritettavat tiedostot ovat ohjelmia

    hakemistoihin voidaan siirtyä

To view and edit the permissions on files and directories, open the Applications->Accessories->Home Folder and right-click on a file or directory. Then select Properties. The permissions exist under the Permissions tab and allow for the editing of all permission levels, if you are the owner of the file.

Oppiaksesi lisää tiedostojen oikeuksista, lue file permissions page Ubuntu Wikistä.

Päätteet

Komentorivillä työskentely ei ole erityisen vaikeaa - komentorivi on vain ohjelma muiden joukossa. Suurin osa Linuxilla työskentelystä voidaan hoitaa komentorivillä. Vaikka paljon voidaankin tehdä graafisista ohjelmista käsin, toisinaan tarvitaan komentoriviohjelmien toimintoja.

The Terminal is located in Applications->Terminal . The terminal is often called the command prompt or the shell. In days gone by, this was the way the user interacted with the computer, however Linux users have found that the use of the shell can be quicker than a graphical method and still holds some merit today. Here you will learn how to use the terminal.

The original use of the terminal was a file browser and indeed it is still used as a file browser, in the event of the graphical environment failing. You can use the terminal as a file browser to navigate your files and undo the changes that have been made.

Yleiset komennot

Katso Kansiot: - ls

Komento ls (LiSt) listaa tiedostot erivärisillä teksteillä.

Tee kansioita: - mkdir (kansion nimi)

Komento mkdir (MaKeDIRectory) luo hakemiston.

Vaihda kansiota: - cd (/kansion/polku)

Komento cd (ChangeDirectory) vaihtaa nykyisestä hakemistosta mihin tahansa määrittelemääsi hakemistoon.

Kopioi tiedostot/kansiot: - cp (tiedoston tai kansion nimi) (kansio minne kopioidaan tai korvattava tiedosto)

Komento cp (CoPy) kopioi määrittelemäsi tiedostot. Komento cp -r kopioi määrittelemäsi kansion.

Poista tiedostot/kansiot: - rm (tiedoston tai kansion nimi)

Komento rm (ReMove) poistaa tiedoston. Komento rm -rf poistaa hakemiston.

Uudelleennimeä tiedostoja/Hakemistoja: - mv (tiedoston tai hakemiston nimi)

Komento mv (MoVe) uudelleennimeää tai siirtää tiedoston tai hakemiston.

Etsi tiedostoja/hakemistoja: - locate (tiedoston tai hakemiston nimi)

Komento locate ('paikallista') etsii määrittelemääsi tiedostonnimeä tietokoneesta. Komento käyttää tiedostoista luotua indeksiä toimiakseen nopeasti. Päivittääksesi tämän indeksin sinun tulee suorittaa komento updatedb. Tämä komento ajetaan automaattisesti päivittäin, jos jätät tietokoneesi päälle. Komento tarvitsee suorittamiseen järjestelmänvalvojan oikeuksia (katso “Root Ja Sudo”).

Tiedostoja löytääksesi voit käyttää myös niin sanottuja 'jokerimerkkejä', kuten "*" (kaikille tiedostoille) tai "?" (yhdelle merkille).

Perusteellisempi perehdytys Linuxin komentoriviin löytyy Ubuntu wikistä: command line introduction

Tekstin muokkaaminen

All of the configurations and settings in Linux are saved in text files. Even though you most often can edit configurations through the graphical interface, you may occasionally have to edit them by hand. Mousepad is the default Xubuntu text editor, which you can launch by clicking Applications->Accessories->Mousepad on the desktop menu system.

At times in this guide, Mousepad is run from the command line using gksudo, which runs Mousepad with administrative privileges, in order to modify configuration files.

If you need to use a text editor from the command line, you can use nano, which is a simple to use text editor. When running it from the command line, always use the following command, which ensures that the editor will not introduce line breaks:

nano -w

Lisää tietoa nanon käytöstä löydät Wiki-oppaasta.

There are also quite a few other terminal-based editors available in Ubuntu, popular ones include VIM and Emacs (the pros and cons of each are cause for much friendly debate within the Linux community). These are often more complex to use than nano, but are also more powerful.

Root Ja Sudo

The root user in GNU/Linux is the user which has administrative access to your system. Normal users do not have this access for security reasons. However, Ubuntu does not include the root user. Instead, administrative access is given to individual users, who may use the "sudo" application to perform administrative tasks. The first user account you created on your system during installation will, by default, have access to sudo. You can restrict and enable sudo access to users with the Users and Groups application (see “Managing Users and Groups” for more information).

Kun ajat ohjelman, joka tarvitsee pääkäyttäjäoikeudet, kysyy sudo sinulta salasanaasi. Näin varmistetaan, ettei haittaohjelmat pääse vahingoittamaan järjestelmääsi ja tämä myös muistuttaa sinua, että olet tekemässä järjestelmänhallinnan tehtäviä ja tämä edellyttää varovaisuutta!

Käyttääksesi sudoa komentorivillä, kirjoita "sudo" ennen komentoa minkä komennat. Sudo kysyy sinulta salasanaasi.

Salasanasi pysyy sudon muistissa ennalta määritetyn ajan. Näin käyttäjä pystyy suorittamaan useita ylläpitotoimia joutumatta kirjoittamaan salasanaansa jokaisella kerralla.

[Huomaa]

Ole varovainen, kun teet pääkäyttäjätehtäviä, koska voit vahingoittaa järjestelmääsi!

Some other tips to using sudo include:

  • Käyttääksesi "rootin" päätettä, käske komentorivillä "sudo -i".

  • Kaikki Ubuntun vakiot graafiset asetustenteko-ohjelmat käyttävät sudoa, joten ne kysyvät salasanaa tarvittaessa.

  • When starting graphical tools with "sudo", run it with "gksudo" instead. This will open a small graphical window that prompts the user for his password. "gksudo" is convenient if you want to set up a launcher for Synaptic on your panel, or something similar, where you would normaly not have the possiblity to enter your password.

  • Jos haluat tietää lisää sudo:sta ja root-käyttäjästä Ubuntussa, lue sudo page Ubuntu Wikistä.

Lisää Ohjeita

Internetistä löytyy uskomaton määrä tietoa Linuxista. Päästäksesi alkuun, suosittelen laadukasta ja kattavaa käyttöopasta Getting Started with Linux.

Niille, jotka tietävät perusteet jo valmiiksi, on Intermediate Level User Linux Course hyvää materiaalia luettavaksi.