LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 06-25-2012, 01:31 PM   #1
Jobin1
LQ Newbie
 
Registered: Jun 2012
Posts: 5

Rep: Reputation: Disabled
Making a program executable from any directory with one command


Hello,
I am working on making a program executable with one command (more specifically, the program is MATLAB). I need to make it executable with just the command "matlab." I have tried making an alias with the following:

alias matlab='cd /pathway_to_matlab | ./matlab'

but the error I get is:
-bash: ./matlab: No such file or directory.

How do I make an alias that both gets me to the necessary directory AND executes the command ./matlab?
 
Old 06-25-2012, 01:37 PM   #2
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
I think just
Code:
alias matlab='/path/to/matlab/matlab'
should work.
 
Old 06-25-2012, 01:56 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Several options...

Put this in your ~/.bashrc:
Code:
alias matlab='/path/to/matlab/matlab'
Or put this in your ~/.bashrc:
Code:
export PATH=${PATH}:/path/to/matlab
Or run this once (as root/sudo):
Code:
ln -s /path/to/matlab/matlab /usr/local/bin/
 
Old 06-25-2012, 01:58 PM   #4
Terminal_Cowboy
Member
 
Registered: Jun 2012
Distribution: Gentoo (Host), Arch (Guest), FreeBSD9, Android 2.3.6
Posts: 32

Rep: Reputation: Disabled
@ Jobin1

An alias is not permanent. It is only temporary and you will lose it after closing a terminal or a reboot.

To make it permanent add the alias to your .bashrc file in your home folder.
 
Old 06-25-2012, 03:06 PM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
can it be installed in /usr/bin/ if that is in the $PATH for the user?
 
Old 06-25-2012, 03:34 PM   #6
Jobin1
LQ Newbie
 
Registered: Jun 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
This might make things much more complicated (or maybe I'm just being stupid) but I dont appear to have a .bashrc file, at least not in my home directory. when I go to 'cd /root', and then use the command 'ls -a' I can see a .bashrc file, but it is read only and this is all on a remote terminal where I don't have permission to use sudo root or edit the .bashrc file... is this just something I am going to have to deal with (making the alias every time I log into the terminal)?
 
Old 06-25-2012, 04:02 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
You don't want to edit root's .bashrc file, unless you'll be doing this as root. Things you change in root's .bashrc will not affect regular users.

You just need to find the login file your system uses. It could be that your system uses .bashrc, and you just don't have one yet, or it could use something else like .profile, .bash_profile, etc. Are you using the BASH shell (echo $SHELL)?
 
  


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
How can I install a program and have it accessible as a command from any directory? bcarl6 Linux - Newbie 3 12-23-2010 10:34 PM
SELinux is preventing Firefox from making the program stack executable alan_ri Fedora 3 11-03-2010 07:52 PM
making script executable; getting no such file or directory madwida Slackware 4 10-08-2008 09:19 AM
Making an executable/path into a command kc0ltv SUSE / openSUSE 2 01-22-2006 01:28 AM
how do I make a program executable through the command prompt? iammeuno Linux - Software 1 12-18-2003 03:29 PM

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

All times are GMT -5. The time now is 08:26 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