Linux Console
First steps with the Linux shell. Create files, move them, write content. 5 tasks.
First steps in the console
First steps with the Linux console
The console (also terminal or shell) is the text-based way to control a Linux computer: you type commands, the computer runs them. Professionals do almost everything via the console because it is fast and automatable.
Key terms & commands
- Directory: a "folder". You move around with
cd, create one withmkdir. echo: prints text — with>you write it into a file.cat: shows the content of a file.ls: lists files in a directory.
Work in the folder
/home/student/uebung/in this lesson. Create it first:mkdir -p /home/student/uebung.
Your goal
You create files, write text into them and practise the basic commands — the foundation for all further modules.
Exercises
1. Create your first file
Concept: creating a file with
>. The arrow>redirects a command's output into a file (overwriting it). This lets you create a file with content in one step.Create the practice folder and write
hallointo a file:mkdir -p /home/student/uebung echo "hallo" > /home/student/uebung/hallo.txtCheck with
cat /home/student/uebung/hallo.txt.Check:
/home/student/uebung/hallo.txtcontains the wordhallo.2. Your name in a file
Concept: appending lines with
>>. While>overwrites,>>appends to a file. This lets you write multiple lines.Write your first and last name on two lines into
ich.txt:echo "Max" > /home/student/uebung/ich.txt echo "Mustermann" >> /home/student/uebung/ich.txtReplace the example names with your own.
Check:
/home/student/uebung/ich.txtcontains at least two lines.3. Write a list
Concept: writing a list. In many text formats a list item starts with a hyphen and space (
-). Write a list with at least three items intoliste.txt.printf -- "- Apple\n- Banana\n- Cherry\n" > /home/student/uebung/liste.txtprintfwith\ncreates line breaks. Alternatively write it by hand withnano.Check:
/home/student/uebung/liste.txtcontains at least three lines starting with-.4. Uppercase
Concept: transforming text with
tr. The commandtr(translate) replaces characters — e.g. lower- to uppercase. Write a word in UPPERCASE (at least 5 letters) intolaut.txt.echo "warning" | tr 'a-z' 'A-Z' > /home/student/uebung/laut.txtResult:
WARNING.tr 'a-z' 'A-Z'converts each lowercase letter to the corresponding uppercase one.Check:
/home/student/uebung/laut.txtcontains at least 5 uppercase letters in a row.5. Create three files
Concept: multiple files &
ls. Create three files, then write an overview of their names intodrei.txt— combiningtouch(create an empty file) andls(list).cd /home/student/uebung touch a.txt b.txt c.txt ls *.txt > drei.txttouchcreates empty files;ls *.txt > drei.txtwrites the list into the file.Check:
/home/student/uebung/drei.txtis not empty (contains the file names).
Related courses
Now practice it yourself
Reading is good – doing is better. Start this course on a real Linux VM, right in your browser. A free account is all it takes.
Start for freeLab content under CC BY 4.0 – free to use with attribution (© TechLogia).
