Sheet 1
Sheet 1
24
Computing and Machine Learning C. Gros, D. Nevermann
Exercise Sheet #1
Introduction to Linux For all the commands below, be sure to check its
man page, using man <command>. If there is something you want to do, and
you don’t find a command, you should search the internet, chances are there
is a UNIX command that does what you want, or someone already had the
same problem.
Online terminal To practice Linux commands, you can also try to use an
online terminal, e. g. https://bellard.org/jslinux/vm.html?url=https:
//bellard.org/jslinux/buildroot-x86.cfg. Mind that for some of the
exercises you might miss some directories. As you can never be sure who
reads the input to the online console do never type your password to any
online console. (So you should not do problem №4 online.)
1
Advanced Introduction to C++, Scientific SoSe 24 | 15.04.24
Computing and Machine Learning C. Gros, D. Nevermann
2. Go to the /etc directory and see what is there, check the rest of the
filesystem tree using cd, ls, pwd and cat. Look in /bin, /usr/bin,
/sbin, /tmp and /boot.
5. Now go back one level try to delete both directories using rm and its
options (check man rm).
6. What is the difference between listing the contents with ls -ltr and
ls -l, or ls (check some of the options, often denoted flags listed in
man ls).
1. Show the content of the text file one page at a time using the less <filename>
command.
2. Show the first and last ten lines of the file using head <filename> and
tail <filename>, respectively.
3. Use grep <word> <filename> to search your file for lines containing
a word of your choice.
Problem 3 (Permissions)
1. Create a file and a directory with permissions r--r--r--. Can you
change to the directory you created now? (hint: man chmod)
2
Advanced Introduction to C++, Scientific SoSe 24 | 15.04.24
Computing and Machine Learning C. Gros, D. Nevermann
2. Save one step and run a command in the remote computer via
ssh [email protected] <command>. See what happens if you
end the connection while the program is running. Try with a graphical
program, for instance Firefox (you need an extra option for that, see
man ssh).
1. Use the grep command and pipe operator to filter the list of files by a
specific keyword. For example, if you wanted to filter by files containing
some <word>, you would use the command ls | grep <word>.
2. Now pipe the output of that command into xargs using the following
command: printf "test1.txt\ntest2.txt" | xargs touch. The
xargs utility will, for each line of the output, execute a given command
(here touch) with that line as an argument. If everything worked, two
new files test1.txt and test2.txt were created. Check if that is the
case using ls.