LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Running a command from anywhere (https://www.linuxquestions.org/questions/linux-newbie-8/running-a-command-from-anywhere-150207/)

tez 02-24-2004 11:27 PM

Running a command from anywhere
 
Hi all,

Running Slackware 9.1, and havesetup the sudoers file to allow shutdown for all users.


How can I get it so I can type shutdown in any directory (logged in as a user) and it being able to run instead of changing to /sbin to run it?

Thanks

Demonbane 02-24-2004 11:31 PM

Put /sbin in your path, or just make an alias in your bash profile.
eg
Code:

alias shutdown='/sbin/shutdown'

tez 02-24-2004 11:34 PM

Hi,

Fellow Sydney nix user :)

Where do I put that in? where's the file?

:confused:

Demonbane 02-24-2004 11:41 PM

Good to see fellow Aussie Linux users around here :-)
It depends on the distro, but ~/.bash_profile for per user setting and /etc/profile for system wide should work most of the time.
If it worked you should see it when you type "alias".

tez 02-27-2004 09:54 PM

So if I dont have a bash_profile or bashrc, when I create one, what do these need to contain?

Demonbane 02-27-2004 10:07 PM

something like
Code:

#!/bin/bash
                                                                               
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

alias shutdown='/sbin/shutdown'



All times are GMT -5. The time now is 12:45 AM.