LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 05-18-2008, 02:17 AM   #1
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Rep: Reputation: 107Reputation: 107
Question create command aliases for a user


Hi all,

I am using Solaris 10 OS on X86. When I add a new user from command
Code:
useradd -d /export/home/vikas -m -s /bin/bash vikas
files local.cshrc, local.login, local.profile and .profile get copied to my home directory (i.e. /export/home/vikas) from /etc/skel/

Which file I have to change to make command aliases and what is the format ?
for e.g. making alias of ls as ls -lrt.

Like in Linux, we have to change .bash_profile as
Code:
ls='ls -lrt'; export ls
to have this effect.

I tried this on local.profile and .profile but it wasnt working.

Also, suppose I need that each time a user logs in a script say /tmp/vikas.sh executes. How to achieve this ? Pls help !

Thanks and Regards,
Vikas
 
Old 05-18-2008, 03:30 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
You need to use the alias command:

alias ls='ls -ltr'

What you are currently doing is setting a value for variable $ls which is not going to work (user would need to type $ls to run the command.
 
Old 05-18-2008, 04:23 AM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,788

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by vikas027 View Post
files local.cshrc, local.login, local.profile and .profile get copied to my home directory (i.e. /export/home/vikas) from /etc/skel/
The local.xxx files are templates. They are not used unless renamed to what the user's shell expects.
Quote:
Which file I have to change to make command aliases and what is the format ?
for e.g. making alias of ls as ls -lrt.

Like in Linux, we have to change .bash_profile as
Code:
ls='ls -lrt'; export ls
to have this effect.
As already stated by Disillusionist, aliases are created with the alias command regardless of the OS.
Quote:
Also, suppose I need that each time a user logs in a script say /tmp/vikas.sh executes. How to achieve this ?
You can add something like this in .profile
Code:
if [ -f /tmp/vikas.sh ]
then
  . /tmp/vikas.sh
fi
Note that using /tmp isn't a good idea, this directory being wiped out when the machine is powered off. Moreover, anyone being able to create a file there, that would be a terrible security weakness on a multiuser machine.
 
Old 05-18-2008, 04:26 AM   #4
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,305

Original Poster
Rep: Reputation: 107Reputation: 107
Thanks all,

It worked by changing .profile

Quote:
alias ls='ls -ltr'
Regards,
Vikas
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create permanent aliases in yakuake/konsole? Pau Gasol Slackware 6 09-22-2007 01:54 AM
Command Aliases??? UFCfighter Slackware 19 07-12-2006 08:01 AM
How do you create a user account from command line??? bossdog22 Ubuntu 3 04-18-2006 01:06 PM
How to create aliases in MySQL? JockVSJock Linux - Software 1 02-26-2006 12:13 PM
MySQL - command - create user/single database dmedici Linux - Software 3 06-21-2004 03:17 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 11:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration