Which command creates a hard link named linkname to a file named file?

Prepare for the Red Hat Certified Systems Admin Exam EX200. Enhance your skills with interactive quizzes, flashcards, and detailed explanations. Ace your certification exam today!

Multiple Choice

Which command creates a hard link named linkname to a file named file?

Explanation:
Hard links are created with the ln command by giving the original file as the source and the new link name as the target. This makes linkname a new directory entry that points to the same inode as file, so both names access the exact same data. That’s why the command without extra options—ln file linkname—is the correct way to create a hard link. Using -s would make a symbolic link, which is just a pointer to the target rather than another directory entry for the same inode. Copying with cp would duplicate the file’s contents into a new file, not a link. The -f option merely forces removal of the destination if it exists, which isn’t about creating a link. Remember, hard links are for regular files on the same filesystem, sharing the same inode.

Hard links are created with the ln command by giving the original file as the source and the new link name as the target. This makes linkname a new directory entry that points to the same inode as file, so both names access the exact same data. That’s why the command without extra options—ln file linkname—is the correct way to create a hard link.

Using -s would make a symbolic link, which is just a pointer to the target rather than another directory entry for the same inode. Copying with cp would duplicate the file’s contents into a new file, not a link. The -f option merely forces removal of the destination if it exists, which isn’t about creating a link.

Remember, hard links are for regular files on the same filesystem, sharing the same inode.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy