Solved

add softlink to a directory Centos linux

Posted on 2012-03-21
9
864 Views
Last Modified: 2012-03-31
I wish to create a link to /usr/local/apache/htdocs by simply typing in "htdocs" at the prompt. I was reading other sites but I couldn't get it to work. Do I have to be root all the time to make this link work or can I be logged in as my own personal user?

In a related question, I wish to create link to:
/home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh by simply typing in at any prompt "pstorm"

Thank you for your help,
Victor
0
Comment
Question by:Victor Kimura
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 5

Assisted Solution

by:1ly4me
1ly4me earned 250 total points
ID: 37751705
Yes you can create soft link to a file and can run under any user.
Create soft link as root user,
#ln -s /home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh /pstorm
Make sure the file phpstorm.sh has execute permission for all users. (Generally 755 permission for that file.)

That soft link pstorm, can be executed under any user, for ex for under test user run the file as
#./pstorm not as pstorm
0
 

Author Comment

by:Victor Kimura
ID: 37755164
Hi 1ly4me,

Am I doing something wrong? I changed the permission to 755 for phpstorm.sh

[root@seokingdomheaven vkimura]# ln -s /home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh /pstorm
[root@seokingdomheaven vkimura]# pstorm
bash: pstorm: command not found
[root@seokingdomheaven vkimura]# ./pstorm
bash: ./pstorm: No such file or directory
[root@seokingdomheaven vkimura]#  ln -s /home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh /pstorm
ln: creating symbolic link `/pstorm' to `/home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh': File exists
[root@seokingdomheaven vkimura]# pstorm
bash: pstorm: command not found
[root@seokingdomheaven vkimura]# ./pstorm
bash: ./pstorm: No such file or directory
0
 
LVL 5

Assisted Solution

by:1ly4me
1ly4me earned 250 total points
ID: 37756345
Type 'pwd' at the command prompt, it will return working directory.
[root@seokingdomheaven vkimura]#pwd
/home/vkimura/  -  It should return something like that.
You have created the soft link on '/' directory, which means on the base directory.

[root@seokingdomheaven vkimura]#cd /    
[root@seokingdomheaven vkimura]#./pstrom

This should work
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:Victor Kimura
ID: 37762465
Hi 1ly4me,

Oh, I see. How can I make the shortcut to work for all directories?
0
 
LVL 5

Expert Comment

by:1ly4me
ID: 37786760
I couldn't get what are you trying to set up?
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 125 total points
ID: 37787192
various solutions:
1. independent from shell (assuming that /home/vkimura/ is in your PATH environment variable)

   ln -s /home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh /home/vkimura/pstorm

2. depends on shell:

   # sh and alike
   alias pstorm=/home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh
 
   # csh and alike
   alias pstorm /home/vkimura/Downloads/PhpStorm-303/bin/phpstorm.sh

if you want these aliases permanent, you need to add these commands to the proper rc-file of the corresponding shell
0
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 125 total points
ID: 37789970
If htdocs a directory or a command? I'll assume it's a directory and you want to be able to change directory to it by typing just htdocs.
Add this line to .bashrc in your home directory
alias htdocs="cd /usr/local/apache/htdocs"

Open in new window

To link to your pstorm.sh command (and indeed to htdocs if it was a command after all), you need to create a symbolic link in a directory that is in your PATH. You can see what that is by typing echo $PATH or env|grep PATH at the command prompt. Do you have a bin directory in your home directory? If you do, you should see it in PATH. If you don't, you should make one
cd; mkdir bin

Open in new window

Next time you log in, you should see /home/vkimura/bin in the list when you echo $PATH. Now all you have to do is make a symbolic link in the new bin directory
cd ~/bin
ln -s ~/Downloads/PhpStorm-303/bin/phpstorm.sh phpstorm

Open in new window

(Instead of the tilde ("~")you could type /home/vkimura, but the Bash shell will do that expansion for you).
You can do all the above when logged in as yourself - in fact the new commands will only work when you are so logged in. There is no need to change permissions on symbolic links - actually it's impossible to do that.
0
 

Author Closing Comment

by:Victor Kimura
ID: 37790839
Thank you all. That's very helpful.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question