<texit info> author=Roman Putanowicz backgroundtext=http://www.L5.pk.edu.pl/~putanowr/iten.html title=Lab 1: Introduction to GNU/Linux operating system showbuttons=off </texit> <texit> \input{/home/prac/putanowr/dokuwiki/data/media/wiki/latex/it_preamb.tex} \renewcommand{\chaptername}{Lab Handouts} \setcounter{chapter}{0} </texit> <texit>\begin{comment}</texit> up | next <texit>\end{comment}</texit>

Lab 1 : Introduction to GNU/Linux operating system

Description

Introduction to the course, organization of laboratory work, grading. Logging to Linux accounts. Working with text and graphical terminals. Basics of Linux file system structure. HOME directory. Creating text files with editors. Basic commands for files and directories management: ls, mkdir, rmdir, cp, mv, pwd, cat, tree.

Lab slides: a02_lab_slides01_jm.pdf

Skills to be acquired

  • logging to Linux account
  • editing text files
  • files and directories management

Self study

This lab can give only a little glimpse of the features of GNU/Linux operating system, even those related only to shell operations and files management. The students are encouraged to make some further study in order to feel more comfortable with the UNIX way of working and UNIX philosophy. Some ideas for self study are given below:

  • finding files with find (e.g. finding files of given name, extension, or modification date)
  • finding files with specific content with grep (especially -rl options)
  • using wildchars in shell commands to operate on several files at once
  • locating lines with particular line number in text files (including turning on line numbering in text editors)
  • concepts of streams (stdin, stdout, stderr), stream redirection and connecting processes (programs) into pipelines

Readings

Solved problems

Ex. 1.1

Create the following directory structure:

  projectA/
  |-- data
  |   `-- caseA.dat
  |-- results
  `-- src
      |-- include
      `-- lib

Fill file caseA.dat with integers form 1 to 10, each number in a separate line.
Solution.

Ex. 1.2

Change to directory projectA created in excercise Ex. 1.1. Being in this directory copy the file caseA.dat in the directory data to file caseB.dat also in the directory data.
Solution.

Ex. 1.3

Create in the directory projectA/data a file named months.txt. Each line in the file should consist in three fields separated by one or more whitespaces: ordinal, month name and number of month's days, e.g:

 1  January  31
 2  February 28
 3  March    31
 ...

Calculate the sum of days in the months which names finish with 'er'.
Solution.

Questions and open problems

Ex. 1.2.1

Calculate the sum of days in each quarter on the basis of the file months.txt for the exercise 1.1.

Ex. 1.2.2

Create 40 files with names following the pattern: case_1.dat, case_2.dat, and so on. Put in each file as many lines wit a single word “item” as is the file number.

Ex. 1.2.3

Remove files created in exercise 1.5 with numbers between 20 and 29 inclusive.

Ex. 1.2.4

Find the total number of lines in the files created in exercise 1.5 with the numbers greater or equal 50.

Ex. 1.2.5

Rename files created in exercise 1.5 in such way that numbers are three digits long and padded with zeros from the left if necessary.

Ex. 1.2.6

Create a file named data_A with the line “this is data A” and a file data_B with the line “this is data B”. Swap the content of these two files.

<texit>\begin{comment}</texit> up | next <texit>\end{comment}</texit>

  • en/teaching/subjects/it/labs/lab1.txt
  • Last modified: 2017/10/02 15:54
  • (external edit)