Which one should be the target and which one be the link name?

Update 1: I am logged in as super user, and I also got to know to access root folder using GUI.

  • 1
    Why /root/Desktop? Are you running logged in as root? That really not a good idea. – Kusalananda Oct 7 '17 at 15:32
  • @frazzerk You are not making sense. Why do you want the shortcut to be on the root user's desktop if you are not logged in using the root login (OP is getting permission denied while trying to access the root directory using the GUI). Please clarify what you want clearly with an edit – Hunter.S.Thompson Oct 7 '17 at 15:41
  • Possible cross-site duplicate of Direction of a symlink – G-Man Oct 7 '17 at 15:55
  • If an answer solved your problem, use the checkmark next to it. You may need to merge your accounts, after registering one. – Jeff Schaller Oct 7 '17 at 18:45

Almost the first line of man ln will tell you the answer to this:

ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)

It's the same order as mv and cp: source then destination. So in your case you would use something like

cd /root/Desktop
ln -s /var/log/messages messages

The -s parameter instructs ln to create a soft link rather than the default hard link.

It's possible to omit the last argument to ln in which case the source file name will be reused

cd /root/Desktop
ln -s /var/log/messages

Notice that in both cases I have changed to the destination directory. This ensures that ln -s with relative paths will work correctly and as expected. In this situation we're using an absolute path (it begins with /) but it's a good practice to start using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.