alias not working in console

Booting, installing, newbie
Post Reply
Message
Author
vientito
Posts: 83
Joined: Sun 17 Sep 2006, 23:22

alias not working in console

#1 Post by vientito »

this may be a very stupid thing, but i try various tricks and still could not get it to work. i hope someone could spot what's wrong here.

i define a few aliases in /etc/profile.local like follows:

alias ll='ls -cl'

but for some strange reason they never appear later after boot when i click on desktop "console" to run rxvt.

the shell seems not to get it at all.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#2 Post by GuestToo »

i'm not sure why aliases in /etc/profile do not apply when you open a console ... i think setting the prompt in /etc/profile does not work either

i think the correct place to put aliases for bash is .bashrc ... they seem to work properly there ... /root/.bashrc will execute automatically when you open a console window, IF you have SHELL=/bin/bash set ... if you have SHELL=/bin/sh set, the file in ENV will execute

you can put this in /etc/profile.local if you like:

export ENV=/root/.bashrc

and .bashrc will execute when you open a console and SHELL=/bin/sh

or you could do this:

export ENV=/root/.shrc

and a file called .shrc in /root will execute ... you could have it source /root.bashrc if you want, then you only need to edit one file and it will work with both bash and sh shells

by the way, /bin/sh IS bash ... sh is just a symlink to bash ... but bash behaves differently if it is named sh

it can be complicated, but what i do is put this in /etc/profile.local:

export SHELL=/bin/sh
export ENV=/root/.bashrc

and put my aliases in .bashrc

User avatar
Gn2
Posts: 943
Joined: Mon 16 Oct 2006, 05:33
Location: virtual - Veni vidi, nihil est adpulerit

#3 Post by Gn2 »

Add the aliase to ~/ .bashrc > ('~" indicates users' "home" folder )
/etc/profile is normally sourced by /etc/skel :
And used to build a user desktop folder content. (useradd or default install behaviour)

Any I.E.. .bashrc or .xinitrc residing there are parsed/used - if none exist, the system wide defaults are used.
Aside - varied profiles may be utilized.
Environment is then local/session only - It is left to user's imagination how that may be beneficial

Normally any new aliase would necessitate logging out & back in ;
To implement in same session - type:

Code: Select all

bashrc
in CLI shell.
IIRC - Exporting Env. variable is also session only.
(User may research how to make it "stick")

Why are you using " -cl" - that has little difference to "-ll" - other than to alter time-stamp listing order. ?

Of more use - sugggest you use rm = 'rm -i'.
That applies also to "mv & cp" commands - interactive permission is then Req'd.
Serves as a reminder before any possibly dangerous task is
hastily performed
Rule of thumb - back up original BEFORE committing.to un-recoverable event ~

http://www.yolinux.com/TUTORIALS/unix_f ... users.html

HTH.

GuestToo
Puppy Master
Posts: 4083
Joined: Wed 04 May 2005, 18:11

#4 Post by GuestToo »

sugggest you use rm = 'rm -i'
that's why i usually use rm -f in a script ... just in case someone has aliased rm='rm -i'

.bashrc does not execute if SHELL=/bin/sh ... i'm not sure whether Puppy's default shell is bash or sh ... they do behave differently, so i set SHELL in profile.local

by the way, there's a lot of information on the Gentoo wiki and forums ... for example:

http://gentoo-wiki.com/TIP_Some_pretty_.bashrc_hints

User avatar
Gn2
Posts: 943
Joined: Mon 16 Oct 2006, 05:33
Location: virtual - Veni vidi, nihil est adpulerit

#5 Post by Gn2 »

I suppose it is one unfortunate side affect of using Ash we must live with.
IIRC Ash is used by most distros for varied "legacy" considerations as well as initiate system installs ?

Backwards compatabilty of Bash was one of goals, in most cases there is no problem.
Then.... some odd situation arises leaving us scratching for a cause.
One reason a good install script should parse any local environment - ("else" use )
And the Bash tutorial explains in detail interactive vs execute only scripts.

Aside: Useful as " precautionary" optional parameters of CLI defaults may be - there is NO substitute to "think twice, act once"

Yes, IMO - Gentoo documentation is the present paradigm of info sourcing.

(That was :wink: one of deciding factors to use of Gentoo )
Without them - the learning curve is much steeper.

marksouth2000
Posts: 622
Joined: Wed 05 Apr 2006, 20:43

#6 Post by marksouth2000 »

According to the man page, /etc/profile is sourced by bash only when it is invoked as a login shell.

Post Reply