Understanding Unix

NUnix · L3 MIAGE · CM1 · 90 minutes

Louis Ledoux

ISTIC · University of Rennes

2026–2027

Linux is closer than you think

Linux surrounded by Android phones, internet boxes, coffee machines, Steam Deck, Raspberry Pi, cloud servers and supercomputers.

You can use it all day without opening a terminal.

Yes, even the coffee machine

Android phones

The Linux kernel manages processes, memory and hardware.

Google · platform architecture

Freebox Server Pop

A home internet box. Free publishes its Linux source code.

Free · firmware 4.9.10

MARO Model One

A coffee machine with embedded Linux, remote support and updates.

Toradex · May 2026

Linux can run behind a touchscreen or a web interface.

Unix and Linux usage

Mobile web use

69.17%

of observed mobile page views come from Android, built on Linux.

Statcounter · Sept 2026

Websites

92.1%

use the Unix family, including Linux, among sites whose OS W3Techs identifies.

W3Techs · 1 Oct 2026

Supercomputers

500/500

systems in the June 2026 TOP500 list use the Linux family.

TOP500 · June 2026

$ whoami

Who teaches NUnix, and how is the course organised?

Louis Ledoux

Associate Professor

University of Rennes · ISTIC
IRISA / Inria · Taran

  • Arithmetic circuits: MLIR (LLVM) / CIRCT.
  • Systolic arrays and small floating-point formats.

Previously: Inria / INSA Lyon, Emeraude.
PhD: BSC / UPC.

MareNostrum 4 server racks inside the former Torre Girona chapel at the Barcelona Supercomputing Center.

MareNostrum 4 · BSC, Barcelona

CM, TD and TP

NUnix · L3 MIAGE · 2026–2027

Sessions Teaching team
CM · lectures Louis Ledoux
TD · tutorials Elisabeth Bouriah and Louis Ledoux
TP · practical sessions Elisabeth Bouriah and Louis Ledoux

In TD and TP, we practise the lecture topics through exercises, commands and Bash scripts.

Course structure

Three lectures (CM) of 90 minutes.

Lecture Topics Application
CM1 · Unix Files, paths and permissions Find files and check access
CM2 · Commands Processes, search, pipes and redirections Count errors in a log
CM3 · Bash Variables, conditions, loops and functions Write scripts with arguments and loops

TD and TP: practise commands first, then write scripts.

One line, a useful result

Which errors occur most often in 1,000 log entries?

sort < errors.log | uniq -c | sort -nr | tee output.txt |
  a2ps -1 -o - | ps2pdf - rapport.pdf

Save the counts in output.txt and the report in rapport.pdf.

errors.log · first three lines

Database timeout
Login rejected
Connection refused

output.txt · first three counts

    320 Database timeout
    210 Login rejected
    140 Connection refused

a2ps: text → PostScript
ps2pdf: PostScript → PDF

By the end of this course, you will understand this command.

1. Linux and the shell

What happens between typing a command and the machine doing the work?

Programs, kernel and hardware

We use hardware to interact with programs.

From bottom to top: the user interacts with a keyboard, mouse and screen. These hardware devices communicate with the Linux kernel through drivers. The kernel provides services to applications including the browser, music player and Bash. Arrows in both directions show input reaching programs and results returning to the user. The kernel also manages CPU time, memory, storage and network access.

The kernel shares resources and controls access.

Linux

  • 1991: Linus Torvalds announces his kernel project.
  • Linux is a Unix-like kernel, distributed as free and open source software.
  • A distribution combines the kernel with tools, libraries and applications.

Our working environment: a Linux system with the Bash shell and command-line tools.

Unix, GNU and Linux

Name Meaning
Unix The operating-system family that inspired Linux
GNU The project behind Bash and many command-line tools
Linux The kernel: manages processes, memory and hardware

GNU = GNU’s Not Unix.
The name contains itself: a recursive acronym.

Touch, click or type

You already use interfaces to start programs.

Your action Interface Example
Touch a phone screen Graphical interface Open an app from its launcher
Click with a mouse Graphical interface Open a folder in a file manager
Type a command Text interface Ask Bash to list a directory

A smartphone can be a terminal: an endpoint for using a service.
Its touchscreen, like a mouse or keyboard, provides input.

Our terminal for this course?

A person using a DEC VT100 physical text terminal, with its screen and keyboard.

DEC VT100 · IF-3-SYS, G. Salagnac, INSA Lyon

A physical terminal sends keystrokes to a computer and displays its replies.

The programs run on the connected computer.

Good news: yours fits in a window.

Terminal, shell and command

Name Role
Terminal emulator A window for keyboard input and text output
Bash, the shell Interprets the line and runs commands
ls, a command Lists directory entries

Type ls → Bash runs ls → the terminal displays its output.

TTY = teletypewriter: early terminals printed on paper.
Unix keeps the name, even for emulated terminals.

A command and its arguments

ls -l /home/alice

Part Role
ls Command: list directory entries
-l Option: change how ls lists them
/home/alice Operand: the directory to list

Both -l and /home/alice are arguments passed to ls.

Short and long options

Form Example Meaning for GNU ls
Short: one dash ls -a Include hidden entries
Long: two dashes ls --all Same as -a
Combined ls -la -l and -a together

Some options take a value: head -n 5 notes.txt prints five lines.

A bare -- ends options.
ls -- -notes.txt treats -notes.txt as a filename.

Each command defines its options. Check --help or man.

Getting help

man ls
info coreutils
apropos directory
help cd
  • Tab completes a name or displays possible completions.
  • Up recalls a previous command. history lists history.
  • clear clears the display. In man, q quits.

2. Files and directories

Where is my file, and what can I do with it?

One directory tree

A directory is a folder: it contains names of files and other directories.

/
├── home/
│   └── alice/
│       └── notes.txt
└── etc/

The common root is /. The path /home/alice/notes.txt follows the tree.
Alice's home directory is /home/alice; the university may use a different path.

Personal files and system data

Linux separates personal files, configuration and application data.

Directory Typical contents
/home/alice Alice’s personal files
/etc System configuration
/var Changing data: logs, caches, application state
/var/lib Persistent application state
/var/log Log files

/var/lib and /var/log are subdirectories of /var.

Users, administrators and software

Directory Typical role
/home, /root User homes; the root account’s home
/usr Most distribution-provided tools and libraries
/usr/local Software installed locally by the administrator
/opt Add-on software packages

/ is the filesystem root.
root is also the administrator account’s name.

Temporary files and system information

Directory Purpose / lifetime
/var Changing data, often persistent
/tmp Temporary files; cleanup policy varies
/run Runtime state, cleared at boot
/dev Device interfaces
/proc, /sys Views of processes, kernel and devices

A path can expose live system information.
It need not refer to ordinary data stored on disk.

Several filesystems, one tree

/
├── home/       user files
├── mnt/        a temporary mount point
└── media/      removable media mount points

Mounting makes another filesystem visible at a directory.
The device node might be /dev/sdb1; its files appear at the mount point.

The current directory

Notation Meaning
. Current working directory
.. Parent directory
/ Root directory
~ Your home directory, expanded by the shell
$HOME Variable containing your home path
$PWD Variable containing the current directory path

Absolute and relative paths

Current directory: /home/alice

Path Interpretation
/home/alice/notes.txt Absolute: start at /
notes.txt Relative: start in the current directory
./notes.txt The same relative path
../bob/notes.txt Go to the parent, then into bob

A path tells us where to look. Permissions determine whether access is allowed.

Listing directory entries

ls
ls -l
ls -a
ls -la /home/alice
  • -l adds details, including ownership and permissions.
  • -a includes names beginning with ., such as .bashrc.
  • ls directory lists that directory's contents.

Creating and removing directories

mkdir practice
rmdir practice

rmdir removes an empty directory.

rm -r practice also removes the directory's contents.
Shell deletion does not send files to a recycle bin.

Creating, copying and moving files

touch notes.txt
cp notes.txt notes-copy.txt
mv notes-copy.txt archive.txt
rm archive.txt

touch creates a missing file, or updates timestamps of an existing file.

Reading text files

Command Result
cat notes.txt Print the whole file
less notes.txt Browse interactively, q to quit
more notes.txt Browse a page at a time
head -n 5 notes.txt Print the first five lines
tail -n 5 notes.txt Print the last five lines
diff old.txt new.txt Show differences between two files

Why is less called less?

Mark Nudelman was investigating errors in large logs.
He wanted to read the lines before an error.

His version of more could not move backward.
The new pager’s name joked about a backward more.

less app.log

Concatenating files

cat first.txt second.txt
cat
cat first.txt - second.txt
  • With filenames, cat prints their contents in argument order.
  • Without filenames, cat reads standard input.
  • A standalone - means read standard input here.
  • At an empty terminal input line, Ctrl+D indicates end of input.

The third command reads first.txt, then your keyboard input, then second.txt.

A space can change the arguments

We want to read one file named meeting notes.txt.

Without quotes

cat meeting notes.txt

cat receives two filenames:

  • meeting
  • notes.txt

With quotes

cat "meeting notes.txt"

cat receives one filename:

  • meeting notes.txt

Quotes keep the filename together. The surrounding " characters are not passed to cat.

Three ways to protect a space

Each command passes the same filename: meeting notes.txt.

Form What you type
Single quotes cat 'meeting notes.txt'
Double quotes cat "meeting notes.txt"
Backslash cat meeting\ notes.txt

The surrounding quotes and the backslash protect the space. They are not part of the filename.

Patterns select matching filenames

The directory contains only a.txt and meeting notes.txt.

cat *.txt

The shell finds the matches, then passes two filenames to cat:
a.txt and meeting notes.txt.

Pattern Matches
* Zero or more characters
? Exactly one character
[abc] One character from the set

The space inside a matched filename stays intact.

Quotes keep a pattern literal

Same directory: a.txt and meeting notes.txt.

Let the shell find matches

cat *.txt

cat receives two filenames:

  • a.txt
  • meeting notes.txt

It reads both files.

Protect the star with quotes

cat '*.txt'

cat receives one filename:

  • *.txt

No file has that literal name here: cat reports an error.

cat "*.txt" and cat \*.txt also pass a literal *.

Single quotes or double quotes?

HOME stores your home directory, here /home/alice. $HOME asks for its value; echo prints its arguments.

What you type What you see
echo '$HOME' $HOME
echo "$HOME" /home/alice

Single quotes keep $HOME literal. Double quotes allow it to expand. Both protect spaces and filename pattern characters such as *.

With double quotes, we can use the variable and protect the space:

cat "$HOME/meeting notes.txt"

Checkpoint: files and paths

  1. What does cd .. do?
  2. Which ls option includes hidden entries?
  3. What does cat a.txt b.txt print first?
  4. Which filename does cat '*.txt' try to open?
  1. Move to the parent directory.
  2. -a
  3. The contents of a.txt.
  4. The literal filename *.txt. The shell does not expand the star.

3. Who may access this file?

Why can I read this file, but cannot change or delete it?

Users, groups and ownership

whoami
id
ls -ld .
ls -l
  • id shows your user identity and groups.
  • ls -l shows the file’s owner, group and permission bits.
  • ls -ld inspects a directory itself.

Permission classes

-rwxr-xr--
  u  g  o
Class Applies to
u The file's owner
g Members of the file's group
o Other users
a All three classes when using chmod

What r, w and x allow

Bit Regular file Directory
r Read contents List entry names
w Modify contents Add or remove entries*
x Execute Search / traverse

*Changing directory entries also requires search permission. Other restrictions, such as the sticky bit, may apply.

Changing permission bits

chmod u+x script.sh
chmod go-w notes.txt
chmod u=rw,g=r,o= notes.txt
  • + adds the selected permission bits.
  • - removes them.
  • = sets the selected class to the listed permissions.

Numeric permissions

Each class adds its bit values: r = 4, w = 2, x = 1.

Owner Group Others
rwx = 7 rw- = 6 r-- = 4
chmod 764 notes.txt

The three digits describe owner, group, others, in that order.

Checkpoint: permissions

  1. Decode 640 for a regular file.
  2. Add execute permission for the owner of run.sh.
  3. Which directory bit allows traversal?
  1. Owner: rw-
    Group: r--
    Others: ---
  2. chmod u+x run.sh
  3. x

“I can see the name, but cannot read it”

# Illustrative server metadata
 drwxr----- alice students  shared/
 -rw-r----- alice students  shared/notes.txt

Bob belongs to students. He can list the names, but cannot open notes.txt. Why?

The directory’s group bits lack x: traversal.
If team access is intended, the owner can add g+x.

CM1 summary: files and permissions

  1. Locate configuration, software, data and logs.
  2. List and read files; quote names containing spaces.
  3. Check owner, group and other permissions.

Optional reference

Examples to revisit during TD or personal practice

Operating system, shell and GUI

Layer What it gives us
Operating system Processes, storage and access control
Graphical interface Windows, menus and direct visual interaction
Shell Commands we can combine and save in scripts
Application A task-specific tool, such as Excel or a database

Your laptop can run Windows while the company’s application runs on Linux. You need to work with both.

Path components and word counts

dirname /home/alice/notes.txt
basename /home/alice/notes.txt
wc -w notes.txt
  • dirname prints /home/alice.
  • basename prints notes.txt.
  • wc -w counts words. wc -l counts newline characters.

Builtins and external commands

Builtin

Implemented inside the shell.

cd ..

Can change the current shell's state.

External program

Loaded from an executable file.

ls -l

The shell searches directories in PATH.

Recognising a command

type cd
type ls
type -a echo
help cd

type reports how Bash resolves a name.
help documents its builtins.

Seeing each argument with printf

Only two files: a.txt and meeting notes.txt.

printf '<%s>\n' displays each following argument on its own line.

printf '<%s>\n' *.txt
<a.txt>
<meeting notes.txt>

Two filename arguments.

printf '<%s>\n' '*.txt'
<*.txt>

One literal argument.

Université de Rennes Louis Ledoux