Linux Basics, Shell Scripting (2021-03-29)¶
Linux and UNIX concepts
Commandline: using the shell efficiently
Filesystem and permissions
grep, and the like
Exercises: combine things to solve problems
Shell scripting: Variables
Parameter expansion, here-documents, and more details
We will be using a Linux machine somewhere in the cloud, IP address
220.127.116.11. Please verify that you are able to login as
follows (substitute my username with yours),
From a Linux system, use the
sshprogram (substitute my username with yours)
$ ssh firstname.lastname@example.org The authenticity of host '18.104.22.168 (22.214.171.124)' can't be established. ECDSA key fingerprint is SHA256:/in22o4VCD400X0bb4FlCb5/vQnrvKvOirgfqq6maPo. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '126.96.36.199' (ECDSA) to the list of known hosts. email@example.com's password: Linux fh-ece-19 4.19.0-14-cloud-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Sat Feb 27 15:04:09 2021 from 188.8.131.52 faschingbauer.joerg@fh-ece-19:~$
From a Windows system, use PuTTY to do the same.
Linux Basics (
download), heading straight
through to the “Permissions” chapter startung on slide #92.
Your password on our cloud machine equals your username. From a security standpoint, this is suboptimal - if anybody knows your username, you’re pwned.
Change your password.
Create an alias
ls -al DIRshows a long listing of
DIR(including “hidden” files).
ls -alis relatively clumsy to type, clumsier than e.g.
For your comfort, create an alias to solve this problem. Do this in a way that makes the alias automatically available on next login.
echocommand appends a linefeed (aka newline) to its output,
$ echo this is a line because it has a newline at the end this is a line because it has a newline at the end $
(You can see the newline character because the next prompt appears on a new line.)
Which option makes
echosuppress the newline character? (The next prompt appears right after the output, on the same line.)
Show file content
In my (username
faschingbauer.jörg) home directory, there exists a subdirectory
dumpbin, and inside that directory exists a file
Print the file content on the console.
Create dumpbin, and give colleagues write permissions
In your hmoe directory, create a
dumpbindirectory. Give your colleagues write permissions in that directory (btw, a colleague is one of the
Create a file in your colleague’s dumpbin, and write-protect that file against the colleague
Again from Linux Basics (
Permissions, again (this is important!)
Tools, including some live demos of pipe usage
stdout, pipe short demos
Problem: on the (small ARM) target machine hell breaks loose (OOM killer runs amoc) from time to time. Sketch a possible way to pull memory usage snapshots from the target.
SSH for remote execution
Shell script on target
Python on host, after making clear why Shell is not an appropriate language if you want to do more.