Completed: / exercises

Tehtävät – Assignments

Ohjeiden lukeminen

Man Pages

Which shell command you'd give to get information about the passwd program (Note: you can get out of the manual pages by pressing q)

Warning: You have not logged in. You cannot answer.

Tiedon haku man-sivuilta

Avaa komennon grep man-sivu. Millä valitsimella (eng. option) komento tulostaa rivinumeron (eng. line number) jokaisen löytämänsä rivin eteen?
Warning: You have not logged in. You cannot answer.

Hakusanojen käyttäminen

Man-komennolla voit myös hakea man-sivuja hakusanalla. Millä seuraavista komennoista löydät listan man-sivuista, joiden nimessä tai kuvauksessa esiintyy sana email?
Warning: You have not logged in. You cannot answer.

Hakemistohierarkia

Nykyinen työhakemisto

Mikä komento näyttää nykyisen työhakemistosi?
Warning: You have not logged in. You cannot answer.

Hakemistohierarkiassa liikkuminen

Millä komennolla liikut hakemistohierarkiassa?
Warning: You have not logged in. You cannot answer.

Absolute pathnames 1

Move to your own home directory by using the command cd ~. Check that you are really in your home directory by using the command pwd. Now move to the directory /usr/share/doc by using absolute pathnames. What command did you use?

Warning: You have not logged in. You cannot answer.

Absolute pathnames 2

Move to the directory /var/spool/mail by using absolute pathnames. What command (and path) did you use?

Warning: You have not logged in. You cannot answer.

Relative pathnames 1

Move to your own home directory by using the command cd ~. Check that you are really in your home directory by using the command pwd. Now move to the directory /home by using a generic command that always takes you one step closer to the root in the hierarchy. What command did you use?
Write your answer below
Warning: You have not logged in. You cannot answer.

Relative pathnames 2

Move to the root directory by using the command cd /. Now change to the directory var by using relative pathnames. What command did you use?
Write your answer below
Warning: You have not logged in. You cannot answer.

Finding a file

Find (using absolute pathnames) all files whose name is index.html from the directory /usr/share/doc/ and all its subdirectories, by using the command find. Search only files, explicitly. Write down the command line:

Warning: You have not logged in. You cannot answer.

Tiedostojen ja hakemistojen hallinta

Creating directories 1

Change to your home directory with the command cd ~. Create a new directory with the name itl. Write down the command you used:
Write your answer below
Warning: You have not logged in. You cannot answer.

Creating directories 2

Check that you are in the directory itl with the command pwd. Now create the following subdirectories with a single command (exactly in the following order): dir1 , dir2 , dir2/subdir1 and dir2/subdir2. What command did you use?
Write your answer below
Warning: You have not logged in. You cannot answer.

Hakemistolistaus 1

Siirry luomaasi hakemistoon jlj. Ota hakemistosta listaus komennolla ls. Tämän jälkeen ota hakemistosta listaus komennolla ls -a. Mitä eroa listauksilla on?
Warning: You have not logged in. You cannot answer.

Hakemistolistaus 2

Siirry hakemistoon dir2. Ota hakemistosta listaus komennolla ls. Tämän jälkeen ota hakemistosta listaus komennolla ls -l. Mitä eroa listauksilla on?
Warning: You have not logged in. You cannot answer.

Moving a directory

Check that you are in the directory itl with the command pwd. If not, change to the directory itl. Now move the directory dir2/subdir1 to be a subdirectory in dir1. What command did you use?
Write your answer below
Warning: You have not logged in. You cannot answer.

Renaming a directory

Move to the directory dir2 by using the command cd dir2. Change the name of the subdirectory subdir2 to be subdir1. What command did you use?

Warning: You have not logged in. You cannot answer.

Looking at the contents of a file

The contents of a (text) file can be looked at with at least cat, less and more. Use one of these to look inside the file /etc/passwd. What is the login shell used by the user root (the last word on the line)?

Warning: You have not logged in. You cannot answer.

Finding text from a file

Use the command grep to find information about the user nobody from the file /etc/passwd. Hint: if the terminal does not seem to respond, press Ctrl-C. Write down the command you used:

Warning: You have not logged in. You cannot answer.

Copying a file

Make sure you are in the directory itl. Copy the file /etc/passwd to the current working directory. What command did you use?

Warning: You have not logged in. You cannot answer.

Removing a file

Remove the passwd file you just copied to the directory. What command did you use?

Warning: You have not logged in. You cannot answer.

Removing directories

Check with the command pwd that you are in the directory itl. If you are not, change to that directory. Now remove the directory dir1 by using the command rm and a suitable option. Write down the command you used:

Warning: You have not logged in. You cannot answer.

Creating a file

Make sure you are in the directory itl by using the command pwd, and change to the directory if you are not in it. Now, create an empty file named itl.txt without using any text editor.

Warning: You have not logged in. You cannot answer.

Tiedoston muokkaus

Muokkaa tiedostoa jlj.txt nano-editorilla ja kirjoita tiedostoon sisältöä. Millä näppäinyhdistelmällä tallennat tiedoston poistumatta editorista?
Warning: You have not logged in. You cannot answer.

Renaming a file

Make sure you are in the directory itl. Rename the file itl.txt to introduction.txt. Write down the command you used.

Warning: You have not logged in. You cannot answer.

Moving a file

Make sure you are in the directory itl. Move the file you just renamed (introduction.txt) to your home directory by using relative path names. Write down the command you used:

Warning: You have not logged in. You cannot answer.

I/O-uudelleenohjaus

Redirecting output to a file

The output of a command line program can be redirected to a file, for example for processing or later inspection. Redirecting is done with the greater-than character ( > ). Make sure you are in the itl directory and redirect the output of the command ls -la to a file called output.txt. Write down the command you used:

Warning: You have not logged in. You cannot answer.

Reading the input from a file

You can also read programming inputs from files instead of the keyboard by using the lesser than sign (<). Use the command wc -l to find out the number of lines in /etc/passwd. Which command did you use? Note: the output should only contain a number.

Warning: You have not logged in. You cannot answer.

Putkitus

Ohjelman tuloste ohjataan toisen ohjelman syötteeksi putkimerkillä ( | ). Suorita komento getent passwd, joka tulostaa kaikki järjestelmässä olevat käyttäjätunnukset (kokeile vaikka!), ja ohjaa sen tuloste komennolle grep root, jonka pitäisi tulostaa vain yksi rivi. Mikä on riviltä kahteen otteeseen löytyvä luku?

Warning: You have not logged in. You cannot answer.

Käyttöoikeudet

Tiedoston oikeudet 1

Mitä tarkoittaa, kun tiedostolla on suoritusoikeus?
Warning: You have not logged in. You cannot answer.

File permissions 2

Make sure you are in the directory itl. The permissions of output.txt should be the following: -rw-------. Change the permissions so that group has read permission. What command did you use?

Warning: You have not logged in. You cannot answer.

Directory permissions 1

Make sure you're in the itl folder. Create the directory dir1. Then grant it the following permissions: user can only execute, group can only write and others can only read. Write down the command you used. In this exercise, give the permissions with letters, not numbers, and in the order given.

Warning: You have not logged in. You cannot answer.

Directory permissions 2

Give the directory dir1 recursively (i.e. the directory and all subdirectories and files within that directory) the following permissions with just one command: user has all the permissions, group has only execute permission, others have only execute permission. Write down the command you used. In this exercise, give the permissions with letters, not numbers, and in the order given.

Warning: You have not logged in. You cannot answer.

Tiedoston omistajan vaihtaminen

Yritä vaihtaa tiedoston output.txt omistajaa tunnukseksi sysadm komennolla chown sysadm output.txt. Komennon suoritus epäonnistuu. Miksi?
Warning: You have not logged in. You cannot answer.

Prosessien hallinta

Prosessi-ID

Mihin prosessi-ID:tä käytetään?
Warning: You have not logged in. You cannot answer.

Prosessilistaus

Komennolla ps aux näet kaikki järjestelmän prosessit. Minkä niminen komento pyörii prosessi-ID:llä (PID) 1? Voit käyttää putketusta ja head-komentoa katsoaksesi prosessilistauksen ensimmäisen rivin.

Warning: You have not logged in. You cannot answer.

Omien prosessien listaus

Millä seuraavista komennoista et näe omia prosessejasi? Voit kokeilla kaikkia vaihtamalla USERNAME:n omaksi käyttäjätunnukseksesi.
Warning: You have not logged in. You cannot answer.

Killing a process

Execute the command grep FOOBAR. Nothing happens. Start a new terminal window and find the process ID of the stuck process. How do you kill the process? Write down the command you used to kill the process.

Warning: You have not logged in. You cannot answer.

Killing a process by name

Assume that a process called thunderbird is running with your user account. You want to kill it without using a process ID. What command do you use?

Warning: You have not logged in. You cannot answer.

Etäkäyttö terminaalista

Connecting with SSH

Assume that you have account itl on the computer foo.bar.com. How do you connect with SSH to that account to that computer?

Warning: You have not logged in. You cannot answer.
?