Symbolische Links erstellen und verwenden
Lernen Sie, symbolische und Hardlinks zu erstellen, zu untersuchen und zu verwalten, um Dateien flexibel zu organisieren, ohne Daten zu kopieren.
Symbolische Links erstellen und verwenden ist eine kostenlose Linux Command Line Mastery-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Linux Command Line Mastery-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Linux Command Line Mastery-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
What Is a Link
A link is a filesystem entry that points to another file. Links let one file appear in multiple places without duplicating its data, saving space and easing organization.
Linux has two kinds: symbolic links and hard links.
Creating a Symbolic Link
A symbolic link (symlink) is a small file holding a path to its target. Create one with ln -s: the target first, then the link name.
ln -s /var/log/app.log current.logInspecting Links
ls -l shows symlinks with an arrow pointing to their target, and the type character l at the start of the permissions.
ls -l current.log
# lrwxrwxrwx 1 user user 16 ... current.log -> /var/log/app.logFollowing a Link
Reading or writing through a symlink transparently affects the target. Editing current.log edits /var/log/app.log.
cat current.log # reads the target file's contentsHard Links
A hard link is a second name for the exact same data on disk. Both names are equal; deleting one leaves the data until the last link is gone.
ln original.txt backup.txt # no -s means hard linkSymbolic vs Hard
Key differences:
- Symlinks can cross filesystems and link directories; hard links cannot.
- A symlink breaks if its target moves; a hard link keeps the data alive.
- Symlinks store a path; hard links share an inode.
Broken Links
If a symlink's target is deleted or moved, the link becomes dangling. Accessing it fails. ls often shows broken links in red.
rm /var/log/app.log
cat current.log # error: No such file or directoryFinding the Target
Use readlink to print where a symlink points, and readlink -f to resolve the full real path through chained links.
readlink current.log
readlink -f current.logUpdating and Removing Links
To repoint a symlink, use ln -sf to force-replace it. To remove a link, rm deletes the link itself, never the target file.
ln -sf /var/log/new.log current.log # repoint
rm current.log # remove the link onlyPractical Uses
Symlinks shine for:
- A stable
currentpath pointing at the latest versioned release. - Putting config files in a dotfiles repo, linked into
$HOME. - Sharing a dataset across projects without copies.
Listing All Links in a Directory
To audit existing links, combine ls with a filter. The find command can list every symlink under a path, helping you spot broken or stray ones.
find . -type lQuick Check
Test your understanding of links.
Recap
You learned to work with links: create symlinks with ln -s, inspect them with ls -l and readlink, understand hard vs symbolic differences, recognize broken links, repoint with ln -sf, and apply them to releases, dotfiles, and shared data.
Häufig gestellte Fragen
Ist die Lektion „Symbolische Links erstellen und verwenden“ kostenlos?
Ja — der vollständige Text von „Symbolische Links erstellen und verwenden“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Linux Command Line Mastery-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Linux Command Line Mastery-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Symbolische Links erstellen und verwenden“?
Lernen Sie, symbolische und Hardlinks zu erstellen, zu untersuchen und zu verwalten, um Dateien flexibel zu organisieren, ohne Daten zu kopieren. Du übst Linux Command Line Mastery mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Linux Command Line Mastery zu starten?
Keine Vorkenntnisse erforderlich. Linux Command Line Mastery auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Symbolische Links erstellen und verwenden“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Linux Command Line Mastery-Lektion Code schreiben und ausführen?
Ja. Jede Linux Command Line Mastery-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Dateiinhalte anzeigen: `cat`, `less`, `more`
- Dateien suchen: `find` und `locate`
- Berechtigungen und Besitz: `chmod`, `chown`
- Symbolische Links erstellen und verwenden