LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-26-2010, 05:39 PM   #1
cruzdelsur
Member
 
Registered: Aug 2010
Location: Chile
Distribution: Ubuntu 12.04
Posts: 69

Rep: Reputation: 0
a basic question about program shorcuts


Hello guys,

I need help with a newbie issue... it's just a basic thing, but it is not working. I have installed R (in Trisquel 4, a gnome ubuntu-like distro), a software that must be used from the terminal. Therefore, I want to create a shortcut to it, to avoid typing the whole route to the program: i.e. just typing R and that the program starts...

So, here is what I did:
Code:
 sudo ln /bin/R-2.11.1./bin/R R
But when I type "R", it doesn't start.
Before you ask, yes, the folder is called "R-2.11.1." and the installation was succesfull because I have tried it and it works.
If I type
Code:
/bin/R-2.11.1./bin/R
, it does run...

So... where is my mistake? Do I need to move the shortcut somewhere else?

Thanks guys!
 
Old 09-26-2010, 06:37 PM   #2
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
I think you need a symbolic link, the command should be:
Code:
 sudo ln -s R /bin/R-2.11.1./bin/R


This should give a link called "R" to the pathname "/bin/R-2.11.1./bin/R"

It usually takes me a couple of times to get it right too.

Play Bonny!
 
Old 09-26-2010, 07:02 PM   #3
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
And actually, in the above example, the TARGET of the link (the R binary) should come before the LINKNAME (your new symlink), so:
Code:
ln -s /bin/R-2.11.1./bin/R /path/to/your/new/R
That's `ln` 1st form of usage, from the manpage:
Quote:
SYNOPSIS
ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
And.. Make sure your new symlink is placed somewhere in your $PATH or the problem will still remain the same.

Last edited by GrapefruiTgirl; 09-26-2010 at 07:04 PM.
 
Old 09-26-2010, 11:13 PM   #4
rkski
Member
 
Registered: Jan 2009
Location: Canada
Distribution: CentOS 6.3, Fedora 17
Posts: 247

Rep: Reputation: 51
Do you really want an alias:

Code:
alias R='/bin/R-2.11.1./bin/R'
 
Old 09-27-2010, 08:24 AM   #5
cruzdelsur
Member
 
Registered: Aug 2010
Location: Chile
Distribution: Ubuntu 12.04
Posts: 69

Original Poster
Rep: Reputation: 0
Well, thanks for your replies and ideas!! I'm not at my Linux computer right now, but when I come back home I'll give it a try!! I'll post later again! Thanks!
 
Old 09-27-2010, 09:36 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Quote:
Originally Posted by cruzdelsur View Post
Well, thanks for your replies and ideas!! I'm not at my Linux computer right now, but when I come back home I'll give it a try!! I'll post later again! Thanks!
You could setup a .bashrc & .bash_profile for your user;

Code:
sample .bash_profile;
Code:
 
 ~$ cat .bash_profile
 # .bash_profile
 #08-30-06 12:21
 #
 # Source .bashrc
 if [ -f ~/.bashrc ]; then
         . ~/.bashrc
 fi
Code:
 sample .bashrc;
 :~$ cat .bashrc
 
 #.bashrc
 #08-30-06 12:20 
 
 # Add bin to path
 
 export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"
 
 #export PATH="$PATH:$HOME/bin"
 
 # Dynamic resizing
 shopt -s checkwinsize
 
 # Custom prompt
 #PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 
 #08-29-06 11:40
 
 if [ `id -un` = root ]; then
    PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
  else
    PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
 fi
 
 #
 # Add color
 eval `dircolors -b`
 
 # User defined aliases
 alias cls='clear'
 alias clls='clear; ls'
 alias ll='ls -l'
 alias lsa='ls -A'
 alias lsg='ls | grep'
 alias lsp='ls -1 /var/log/packages/ > package-list'
 alias na='nano'
 alias web='links -g -download-dir ~/ www.google.com'

#new User Alias for 'cruzdelsur'
alias uR='/bin/R-2.11.1./bin/R'

 #08-29-06 11:50
 
 #To clean up and cover your tracks once you log off
 #Depending on your version of BASH, you might have to use
 # the other form of this command
    trap "rm -f ~$LOGNAME/.bash_history" 0
 
 #The older KSH-style form
 #   trap 0 rm -f ~$LOGNAME/.bash_history
The .bashrc is very useful!

 
Old 09-27-2010, 09:54 AM   #7
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by cruzdelsur View Post
Hello guys,

I need help with a newbie issue... it's just a basic thing, but it is not working. I have installed R (in Trisquel 4, a gnome ubuntu-like distro), a software that must be used from the terminal. Therefore, I want to create a shortcut to it, to avoid typing the whole route to the program: i.e. just typing R and that the program starts...
What you probably want then is called an "alias", you should check the docs for your shell to discover how to set up an alias for a given command, in bash you just put the right command on your ~/.bashrc and/or ~/.bash_profile depending on what do you exactly want. "man bash" will give you more info about that.

Code:
alias r='/path/to/R'
Then just run "r" after restarting your shell.

Quote:
So, here is what I did:
Code:
 sudo ln /bin/R-2.11.1./bin/R R
But when I type "R", it doesn't start.
Before you ask, yes, the folder is called "R-2.11.1." and the installation was succesfull because I have tried it and it works.
If I type
Code:
/bin/R-2.11.1./bin/R
, it does run...
You are assuming that the current directory will be in your search $PATH, but that's not true in Linux for security reasons (unlike in DOS).

Quote:
So... where is my mistake? Do I need to move the shortcut somewhere else?

Thanks guys!
You either use an alias, or put the link into a directory that's in your path, or just add /bin/bin (weird path by the way) to your $PATH, that way you can run 'R' directly without needing any intermediaries.
 
Old 09-28-2010, 02:24 AM   #8
cruzdelsur
Member
 
Registered: Aug 2010
Location: Chile
Distribution: Ubuntu 12.04
Posts: 69

Original Poster
Rep: Reputation: 0
Hi people!!
The alias did the trick!! Thank you all for your help!! You're great!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
basic html question - download link to files on my webpage question Davno Linux - Server 5 12-25-2009 07:24 AM
Keyboard shorcuts - adding a command? compu73rg33k Linux - Software 4 12-23-2006 07:35 PM
Visual Basic like program for Linux shortname Linux - Software 1 02-07-2005 08:12 PM
shorcuts in linux console jayakrishnan Linux - General 4 09-01-2002 05:15 AM
Shorcuts!!! DaDdY SnEb Linux - Newbie 4 06-21-2002 12:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration