Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-15-2009, 11:01 AM   #1
LQ Newbie
Registered: Apr 2009
Location: Florida
Posts: 19

Rep: Reputation: 0
Ksh Shell conversion

Our Linux RHEL 5.2 come by default with bash shell and we want to change it to use ksh. All the users have been created and had the bash shell features. I ran the command" 'usermod -s /bin/ksh $USERNAMR' to change them to ksh. Now there is no .profile added for the user and how can get one so I can push to all the users?
Also going forward any users I add need to have /bin/ksh so how I ensure that the .profile will be created.

Last edited by rbell54; 05-15-2009 at 11:03 AM.
Old 05-15-2009, 01:35 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,820
Blog Entries: 15

Rep: Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664
You can insure new users get the .profile by creating one and putting it in /etc/skel. During useradd the contents of /etc/skel are copied to the user's home directory. (Type "man useradd" for more details.)

.profile is just a text file with various settings in it. You can create one simply by using vi /etc/skel/.profile and adding what you want. Since /etc/skell usually already has .bash_profile you could start by copying .bash_profile to .profile then customizing the copy to insure it works for ksh. Many bash settings are relevant to ksh since both derive from Bourne shell and both now mostly have Posix compliance.

You can also copy the .profile you create to the home directory of the users that already exist with a for loop e.g.:

for user in `grep /bin/ksh /etc/passwd |awk -F: '{print $1}'`
do cp /etc/skel/.profile ~$user
chown $user ~${user}/.profile
chmod 640 ~${user}/.profile

Note that the symbol before grep and at end of that line is the back tick not the apostrophe. The symbol around the print statement of awk IS the apostrophe.
Old 05-18-2009, 09:04 AM   #3
LQ Newbie
Registered: Apr 2009
Location: Florida
Posts: 19

Original Poster
Rep: Reputation: 0

This has assisted me. I have create a .profile and move to /etc/skel.


linux, shells

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
Shell Scripting for KSH sagarbsa Programming 1 10-12-2007 06:37 AM
korn shell ( ksh ) lechuga Puppy 3 02-05-2007 10:43 PM
How to change shell to ksh rajeshsfo Linux - Software 3 08-14-2006 03:01 PM
KSH and SCO Shell Scripting mpgram Programming 3 12-29-2005 01:24 PM
How to install Ksh shell hardeep_ubhi Linux - Newbie 1 02-03-2005 08:55 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:36 AM.

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