LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Do I have to type /sbin/ (https://www.linuxquestions.org/questions/linux-newbie-8/do-i-have-to-type-sbin-447374/)

snay 05-22-2006 10:49 AM

Do I have to type /sbin/
 
Ive been using linux for a while now. Moved from opensuse 10 over to fedora core 5, just to try it out really. I quite like it, but one thing bugs me. I am constantly typing /sbin/ for commands. Now I know I dont have to, because I never used to in Suse, but how do I set up the console to work without me typing /sbin/
Im guessing its something to do with the alias command, but Im haveing some problems with the alias command. How do I get rid of lines? specifically rm=rm -i
I would experiment, but I dont want to untill I know I can get rid of any dodgy lines in the alias command.
Thanks.
Tony.

rjwilmsi 05-22-2006 11:12 AM

Add alias lines to your .bashrc file in your home directory. Lines like

alias rip='cdparanoia "1-" -v'

work fine. If you want to remove them, just edit .bashrc and restart Konsole.

pljvaldez 05-22-2006 11:18 AM

I believe you alias commands should be in the file ~/.bashrc. Just comment out the line that says alias rm=`rm -i`

I believe you can add EXPORT PATH=/sbin: $PATH to the top of your .bashrc file and/or ~/.bash_profile. Then just do a source .bashrc and it should apply it to the current session. Otherwise, just logout and log back in, then type echo $PATH and see if it's been added.

marozsas 05-22-2006 11:19 AM

For commands you have to type /sbin in front, there is 2 ways to solve this:

create an alias for it in .bashrc, e.g.,
Code:

alias fdisk='/sbin/fdsk'
or append /sbin to your path. Do that in .profile:
Code:

export PATH=${PATH}:/sbin
To fix 'rm', search where this alias is set (.bashrc, .alias, .profile) or clear the alias with the command "unalias rm". "unalias -a" will clear all aliases defined.

Lotharster 05-22-2006 11:26 AM

You should add sbin to your $PATH - variable. Whenever you type the name of some application in terminal, bash looks for an executable file with that name in the directories in the $PATH - variable.
The path variable consists of several colon-seperated directories. This is mine:
Code:

PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
You can simply add /usr/sbin/ via:
Code:

PATH="${PATH}:/usr/sbin"
However, that will only set the path variable for your current session. If you want to have it in your path variable whenever you login, you should put it into ~/.bash_profile. If you want it to be in the path variable of every user, you can modify /etc/profile and change the path variable there.

ethics 05-22-2006 11:27 AM

There is a reason these files are in /sbin/ it's because they are generally supposed to be called by root (who should have sbin in his path by default). I use Sudo but still maintain typing the /sbin/ path so that i don't become complacent about when and as whom i am running these commands as.

PTrenholme 05-22-2006 11:29 AM

By way of clarification, a "normal" user should not need to use any of the commands in /sbin since they are (mostly) related to system administration tasks. For example, the rm command is in /bin, not /sbin.

That said, where your system looks for commands is controlled by the values of $PATH. The settings I have are like this:
Code:

[peter ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/home/peter/bin
[peter ~]$ su -
Password:
[root@tss-4 ~]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

You can change what's in $PATH by editing /etc/profile so it calls pathmunge for the directories you want to add.


All times are GMT -5. The time now is 03:08 PM.