
The pwd command displays the directory where the user is currently located. (pwd stands for “print working directory”). For example, typing
pwd
while in the Desktop
will show /home/[username]/Desktop
.
Note
Konsool kuvab selle teabe oma akna vahekaardil ja tiitliribal.
The cd command changes directories. (cd stands for “change directory”). When a terminal window is opened, it will be in the user's home directory. Moving around the file system requires the use of the cd.
To navigate into the root directory, type:
cd /
To navigate to the current user's home directory, type:
cd
or
cd ~
Note
Käsk ~ esindab praeguse kasutaja kodukataloogi. Nagu ülal näidatud, on cd ~ käsu cd /home/username/ ekvivalent. Kui käivitad selle käsu juurkasutajana (näiteks sudoga), siis viitab ~ kataloogile
/root
. Kui käivitad käsu cd koos sudoga, siis pead trükkima kodukataloogi täieliku asukoha.To navigate up one directory level, type:
cd ..
To navigate up two directory levels, type:
cd ../../
To navigate to the previous directory (go back), type:
cd -
Korraga läbi mitme kataloogitaseme liikumiseks määra kataloogi täistee. Näiteks trüki:
cd /var/log
, et minna otse alamkataloogi
/log
subdirectory of/var/
. For another example, typing:cd ~/Desktop
moves to the
Desktop
subdirectory inside the current user's home directory.
The ls command outputs a list of the files in the current directory. (ls is short for “list”). For example, typing
ls ~
will display the files that are in the current user's home directory.
Koos võtmega -l väljastab ls peale faili nime veel muudki teavet, nagu faili õigused, faili omanik ja muud.
Koos võtmega -al väljastab ls sama teabe, mis -l, kuid kuvab ka peidetud failid (võti a).
Käsku touch kasutatakse faili vaatamise ja muutmise ajatemplite muutmiseks või uue tühja faili loomiseks. Näiteks
touch foo
loob uue tühja faili nimega foo
. Kui foo
-nimeline fail on juba olemas, siis käsu touch kasutamine uuendab faili ajatemplid, mis näitavad, millal faili viimati näpiti.
The mkdir command is used to create a new directory. (mkdir stands for “make directory”). To create a new directory named foobar
, type:
mkdir foobar
The cp command makes a copy of a file or directory. (cp is short for “copy”). To make an exact copy of foo
and name it bar
, type:
cp foo bar
To make an exact copy of the foo_dir
directory and name it bar_dir
, type:
cp -r foo_dir bar_dir
The mv command moves a file or directory to a different location or will rename a file or directory. (mv is short for “move”). To rename the file foo
to bar
, type:
mv foo bar
To move the file foo
into the current user's Desktop
directory, type:
mv foo ~/Desktop
This will not rename foo
to Desktop
because foo
is a file and Desktop
is a directory.
The rm command is used to delete files and directories. (rm is short for “remove”). To delete the file foo
for the current directory, type:
rm foo
Vaikimisi ei eemalda käsk rm katalooge. Kataloogide eemaldamiseks pead kasutama võtit -r (või -R või --recursive). Näiteks
rm -r foobar
või
rm -R foobar
või
rm --recursive foobar
eemaldab kataloogi foobar
ja kogu selle sisu!