What is the difference between -l and -s?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 12 2025
0104

The difference between -l and -s options in the cp command is as follows:

  • -l (Link): This option creates hard links to the source files instead of copying them. Hard links point to the same inode on the filesystem, meaning that both the original and the link refer to the same data. If you modify the file through one link, the changes will be reflected in the other.

  • -s (Symbolic Link): This option creates symbolic (or soft) links to the source files. A symbolic link is a separate file that points to the original file's path. If the original file is moved or deleted, the symbolic link will break and no longer point to a valid file.

Example:

  • Using -l:

    cp -l source.txt link_to_source.txt

    This creates a hard link named link_to_source.txt that points to source.txt.

  • Using -s:

    cp -s source.txt symlink_to_source.txt

    This creates a symbolic link named symlink_to_source.txt that points to source.txt.

If you have further questions or need clarification, feel free to ask!

0 Comments

no data
Be the first to share your comment!