TCM Security Academy Notes - by syselement
🏠 Home BlogGitHub📚 Buy Me a Book
  • TCM Security Academy Notes
  • Courses
    • TCM - Linux 101
      • 1. Introduction
        • Linux Distributions
        • Installing Linux
      • 2. Command Line
        • Intro to Command Line
        • Getting help on the Command Line
        • Command Line Arguments and Options
        • Reading Text Files
      • 3. File System
        • Filesystem Hierarchy Standard
        • Devices, Partitions and Mounting
        • Absolute and Relative Paths
        • Files and Directories
        • Paths, Filenames and Text Files
        • Filesystem Links
        • Archiving and Searching Files
      • 4. Users and Groups
        • Working with Users and Groups
        • File and Directory Permissions
        • Changing Users and Passwords
      • 5. Installing Software
        • Package Management
      • 6. Shells
        • Common Command Line Shells
        • Environment Variables & Startup Files
        • Input/Output Redirection
        • Command History & Substitution
      • 7. Utilities and File Editors
        • Searching and Processing Text
        • Networking at the Command Line
        • File Transfer
        • Text Editors and Converters
      • 8. Process Management
        • Process Information
        • Foreground and Background Processes
        • Managing Processes
        • Scheduling Processes
      • 9. Regular Expressions
        • Regular Expressions, Searching, Replacing, Building
      • 10. Bash Scripting
        • Bash Scripting Basics, Control Structures, Loops
      • 🌐Linux101 References
    • TCM - Mobile Application Penetration Testing
      • 1. Introduction & Mobile Pentesting
      • 2. Android Security
      • 3. Android Lab Setup
      • 4. Android Static Analysis
      • 5. Android Dynamic Analysis
      • 6. Android Bug Bounty
      • 7. iOS Security
      • 8. iOS Lab Setup
      • 9. iOS Static Analysis
      • 10. iOS Dynamic Analysis
      • 11. iOS Bug Bounty
      • 🌐MAPT References
    • TCM - Practical Ethical Hacking
      • 1. Introduction & Networking
      • 2. Lab Set Up, Linux & Python
        • Intro to Kali Linux
        • Intro to Python
      • 3. The Ethical Hacker Methodology
        • Information Gathering
        • Scanning & Enumeration
        • Vulnerability Scanning with Nessus
        • Exploitation Basics
        • Capstone Practical Labs
      • 4. Active Directory
        • Active Directory Lab
        • AD - Initial Attack Vectors
        • AD - Post-Compromise Enumeration
        • AD - Post-Compromise Attacks
        • AD - Additional Attacks
        • AD - Case Studies
      • 5. Post Exploitation
      • 6. Web Application
        • Web App Lab Setup
        • Web App - SQL Injection
        • Web App - XSS
        • Web App - Command Injection
        • Web App - Insecure File Upload
        • Web App - Authentication Attacks
        • Web App - XXE
        • Web App - IDOR
        • Web App - Capstone Practical Lab
      • 7. Wireless Attacks
      • 8. Legal Documentation & Report Writing
      • 🌐PEH References
  • 🏠syselement's Blog Home
Powered by GitBook
On this page
  • ln
  • Hard Link
  • Soft - Symbolic Link

Was this helpful?

Edit on GitHub
  1. Courses
  2. TCM - Linux 101
  3. 3. File System

Filesystem Links

  • Linux offer shortcut function through links.

  • A link is a reference or a pointer to a file or directory somewhere on the file system.

  • There are two types of links: hard and soft (symbolic) links.

ln

  • ln - make links between files

ln --help
	Usage: ln [OPTION]... [-T] TARGET LINK_NAME
	  or:  ln [OPTION]... TARGET
	  or:  ln [OPTION]... TARGET... DIRECTORY
	  or:  ln [OPTION]... -t DIRECTORY TARGET...
	In the 1st form, create a link to TARGET with the name LINK_NAME.
	In the 2nd form, create a link to TARGET in the current directory.
	In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
	Create hard links by default, symbolic links with --symbolic.
	By default, each destination (name of new link) should not already exist.
	When creating hard links, each TARGET must exist.  Symbolic links
	can hold arbitrary text; if later resolved, a relative link is
	interpreted in relation to its parent directory.
  • By default ln creates a Hard Link.

Hard Link

  • A hard link points to the physical location of the file on storage.

    • If the original file is moved or deleted a hard link continues to work. The file will be completely deleted when there are no hard links to the file.

    • Hard links are older and less frequently uses.

    • Cannot create directory hard link.

cat hello.txt 
	Hello

ln hello.txt hello-hard-link.txt

ls hello*
	hello-hard-link.txt  hello.txt

# After editing the original hello.txt file, the change is visible in the hello-hard-link.txt file
cat hello.txt
	Hello World!!!

cat hello-hard-link.txt
	Hello World!!!

# If original file is delete, the link file still exists with the same content
rm hello.txt 
cat hello-hard-link.txt
	Hello World!!!

# Recreate the original file
ln hello-hard-link.txt hello.txt

Soft - Symbolic Link

  • A symbolic link references the file or directory on the file system, not on storage.

    • If the resource is moved or deleted from the file system, the symbolic link will not work.

    • Always use absolute paths for soft links targets.

    • Soft links can cross file systems.

    • Directory soft links can be created.

    • There are many internal system symbolic links.

ln -s ./hello.txt hello-soft-link.txt

ls -l hello*
	-rw-rw-r-- 2 user user 15 ago 28 19:50 hello-hard-link.txt
	lrwxrwxrwx 1 user user 11 ago 28 19:56 hello-soft-link.txt -> ./hello.txt
	-rw-rw-r-- 2 user user 15 ago 28 19:50 hello.txt

# The soft link created references the original hello.txt file
cat hello-soft-link.txt 
	Hello World!!!

# If original file is moved, the soft link won't work
mv hello.txt hello-new.txt
cat hello-soft-link.txt
	cat: hello-soft-link.txt: No such file or directory

PreviousPaths, Filenames and Text FilesNextArchiving and Searching Files

Last updated 2 years ago

Was this helpful?