Jump to content

Slackware- /etc/profile? global aliases?


Guest SDMF
 Share

Recommended Posts

From a Mandrake 9.0/9.1 install? The part of it with the global aliases. I'm trying to get my Slackware install closer to the Mandrake one, terminal-wise, and I forgot to save a copy of my file. I want to get all the aliases set up like Mandrake had them.

Link to comment
Share on other sites

here's my whole thing from 9.1

 

# /etc/profile -*- Mode: shell-script -*-

# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>



loginsh=1



# Users generally won't see annoyng core files

[ "$UID" = "0" ] && ulimit -S -c 1000000 > /dev/null 2>&1



if ! echo ${PATH} |grep -q /usr/X11R6/bin; then

   PATH="$PATH:/usr/X11R6/bin"

fi



if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /usr/games; then

   export PATH=$PATH:/usr/games

fi



umask 022



USER=`id -un`

LOGNAME=$USER

MAIL="/var/spool/mail/$USER"

HISTCONTROL=ignoredups

HOSTNAME=`/bin/hostname`

HISTSIZE=1000



if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then

   INPUTRC=/etc/inputrc

fi



# some old programs still use it (eg: "man"), and it is also

# required for level1 compliance for LI18NUX2000

NLSPATH=/usr/share/locale/%l/%N



export PATH PS1 USER LOGNAME MAIL HOSTNAME INPUTRC NLSPATH

export HISTCONTROL HISTSIZE



for i in /etc/profile.d/*.sh; do

if [ -x $i ]; then

 . $i

fi

done



unset i

Link to comment
Share on other sites

for i in /etc/profile.d/*.sh; do

  if [ -x $i ]; then

     . $i

  fi

done

 

the aliases are inside the profile.d directory. the . $i line means to source the corresponding script in the directory causing whatever changes in those scripts to be reflected in the current shell.

 

ciao!

Link to comment
Share on other sites

In that folder is a file alias.sh

Would this be what ya lookin for?

 

# Linux-Mandrake configuration: Chmouel Boudjnah <chmouel@mandrakesoft.com>

#

# Common Aliases for a system.

#

# The Semantic is :

#	If exist a ~/.alias and the user hasn't specified a

#	LOAD_SYSTEM_ALIAS variables then don't do any system aliases

#	If there is no ~/.alias but the user has specified a

#	IGNORE_SYSTEM_ALIASES then don't do any system aliases.



[[ -f ~/.alias ]] && [[ -z $LOAD_SYSTEM_ALIASES ]] && return 0

[[ -n $IGNORE_SYSTEM_ALIASES ]] && return 0



[ -e /etc/sysconfig/system ] && . /etc/sysconfig/system



eval `dircolors --sh /etc/DIR_COLORS`



# default ls options

LS_OPTIONS="-F"



# this should be removed once the bug with ls and multibytes locales is fixed

[ -r /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh

case "$LC_ALL$LC_CTYPE" in

   ja*|ko*|zh*) LS_OPTIONS="$LS_OPTIONS --show-control-chars";;

   *) if [ "`locale charmap`" = "UTF-8" ]; then

       LS_OPTIONS="$LS_OPTIONS --show-control-chars"

      fi;;

esac



# emacs doesn't support color

if [ $TERM != "emacs" ];then

   LS_OPTIONS="$LS_OPTIONS --color=auto"

fi



alias ls="ls $LS_OPTIONS"



alias d="ls"                                                  

alias l="ls"       	 # classical listing.

alias ll="ls -l"   	 # List detailled. 

alias la='ls -a'      # List all.               

alias lsd="ls -d */"  # List only the directory.

alias cd..="cd .."  

alias s="cd .."

alias p="cd -"



alias md="mkdir"

alias rd="rmdir"

alias cp="cp -i"

alias mv="mv -i"

alias rm="rm -i"



# Make a filter for less

if [ -x /usr/bin/lesspipe.sh ];then

    export LESSOPEN="|/usr/bin/lesspipe.sh %s"

fi



if [ -n "$CLASS" -a "$CLASS" = "beginner" ];then

# Size of a directory (by default Human Readable).

   alias du='du -h'                              

                                             

# Size of a disk (by default Human Readable). 

# and don't probe supermount

   alias df='df -h -x supermount'

fi

Link to comment
Share on other sites

In that folder is a file alias.sh

Would this be what ya lookin for?

YES! Slack doesn't have that file, I will add that to /etc/profile.d/

 

Thanks everyone!

Link to comment
Share on other sites

Mods, I got the help that I needed the Mandrake /etc/profile and /etc/profile.d/alias.sh stuff, but this has developed into a problem with Slack as opposed to me asking for MDK info, so please move it to the "Other Distrobutions" forum. Thanks.

 

 

OK, so I added the alias.sh file, with a few modifications here and there so it wouldn't conflict with what was already in my /etc/profile, and all is well UNTIL I get into X. From the console, the aliases work. I also edited the "export PS1" statement in /etc/profile to alter the shell prompt, and those changes work too. Everything works, UNTIL I startx into my WM. Then none of the aliases work. In addition, I just noticed that the the shell prompt when I am in X and using a terminal has always been different from what it was from the console. It has always displayed the version of the shell followed by a $ or #. So it appears that some other script is overriding what is being set by the global /etc/profile. Have any of you experienced this same problem?

Link to comment
Share on other sites

Have any of you experienced this same problem?

 

It is not a problem, it is the way bash (and other shells) work. Mandrake has the same 'problem'

 

On a login shell it is read and executed /etc/profile and the first file found of this list: ~/.bash_profile, ~/.bash_login or ~/.profile

 

On a non login shell, the config file that is read and executed is ~/.bashrc

 

So when you startx from a console you are already logged-in, aren't you? So any terminal you open within X reads and executes ~/.bashrc and don't care to look (unless you tell it) the profile files.

 

In addition aliases aren't inherited from parent sells to son shells (versus environment variables which are inherited).

 

That's why you loose your aliases when you are in X. Aliases MUST go into bashrc in order to be read each time you start a new shell (unless you do some tricks... keep reading).

 

You might think that this is a mess, but it has a lot of logic. I suggest you to google for a good and deep explanation of why is thought to be that way.

 

As you are using slakware you have to made your configuration files *almost from scratch*. I suggest to follow the mandrake schema since you want to feel like in mandrake:

 

Global files:

 

/etc/profile (plus /etc/profile.d)

/etc/bashrc (which doesn't exist in slackware, here comes the tric used by mdk to have all the users with the same profile). This file should include some code to check if we are in a login shell or not, and if we are not, then 'emulate' /etc/profile and read and execute the scripts in /etc/profile.d. For example:

    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell

       for i in /etc/profile.d/*.sh; do

       if [ -x $i ]; then

           . $i

       fi

   done

   unset i

   fi

 

The user only files:

 

~/.bash_profile Should include this statement:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

 

~/.bashrc If you want to make it work like mandrake's bash, it must include:

if [ -f /etc/bashrc ]; then . /etc/bashrc; fi

 

With the above schema, and if I'm not missing anything, you'll get the same behaviour on a login shell and in a non-login shell. This is a clever and a user friendly aproach that Mandrake uses.

 

Me, for instance, on my slackware, I don't use all that mess, I just write my user config files the way they should be written:

~/.bash_profile includes environment variables, and some code to be executed once when I login. Oh, and ofcourse a call to ~/.bashrc

~/.bashrc includes all the rest: Non global variables (ie, PS1), functions, and finally aliases.

 

As you can see, my schema is much more simple and easy to maintain

 

HTH

Link to comment
Share on other sites

Thanks a lot, I'll do that. I would put my aliases in ~/.bashrc, but the ones I was referring to are ones that I WANT to be the default for all users.

Link to comment
Share on other sites

...but the ones I was referring to are ones that I WANT to be the default for all users.

 

As I stated above, but I think I haven't made my self clear, do it 'a la mandrake' (when I say doing it 'a la mandrake' I mean to put the 'global' alias into /etc/profile.d/alias.sh). So in order to make this stuff robust, you need to follow the mandrake schema, and that is:

 

I suggest to follow the mandrake schema since you want to feel like in mandrake:

 

Global files:

 

/etc/profile (plus /etc/profile.d)

/etc/bashrc (which doesn't exist in slackware, here comes the tric used by mdk to have all the users with the same profile). This file should include some code to check if we are in a login shell or not, and if we are not, then 'emulate' /etc/profile and read and execute the scripts in /etc/profile.d. For example:

    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell<!--QuoteEBegin--><!--QuoteEBegin-->        for i in /etc/profile.d/*.sh; do<!--QuoteEBegin--><!--QuoteEBegin-->        if [ -x $i ]; then<!--QuoteEBegin--><!--QuoteEBegin-->            . $i<!--QuoteEBegin--><!--QuoteEBegin-->        fi<!--QuoteEBegin--><!--QuoteEBegin-->    done<!--QuoteEBegin--><!--QuoteEBegin-->    unset i<!--QuoteEBegin--><!--QuoteEBegin-->    fi<!--QuoteEBegin--><!--QuoteEBegin-->

 

The user only files:

 

~/.bash_profile Should include this statement:

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi

 

~/.bashrc If you want to make it work like mandrake's bash, it must include:

if [ -f /etc/bashrc ]; then . /etc/bashrc; fi

 

Also you'll need to edit the skel (/etc/skel/) files .bashrc and .bash_profile accordingly in order that all new users will have the same pofile files with the changes in.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...