Computers, Operating Systems, and GNU/Linux Computational environments for digital biology

Dr. Paweł Widera

October 2024
Creative Commons Attribution-ShareAlike Licence

Overview

Our tool belt

  • GNU/Linux
  • ssh
  • X2Go
  • bash

Files / Datasets

  • file archive +1

  • 1

What will we do?

Turing Machine

Bit flipping programme



http://turingmachine.vassar.edu/jYKEWL9T

Command line

Directories and files

$ pwd
$ ls
$ cd
$ mkdir
$ mkdir -p Documents/8321/labs-1
$ man mkdir

$ cd Documents/8321/labs-1

Characters with special meaning: . .. - ~

$ echo "Hello!"
$ echo "Hello friends!" > hello.txt
$ cat hello.txt > another_hello.txt
$ cat another_hello.txt
$ echo "How are you?" >> another_hello.txt
# Some commands do not work without arguments!
$ cp
$ mv
$ rm

Command options and arguments

$ ls -l
$ ls -la ~
$ ls -lah ~
$ ls -lt ~
$ ls --help
$ man ls
$ tldr ls

# Run "tldr -u" first to update the help database.
$ ls -la ~/Documents/8321/labs-1
$ cp -r ~/Documents/8321 ~/8321_copy
$ rm -r ~/8321_copy
$ ls /
$ ls /tmp
$ ls $HOME

Matching and compression

$ ls ~/D*
$ ls ~/D*/8*/hello*.txt

# Be careful with things like "rm -fr *"!
$ gzip hello.txt
$ gunzip hello.txt.gz

$ xz hello.txt
$ unxz hello.txt.xz
$ zcat hello.txt.gz
$ xzcat hello.txt.xz
$ tar -cf archive.tar *.txt
$ tar -acf archive.tar.gz *.txt
$ tar -acf archive.tar.xz *.txt

# Which archive is smaller?
$ tar -tf archive.tar.xz

$ mkdir archive
$ cd archive
$ tar -xvf ../archive.tar.xz

Redirection and chaining

$ ls /usr/bin > files.txt

$ head files.txt
$ tail files.txt
$ less files.txt

# Press "q" to exit from less paging mode.
$ cat files.txt | wc
$ cat files.txt | wc -l
$ cat files.txt | head -n 100 | sort | uniq

# What about "cat < files.txt > files.txt"?
$ du -h .
$ du -hs ~/Documents

$ du -hs /abc
$ du -hs /abc 2> error.txt
$ du -hs /abc 2> /dev/null

Challenge time!

Analyse the mysterious archive file

# copy the archive
cd ~/Documents/8321/labs-1
... /opt/files/covid_publications.tar.gz .

# check its size
ls ...

# check archive content
tar -t ...

# extract the files
tar -x ...

# delete archive file
...

# check uncompressed size
du ...
# count number of files
.. | wc ..

# organise files by extension in separate directories
mkdir ...
mv ...

# how many files each directory has? how much space they take?
...