Unable to save my configurationsettings

I need to login to several AIX boxes .... I use putty for that and I am losing the configurations as I logout. For ex: I like to work with emacs editor, as AIX comes default with ksh , I set it using set -o emacs, once I log out and login back I am back again in ksh ... :confused:

Put whatever you want to have set into the file .kshrc in your $HOME directory. This file (don't forget to set the executable-bit) is executed every time a new shell is started by your user.

Btw. and for clarification: when issuing "set -o emacs" you do NOT leave the Korn shell, just change the way the commandline can be edited.

I hope this helps.

I dont have .kshrc file in my home dir , can I create it and check.

Nivas P

I am not sure if this is known to you (if it is: sorry about wasting your time), but you won't see files named starting with a dot "." if you do an "ls -l" as a non-root user. Use "ls -la" to see them. In fact this is what the "-a" option is for. For the root user "-a" is the default in ls.

You can create the file using your favourite text editor, it is like any other shell script.

Here is a sample .kshrc script which you can use as a starting point:

set -o vi             # my preference, change it to "emacs" if you like

unalias rm            # many systems have "rm" aliased to "rm -i" to enforce
                      # interactive use of rm, but i dislike this. I like living dangerously.

alias l='ls -lai'     # this is a nifty one, which saves typing

PS1='# '              # set the shell prompt

save this to the file ".kshrc", set the executable bit and excecute by ". ./.kshrc" to activate it.

I hope this helps.

bakunin

You can also use your .profile to set these configurations... also if you need to use a variable or update your path, etc... remember to export the variable...

For example add this to your .profile to add the bin directory from your home directory in your path...

export PATH=$PATH:~/bin

ahem...:no - at least not quite

".profile" is executed every time the user logs on, whereas ".kshrc" is executed every time a new ksh instance starts. Of course, logging on will also start a new shell (which is started by the login process), so in this (but only in this) instance both events occur at the same time. It is a good idea to put

. ~/.kshrc

at the end of the ".profile" script, just in case.

But except for this the two events are quite different.

I hope this helps.

bakunin

Thanks a lot Gurus (masters)... :slight_smile: , I really learnt a lot from this small topic once again thanks for sharing the info.

I have a quick question again :wink:

I have the following script in my $HOME :

alias l='ls -lai'
EDITOR=emacs # This is my fave editor
alias c='clear'
clear
alias x='exit'

when I type
$ oslevel -r command - I get the result but with the screen cleared
but when I use with sudo , I have no issues
$ sudo oslevel -r ....... i get the result at the next line......

anything wrong in the .kshrc profile

Hmm..., do NOT CONFUSE "EDITOR=" and "set -o", they are serving different purposes. If you want emacs-style commandline editing (for instance, "CTRL-P" for the previous command, "CTRL-N" for the next command, etc.) replace this line with "set -o emacs" or at least add this line to the file.

I suggest you read the man page about ksh or a good book about ksh to find out more about the many configuration options this shell has. One book i can recommend wholeheartedly is "The ksh Programming Tutorial" by Barry Rosenberg.

Not sure, what you want to achieve here, but if you want a command to clear the screen use "tput clear". That "clear" works is by chance and it might not be this way on the next machine, but "tput clear" will works always. You might consider changing the line to "alias c='tput clear'".

You do not have to type "exit" to leave the shell. A simple "CTRL-D" (which is a EOF character, actually) will also get you out of the shell.

To understand this consider the following: an interactive shell session is quite the same as a shell executing a script. The interactive shell is just "reading" your terminal as input file. If you present an EOF character you tell the shell that this "input file" is finished her - so the shell will stop and exit.

You can prevent this behavior (and this is sometimes done out of a false sense of security, because it adds nothing to the security of a system) by setting "set -o ignoreeof", which will cause the shell to ignore this EOF character. If your system is configured this way you can change the setting by "set +o ignoreeof".

Issue the "alias" command to list all aliases in effect. maybe the oslevel command is not what it should be.

Alternatively use "which oslevel" to find out if there is some script named oslevel before the binary in the path. The "$PATH" variable is searched consecutively and if it looks like "/usr/local/bin:/usr/bin:..." and in /usr/local/bin is an executable file named the same way as one in /usr/bin you would use the one from /usr/local/bin and not from /usr/bin. The "which" command tells you which one it will load effectively.

If something like this is the case either "unalias" the offending alias or Reaarrange the $PATH variable. by simply setting it anew: "PATH=/first/dir:/second/dir:....". You could put this also in your .kshrc.

I hope this helps.

bakunin

I have one more quick question friends

I logged into another server , but I am not able to see the .kshrc file only .profile is visible ... can someone shed some light on this. I am not able to get the settings on another machine.

I tried to telnet from the machine where I have the .kshrc file, but i dont the see the settings getting reflected when I telnet ? :confused:

Thanks a lot , Bakunin.... will try to follow as you said and will get back .

Your setting look like it is clearing the screen and when you use sudo it is not using your settings

Here is a cool thing to try with your .profile as well

#PS1=^[[35m`uname -n`':^[[31m${PWD}#'^[[33m
PS1=^[[35m`uname -n`^[[34m`whoami`':^[[36m${PWD}#'^[[33m
#PS1=^[[32m `uname -n`^[[34m`whoami`':^[[31m${PWD}#'^[[33m
alias ll='ls -larti'

I have this setup in my profile because it adds colors to my profile
The way to set this up is to do the following on your system as you can not just copy this config

In your home dir

tput smso >> .profile
tput rmso >> .profile

vi .profile

at the end of your profile you will find the control code for the tput settings

^[[7m ^[[33m

Depending on your setting this may look different

Split the 2 functions
^[[7m Now you can change this 7 to numbers (31 - 36 ) for different colors

^[[33m

Now using this change your PS1 to look like this
PS1=^[[35m`uname -n`^[[34m`whoami`':^[[36m${PWD}#'^[[33m

Cat .profile and see if you like

Cheers

Posing again ...

I have one more quick question friends

I logged into another server , but I am not able to see the .kshrc file only .profile is visible ... can someone shed some light on this. I am not able to get the settings on another machine. can I use .profile to update my settings need on another machine

I tried to telnet from the machine where I have the .kshrc file, but i dont the see the settings getting reflected when I telnet ? :confused:

You have to set these settings in every machine you get an account separately. Save your .kshrc and .profile files and copy them (more securely: merge them if there are existing ones) at your new accounts $HOME directory. Most of us have created complex files this way, reflecting the very personal style of working with the machine.

My own .kshrc is close to 100 lines long and contains some functions i like (for instance a "directory stack" which allows me to "roll back" or "roll forward" the directories i have been in - quite handy for working in several directories at the same time which saves a lot of typing on "cd ...." commands, etc.). It has grown that way over time and sometimes i find something new and incorporate it to my "arsenal".

I hope this helps.

bakunin

Thanks a lot , I think my question is answered :b: