1-DAV-202 Data Management 2023/24
Previously 2-INF-185 Data Source Integration

Materials · Introduction · Rules · Contact
· Grades from marked homeworks are on the server in file /grades/userid.txt
· Dates of project submission and oral exams:
Early: submit project May 24 9:00am, oral exams May 27 1:00pm (limit 5 students).
Otherwise submit project June 11, 9:00am, oral exams June 18 and 21 (estimated 9:00am-1:00pm, schedule will be published before exam).
Sign up for one the exam days in AIS before June 11.
Remedial exams will take place in the last week of the exam period. Beware, there will not be much time to prepare a better project. Projects should be submitted as homeworks to /submit/project.
· Cloud homework is due on May 20 9:00am.


Difference between revisions of "Command-line basics"

From MAD
Jump to navigation Jump to search
(Created page with "==Files and folders== * Images, texts, data, etc. are stored in files * Files are grouped in folders (directories) for better organization * A folder can also contain other fo...")
 
Line 9: Line 9:
 
* The list of files in some other folder can be obtained with the command <tt>ls other_folder</tt>
 
* The list of files in some other folder can be obtained with the command <tt>ls other_folder</tt>
 
* The command <tt>cd new_folder</tt> changes the current folder to the specified new folder
 
* The command <tt>cd new_folder</tt> changes the current folder to the specified new folder
* Notes: <tt>ls<tt> is an abbreviation of "list", <tt>cd</tt> is an abbreviation of "change directory"
+
* Notes: <tt>ls</tt> is an abbreviation of "list", <tt>cd</tt> is an abbreviation of "change directory"
  
 
'''Example:'''  
 
'''Example:'''  
 
* When we login to the server, we are in the folder <tt>/home/username</tt>.  
 
* When we login to the server, we are in the folder <tt>/home/username</tt>.  
 
* We then execute several commands listed below
 
* We then execute several commands listed below
* Using <tt>cd</tt> command, we move to folder <tt>/tasks/perl/</tt> (computer does nto print anything, only cnages the current folder).
+
* Using <tt>cd</tt> command, we move to folder <tt>/tasks/perl/</tt> (the computer does not print anything, only changes the current folder).
 
+
* Using <tt>ls</tt> command, we print all files in the <tt>/tasks/perl/</tt> folder.  
počítač nič nevypíše, iba zmení aktuálny adresár) a skúsime ls. Príkaz ls vypíše obsah adresára data-ppb/: podadresáre 2010-L, DU10,  DU6, events a ukazka a súbor README. Nakoniec vypíšeme obsah podadresára events, ktorý obsahuje ďalšie podadresáre 2009 a 2010.
+
* Finally we use <tt>ls /tasks</tt> command to print the folders in /tasks
 
<pre>
 
<pre>
meno@vyuka:~$ cd /projects/data-ppb/
+
meno@vyuka:~$ cd /tasks/perl/
meno@vyuka:/projects/data-ppb$ ls
+
meno@vyuka:/tasks/perl$ ls
2010-L DU10 DU6 events  README  ukazka
+
fastq-lengths.pl reads-small.fastq reads-tiny-trim1.fastq series.tsv
meno@vyuka:/projects/data-ppb$ ls events
+
protocol.txt      reads-tiny.fasta  reads-tiny-trim2.fastq
2009 2010
+
reads.fastq      reads-tiny.fastq  series-small.tsv
 +
meno@vyuka:/tasks/perl$ ls /tasks
 +
bash  bioinf1  bioinf2  bioinf3  cloud  flask  make  perl  python  r1 r2
 
</pre>
 
</pre>
  

Revision as of 23:46, 11 February 2023

Files and folders

  • Images, texts, data, etc. are stored in files
  • Files are grouped in folders (directories) for better organization
  • A folder can also contain other folders, forming a tree structure

Moving around folders (ls, cd)

  • One folder is always selected as the current one; it is shown on the command line
  • The list of files and folders in the current folder can be obtained with the ls command
  • The list of files in some other folder can be obtained with the command ls other_folder
  • The command cd new_folder changes the current folder to the specified new folder
  • Notes: ls is an abbreviation of "list", cd is an abbreviation of "change directory"

Example:

  • When we login to the server, we are in the folder /home/username.
  • We then execute several commands listed below
  • Using cd command, we move to folder /tasks/perl/ (the computer does not print anything, only changes the current folder).
  • Using ls command, we print all files in the /tasks/perl/ folder.
  • Finally we use ls /tasks command to print the folders in /tasks
meno@vyuka:~$ cd /tasks/perl/
meno@vyuka:/tasks/perl$ ls
fastq-lengths.pl  reads-small.fastq  reads-tiny-trim1.fastq  series.tsv
protocol.txt      reads-tiny.fasta   reads-tiny-trim2.fastq
reads.fastq       reads-tiny.fastq   series-small.tsv
meno@vyuka:/tasks/perl$ ls /tasks
bash  bioinf1  bioinf2  bioinf3  cloud  flask  make  perl  python  r1  r2

Absolútne a relatívne cesty

  • Absolútna cesta určuje, ako sa k danému súboru alebo adresáru dostať z koreňa
  • Napr. /projects/data-ppb/, /projects/data-ppb/README, /projects/data-ppb/events/2009/Wed_25_Nov_2009, /home/meno/ atď
  • Jednotlivé adresáre v strome sa oddeľujú lomítkom
  • Absolútna cesta začína lomítkom
  • Relatívna cesta určuje, ako sa k danému súboru dostať z aktuálneho adresára
  • Napr. ak aktuálny adresár je /projects/data-ppb/, tak relatívna cesta k /projects/data-ppb/README je len README a relatívna cesta k /projects/data-ppb/events/2009/Wed_25_Nov_2009 je events/2009/Wed_25_Nov_2009
  • Relatívna cesta nezačína lomítkom
  • Relatívna cesta môže ísť aj hore do nadadresára, pomocou ..
  • Napr. ak aktuálny adresár je /projects/data-ppb/events/2009, tak relatívna cesta ../../proteins nám dá to isté ako /projects/data-ppb/proteins

V príkazoch ls, cd a ďalších môžeme používať absolútne aj relatívne cesty.

Dôležité adresáre

  • Koreň je adresár s cestou /, počiatočný bod stromovitej štruktúry adresárov
  • Domovský adresár (home directory) /home/meno je aktuálny po prihlásení
    • Tam si ukladáme väčšinu svojich súborov, ak nie je dobrý dôvod ich uložiť inde
    • Skratka pre domovsky adresár je ~, napr. cd ~ vás tam presunie

Hviezdičková konvencia

  • Príkaz ls namiesto všetkých súborov v adresári môže vypísať len tie, ktoré si vyberieme
  • Všetky súbory v aktuálnom adresári začínajúce písmenom x vypíšeme pomocou ls x*
  • Všetky súbory obsahujúce písmeno x hocikde v mene vypíšeme pomocou ls *x*

Prezeranie obsahu súboru (less)

  • less subor
  • Vypíše súbor na obrazovku, môžeme v ňom listovať pomocou medzery alebo Page up a Page down, vyskočíme pomocou q (ako quit), ďalšie klávesy sa dozviete po stlačení h (help)

Kopírovanie súborov (cp)

  • cp odkiaľ kam
  • Skopíruje súbor odkiaľ na miesto kam
  • Môžeme použiť absolútne alebo relatívne cesty.
  • Cieľové miesto kam môže byť adresár alebo celé meno súboru

Príklad: ak aktuálny adresár je /projects/data-ppb/, nasledujúce tri príkazy všetky kopírujú súbor README do poadresára events:

# relatívne cesty
cp README events/
# absolútne cesty
cp /projects/data-ppb/README /projects/data-ppb/events/
# celé meno súboru 
cp README events/README

# tento príkaz kopíruje do /projects/data-ppb/events/README2
cp README events/README2
# ak sa presunieme do adresára events, môžeme kopírovať súbor do aktuálneho adresára .
cd events
cp ../README .

Kopírovanie súborov zo servera/na server (scp)

  • Kríženec medzi ssh a cp (Secure CoPy)
  • Na server (spustite na vašom linuxovom počítači napr. v učebni): scp subor meno@vyuka.compbio.fmph.uniba.sk:nove_meno_suboru
  • Zo servera: scp meno@vyuka.compbio.fmph.uniba.sk:subor nove_meno_suboru
  • Ak chcete kopírovať súbory medzi serverom a Windowsovým počítačom, nainštalujte si program WinSCP
#skopíruje súbor README2 do adresára /projects/data-ppb/ na serveri
scp README2 hrasko37@vyuka.compbio.fmph.uniba.sk:/projects/data-ppb/

#skopíruje súbor README2 do domovského adresára užívateľa hrasko37 na serveri
scp README2 hrasko37@vyuka.compbio.fmph.uniba.sk:

#skopíruje súbor README2 do domovského adresára užívateľa hrasko37 pod menom README3
scp README2 hrasko37@vyuka.compbio.fmph.uniba.sk:README3

#skopíruje súbor README2 z domovského adresára užívateľa hrasko37 na serveri do aktuálneho adresára
scp hrasko37@vyuka.compbio.fmph.uniba.sk:README2 .

Poznámky

Upozornenie: dvakrát meraj, raz rež

  • Príkazový riadok spraví, čo napíšete, nepýta sa, či to myslíte naozaj
  • Príkazy cp a scp môžu prepísať už existujúce súbory
  • Neexistuje undo
  • Preto si vždy dobre premyslite, čo chcete spraviť a skontrolujte príkaz pred tým, ako dáte Enter

Zjednodušenie práce

Užitočné pomôcky na príkazovom riadku:

  • kláves Tab
    • ak je len jeden súbor alebo adresár, ktorý pasuje na rozpísaný začiatok slova, doplní ho automaticky
    • ak je súborov alebo adresárov viac, doplní, čo majú spoločné,po opakovanom stlačení ponúkne možnosti
  • šípky hore/dole
    • prechádzanie históriou spustených príkazov
  • copy&paste myšou
    • ľavým tlačidlom a ťahaním po texte označíme
    • kliknutím stredného tlačidla (kolieska) vložíme kam potrebujeme
    • ak nemáme stredné tlačidlo, klikneme naraz pravým aj ľavým

Ďalšie materiály k linuxu