LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-02-2007, 09:58 AM   #1
mudman69
Member
 
Registered: Mar 2007
Distribution: Whatever Works
Posts: 44

Rep: Reputation: 16
Setting Up Shell Parameters


Hey all, I had a question about setting up shell parameters in Fedora Core 6. I'm kinda new to Linux but have decent AIX expierence. I know in AIX you can setup a specific users profile in the $HOME/.profile file. Will this work for Linux as well? All I really want to set up for now is a PATH and to "set -o vi" for a specific user. Any help is appreciated. Thanks
 
Old 04-02-2007, 11:09 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Bash specific parameters go either in /home/user/.bashrc or /home/user/bash_profile.
There's probably already a $PATH set up automatically when the user was created, so look for that and adjust it's settings.

If you want to apply the settings to all users, you should put them in /etc/profile or /etc/bashrc instead.
 
Old 04-02-2007, 11:44 AM   #3
mudman69
Member
 
Registered: Mar 2007
Distribution: Whatever Works
Posts: 44

Original Poster
Rep: Reputation: 16
Awesome, thanks for the reply. Will this also work with Ksh? or Maybe I should just start getting used to Bash
 
Old 04-02-2007, 12:49 PM   #4
hepburnenthorpe
Member
 
Registered: Jun 2006
Location: Sydney
Distribution: Gentoo + Debian
Posts: 132

Rep: Reputation: 15
Never used Ksh, but it should have something simular. Check out the man page.

Code:
man Ksh
 
Old 04-03-2007, 03:17 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
I haven't used ksh either, but a quick look in the man page and on Google turned up that it uses
the files /etc/profile (all users) and /home/user/.profile (user specific), as well as the filename stored in $ENV variable, which is typically /home/user/.kshrc or something like that.

Please also note that the exact syntax of the commands to set the $PATH variable for instance. The "set -o vi" command should work in ksh just fine.
 
Old 04-03-2007, 02:01 PM   #6
mudman69
Member
 
Registered: Mar 2007
Distribution: Whatever Works
Posts: 44

Original Poster
Rep: Reputation: 16
Great... Thanks alot for your help ! ! !
 
Old 04-04-2007, 03:56 PM   #7
alf55
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Rep: Reputation: 0
The files that are read at login or when a new shell starts...

As Unix shells go..
First there was the Bourne Shell (sh). This is the base shell for the newer shells Korn Shell (ksh) and Bourne Again Shell (bash). It was not used as the base for the C Shell (csh) nor the ??? (tcsh).

Please note that the "sh" on a Linux based system is most like the "Bourne Again Shell" rather than the "Bourne Shell".

The "Bourne Shell" system startup file is "/etc/profile" and the user startup file is "${HOME}/.profile" (sourced at login). With the "Korn Shell", they added a file that would be sourced when each shell is started and it's name was not specified but it name was defined via the value of the environment variable "ENV". When the "Bourne Again Shell" development team decided that they would first look for a pair of "bash" specific files and use them if present otherwise they would look for those of older shells. Because of this feature bash looks for files in the following order:
Code:
     (system)                   /etc/profile
     (user at login first of)   ${HOME}/.bash_profile
                                ${HOME}/.bash_login
                                ${HOME}/.profile
     (user if exists)           ${HOME}/.bashrc
Also not that bash also has a user script that runs (when present) at logout called: ${HOME}/.bash_logout

The C Shell (csh) was not based on the Bourne shell and has a whole different syntax and in order to exist on a standard machine, only uses it's own set of start-up files. The tcsh was based on csh and like the bash shell has it's own files with fall back to the csh files. The C Shell added the concept of a cleanup script at logout. The C Shell and tcsh shells have lots of security issues and restrictive pipes exit status ans such so most people never use them for any kind of admin tasks. Before "bash" (or zsh) lots of people preferred the tcsh for interactive usage (if they never did any admin types of tasks).

Now that I have mentioned the "zsh", it is a shell that attempts to have merged both of these major shell lines (bourne and csh).

There are many other shells that can be used as your interactive shell (even a perl shell called psh).



Note that "$HOME/", "${HOME}/", and "~/" all mean the same thing in a bash shell.
the "~/" was a Korn shell addition.

Other ease of use "~" expansions are:
Code:
    ~user123/          means the home directory for user "user123"
    ~-/                means the previous directory
 
Old 04-04-2007, 03:59 PM   #8
alf55
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Rep: Reputation: 0
There are many shells that are avaliable for use in a Linux/Unix environmnet..

Boure, Korn, Bourne Again Shell, ZSh

csh, tcsh, zsh

ash

psh

tclsh, wish

Just to list a few of them....
 
Old 04-05-2007, 12:33 AM   #9
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
Quote:
Originally Posted by alf55
Boure, Korn, Bourne Again Shell, ZSh

csh, tcsh, zsh

ash

psh

tclsh, wish

Just to list a few of them....
Hate to diverge from the original poster, but why are there so many shells and what are the advantage/disadvantage to them? Can't we just stick to one? I used a csh once in a cluster setup and tried to submit a (bash) script and it locked up my computer. That was painful!
 
Old 04-05-2007, 02:33 AM   #10
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Like Linux itself and many applications, shells come in flavors. The user picks what he/she likes best.

When it comes to shells, though, bash/sh and zsh are probably most commonly used.

Syntax is quite different, especially between bash and csh for instance. A few hints to prevent mayhem:
-add the shebang line (ie #!/bin/bash) at the top of your script as a hint on the interpreter you'll need;
-install both csh and bash on your machines as you're likely to come accross both. zsh may help too.
 
Old 04-05-2007, 12:28 PM   #11
alf55
LQ Newbie
 
Registered: Oct 2005
Posts: 7

Rep: Reputation: 0
Why or Why do we have more than a single shell....

Quote:
Originally Posted by Micro420
Hate to diverge from the original poster, but why are there so many shells and what are the advantage/disadvantage to them? Can't we just stick to one? I used a csh once in a cluster setup and tried to submit a (bash) script and it locked up my computer. That was painful!
We have different shells because someone finds something missing or hard to use or not the way that I would do it. They (or someone that hears about it and likes the idea) then do something about by creating their own.

It is a good thing that people are always finding and producing new (or different stuff) if that was not the case, we would not have any advancement in any field and would be sleeping in cliff depressions, under trees, and so on. By learning new things, we actually are aiding in brain development which should be happening in our entire live.

Mr Bourne created the original widely used Unix shell. When people at UC, Berekely (I think I have enough 'e's in there) were coding in the programming language C and thought a more C-like shell would be a good thing and the "csh" was created. (Yes, I know that it does not really look like C but they needed a fast parser and parsed the line using the "strtok" function.) But "csh" has lots of problems (see http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/ ) but had lots of nice features not found in the Bourne shell. Mr. Korn, decided that he would extend the Bourne shell to have several of these new and nice features (such as better command line editing, job control, arrays, etc) while retaining backward compatablity. This new shell is the 'ksh'. The Bourne Again shell is the result of the GNU group providing equivalent programs to the commercial Unix and it extends the original Bourne shell far past the ksh in features and can still run an original Bourne shell script.

The "psh" is an interactive shell that is really interactive perl.

The "tclsh" is a product that came out of Sun for controlling tools. It stands for "Tool Control Language". This was extended to include a graphics widget set and "wish" was created. The tclsh (and therefor wish) was made so that it could be added into a C application (C++ can also add it in also) to be used as it command processor. I worked for a company that made a code coverage tool that embeded tclsh and we used it to allow the user to extend and modify/create custom reports. We even included a "tcl" script that generated an html report as part of the product. We have used wish scripts to generate an living example of potential products and features as it is faster to generate for a "sales pitch" for a new idea than generating a c/c++ program.

The great thing is that all of these can co-exist without any problems.

Quote:
tried to submit a (bash) script and it locked up my computer
This must have been a error in the script or you used the "source" command to execute it. The commands are different between them but I still would not have expected a locked up computer. A script just like a program can have infinite loops that so it does not stop. But that is what control-c ( or in extreme cases control-\ ) is for.

To top it off how boring would live be if only 1 type thing is needed. One house model, one transportation model, one tree model, one land model, one water model, etc. How about one water animal model, one air animal model, or one land animal model (We might not even be here then!).
 
  


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
Changing shell DISPLAY parameters dpvone Linux - Software 4 05-10-2007 10:15 AM
bash shell parameters jayeola Programming 4 05-15-2006 11:29 AM
Passing parameters to a shell script neocookie Linux - General 5 10-20-2005 12:44 PM
shell: positional parameters... neidias Programming 1 04-04-2005 03:45 PM
pass parameters to shell scripts ? qwijibow Linux - Newbie 2 08-07-2003 08:27 AM


All times are GMT -5. The time now is 08:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration