Ondřej Plátek Blog
PhD candidate@UFAL, Prague. LLM & TTS evaluation. Engineer. Researcher. Speaker. Father.

Week 1, Intro to Unix lab 2016

Content

  • Parse the instructions on this website and send me run.sh script which will print your desired nickname
    • Nickname requirements: Max 8 characters.
  • Motivation. Why shell and simple utilities?
    • Automation
      • Try interactively, repeat via scripting
      • Large number of simple fast and useful commands which can be combined
      • Can easily parse huge files. (Just try to open 1GB text file in MS Word)
    • Faster than GUI for text editing
    • Low resources
    • CLI - command-line interface - standard interface for a lot of machines
      • web servers
      • large clusters of computers
      • robots and embedded devices e.g. washing machines, tourniquets
      • many other examples …
    • In addition: why Linux?
      • Free, widely used, open-source
        • You can learn it and improve it
    • Glue language for system administration, running experiments, compilation, …
  • Understand how you can pass the labs
  • Using shell in lab/Rotunda
    • ssh YOUR_LOGIN@u-pl2[0-9].ms.mff.cuni.cz
  • Terminal in lab, Terminal for OSX, Docker for Windows, Putty, VirtualBox (see main page for links)
  • Command line shortcuts Ctrl-a, Ctrl-e, Ctrl-w, Ctrl-k, Ctrl-Left, Ctrl-Right, Ctrl-r, Ctrl-d, Ctrl-C
  • Comments # this is comment - it does nothing
  • cd, cd -, cd /path/to/directory, todo, cd .. # go to parent directory, cd ../.. # go two directories up
  • man man, search using /, jumping to occurrences vian and N
    • structure man man, $0 --help, synopsis command [OPTION]... [FILE]...
  • Basic commands
    • cp, mv, rm, touch, ln, sleep

Homework

  1. (1 point) Print numbers 3300, 3301, …, 3333 from file which has 10000 lines. Prepare the file yourself. Numbers are stored each on single line and each number is located on the row with corresponding number.
    • Hints - commands seq, head, tail and man
  2. (2 points)
    • Create a directory named test and empty files test/1, test/2, .., test/10.
    • Use vi or other editor and edit all of the 10 files and to each file insert one of your favourite songs/articles.
    • Change the time of modification for file test/8 so it is the latest.
    • List files in the test directories sorted by time. List just the directory test.
    • Merge the content of all the files in the test directory to one file called all

Bonus

  • (2 points) Write a script which finds as many commands and functions which measure time both in shell and in C. Present them in three columns (function name, man section number, one line function synopsis)
    • One point for one function
    • Find at least one C function
    • Describe how you think about the problem
  • (2 points) Prepare a short presentation (in Czech) about tr command
    • Explain to others how it can be used
      • Syntax and how to read the manual page
      • Use with echo and pipes (Pipes will be introduced next time)
      • Prepare at least three examples how it can be used
  • (2 points) Prepare a short presentation and a blog post describing how to get your Linux command-line at home
    • Include at least three options from list below:
      • ssh to Rotunda lab
      • Use Putty to ssh to Rotunda lab
      • Install Ubuntu 14.04/Debian 8
      • VirtualBox on Windows with Ubuntu/Debian
      • Docker on Windows or Linux
  • (1 point) Find a spelling or other error on the lab webpage and submit me a fix using Pull request (PR).