1834020 Members
3176 Online
110063 Solutions
New Discussion

Re: set alias

 
SOLVED
Go to solution
hangyu
Regular Advisor

set alias

If I want a group of user has the same alias setting , can advise what can i do ?

alias cp='cp -i'
alias mv='mv -i -r'
alias rm='rm -i -f '
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-ti
lde'
5 REPLIES 5
Oviwan
Honored Contributor
Solution

Re: set alias

Hy

You can add this to /etc/profile then every user has this.

or you can make a file called .alias and put the aliases in this file. now you can source this file to the profile of the users

source:

. /path_to/.alias

Regards
SANTOSH S. MHASKAR
Trusted Contributor

Re: set alias

Hi,

For already existing users add alias settings into
users .profile

for new users copy /etc/skel dir to say /etc/skel_new

# cp -Rp /etc/skel /etc/skel_new

then add required alias into /etc/skel_new/.profile

while adding user use -mk /etc/skel_new

for eg.

# useradd -u -g -mk /etc/skel_new

this newly created user will have all the
aliases into his .profile


-Santosh
Yogeeraj_1
Honored Contributor

Re: set alias

hi,

/etc/profile would be the most appropriate place to put them.

But, to avoid that to be too messy, refrain from defining too many aliases as it will affect all the users who log on the system.

Another option is to have a common home directory for that particular group of users and add these aliases to the .profile file.

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
spex
Honored Contributor

Re: set alias

Hello,

1) Create a new group for users who will have these aliases: 'groupadd aliasgp'.
2) Assign users to this group.
3) Insert a check into /etc/profile:
if [[ "$(id -gn)x" = "aliasgpx" ]]; then ...
4) Place your aliases after this check.
5) Terminate the conditional block with 'fi'.

PCS
spex
Honored Contributor

Re: set alias

In my previous example, if you do not wish to make "aliasgp" the users' primary group, change the if-statement to:

if $(id -Gn | grep -q 'aliasgp');
then
...
fi


PCS