Information below is not for the current semester.
The current semester can be found here.
Other labs: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12.
Přeložit do češtiny pomocí Google Translate ...Lab #2 (Feb 24 – Feb 28)
Before class
- What is a terminal, which terminal emulators are there (hint:
konsole
,xterm
, …)? - What is stdout, stdin and stderr?
- What is a pipe (in the process chaining sense)?
- What is a manpage?
- What is a shell?
- What are filename wildcards?
- Which directory is aliased to tilda (
~
)? - Write a program in Python (or in other reasonable language) that copies its stdin to its stdout and stderr.
- Write a program in Python that takes as command-line argument
(
sys.argv
) one natural number and prints a random number in the range of 0 to the provided number. On bad usage (no number, invalid number etc.) it shall printBad usage
.
Topic
- Introduction to command-line environment of GNU/Linux.
- Working with files in command-line.
- Effective command-line usage.
- Basic utilities.
Exercises
1.
Write a program in Python (or in other reasonable language) that copies its stdin to its stdout and stderr.
Solution.
2.
Write a program in Python that takes as command-line argument
(
sys.argv
) one natural number and prints a random number in the range
of 0 to the provided number.
On bad usage (no number, invalid number etc.) it shall print
Bad usage
.
Solution.3.
Choose one terminal based text editor and familiarize yourself with it.
4.
List the content of your home directory. Then repeat for hidden files.
Solution.
5.
Print the detailed (long) listing of the
/etc
directory.
Solution.6.
7.
Create a file
file with space.txt
. How is it treated by the ls
command? What does a tab completion do with this file?
Solution.8.
Create a directory
a
and inside of it create a text file --help
containing Lorem Ipsum
. Print the content of this file and then
delete it.
Solution.9.
Create a directory called
a
and inside of it create files called
alpha.txt
and *
. Then delete the file called *
and watch out what
happened to the file alpha.txt
.
Solution.10.
11.
Print the content of the file
/etc/shells
.
Solution.12.
Print the content of the file
/etc/passwd
sorted by the rows.
Solution.13.
Print the first and fifth column of the file
/etc/passwd
.
Solution.14.
Count the lines of the file
/etc/services
.
Solution.15.
Print the first three lines of the file
/etc/passwd
.
Solution.16.