Symlink for .sh files

phoeneousphoeneous Member Posts: 2,333 ■■■■■■■□□□
Running Centos 6 and trying to execute pycharm.sh from any directory. I've extracted it to /home/phoeneous/Downloads/pycharm-community-3.4/bin. My path is /usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/phoeneous/bin. How can I link pycharm.sh and run it from any directory? I've tried ln -s /path/to/pycharm.sh pycharm but I still get bash: pycharm: command not found. Pretty sure I'm doing it wrong.

Comments

  • phoeneousphoeneous Member Posts: 2,333 ■■■■■■■□□□
    Fixed:

    sudo ln -s /home/phoeneous/Downloads/pycharm-community-3.4/bin/pycharm.sh /usr/bin/pycharm
  • tomtom1tomtom1 Member Posts: 375
    ​Bit of background info:
    You can only run something without giving the full path when the link to the binary is in the $PATH. On a Linux or UNIX based system, just try this for fun:

    echo $PATH

    It'll give you something like this.

    /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

    Everything that's in one of these directories can be called directly without the absolute path.
  • W StewartW Stewart Member Posts: 794 ■■■■□□□□□□
    Like tomtom1 suggested, you're getting command not found because you didn't specify either a full path or relative path to pycharm.sh. Linux doesn't just run a file in the current directory like windows does. You would need to specify the current directory with ./pycharm.sh.

    Although symlinking the file to whatever random directory you're in and trying to run it is the wrong way to go about it if you want to be able to run the file from any directory. The easiest way to do it would be to put the file into a directory that is already in your $PATH environment variable. Putting it in /home/phoeneous/bin or /usr/local/bin would probably be the best way to do it. Then you could run the file without specifying an absolute or relative path.
  • phoeneousphoeneous Member Posts: 2,333 ■■■■■■■□□□
    Understood, thanks~!
Sign In or Register to comment.