0% found this document useful (0 votes)
61 views7 pages

Soft Link and Hard Link

The document discusses soft links and hard links, which are two types of links used in file systems. Soft links are pointers to other files or directories, while hard links share the same data blocks as the original file. The document also covers wildcards used to match multiple files in operating systems using patterns, and defines relative and absolute paths used to specify file locations.

Uploaded by

Mahwish Pervez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views7 pages

Soft Link and Hard Link

The document discusses soft links and hard links, which are two types of links used in file systems. Soft links are pointers to other files or directories, while hard links share the same data blocks as the original file. The document also covers wildcards used to match multiple files in operating systems using patterns, and defines relative and absolute paths used to specify file locations.

Uploaded by

Mahwish Pervez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Soft link and hard link:

Soft links (symbolic links) and hard links are two types of links used in file systems to
associate one file with another. Both types of links are ways to create references to files,
but they have different characteristics and use cases

• Definition:
A soft link is a pointer or reference to another file or directory. It is a separate file that
contains a path to the target file or directory.

• Characteristics:
o The size of a soft link is typically small, as it only contains the path to the target file.
o If the target file is deleted or moved, the soft link becomes a "dangling link" and will no
longer point to a valid location.
• Soft links can span file systems, allowing links to files or directories located on different
partitions.
• They can link to non-existent targets without causing errors.

For example: ln -s /path/to/target_file /path/to/soft_link

Hard Link:

• Definition:
A hard link is an additional reference to an existing inode (data structure on disk
representing a file). Hard links essentially share the same data blocks on the disk with the
original file.
• Characteristics:
o All hard links to a file are essentially equal; there is no concept of the "original" file.
o Deleting any hard link does not affect the other links as long as there is at least one
remaining.
o Hard links cannot span file systems; all links must be on the same partition or disk.
o Changing the content of any link affects all other links since they point to the same data
blocks.
For example: ln /path/to/target_file /path/to/hard_link

To verify the link type and see where the link points, you can use the dir command
with the /a option:
dir /a C:\LinkToFolder
dir /a C:\LinkToFile.txt
Wildcard
Wildcards in operating systems are characters or combinations of characters that represent
unknown or multiple characters in file and directory names. They are used with commands
to perform operations on groups of files that match a specific pattern. Wildcards provide a
convenient way to work with multiple files without specifying each file's exact name. Here
are some common wildcards used in various operating systems:

1. Asterisk (*) - Match any sequence of characters

Example (on Windows and Unix-like systems):


*.txt matches all files with a ".txt" extension.
file* matches any file that starts with "file."

2. Question Mark (?) - Match any single character

Example:
file?.txt matches files like "file1.txt," "fileA.txt," etc., where "?" represents a single
character.

3.. Square Brackets ([ ]) - Match any single character within the specified
range or set

Example:
[abc]file.txt matches "afile.txt," "bfile.txt," or "cfile.txt."
[0-9]file.txt matches any single digit followed by "file.txt."

4. Curly Braces ({ }) - Match any of the comma-separated values

Example:{jpg,gif,png} matches files with a ".jpg," ".gif," or ".png" extension.


5. Double Asterisk (**) - Recursive matching (commonly in Unix-like
systems)

Example (using find command):


find /path/to/directory -name "*.txt" matches all ".txt" files in the specified directory
and its subdirectories
.
Operating System-Specific Examples:
dir *.txt :: List all files with a ".txt" extension
del file?.txt :: Delete files like "file1.txt," "fileA.txt," etc.
copy [abc]*.txt C:\Destination :: Copy files starting with "a," "b," or "c" and having a ".txt"
extension to C:\Destination
Relative path and absolute path:-

In operating systems, a file or directory path is a representation of the location of a file or


directory within the file system. There are two types of paths used to specify the location
of a file or directory: relative paths and absolute paths.

You might also like