LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux equivalents of .profile, <esc>-k and others (https://www.linuxquestions.org/questions/linux-newbie-8/linux-equivalents-of-profile-esc-k-and-others-748792/)

RPeruzzi 08-19-2009 01:25 PM

Linux equivalents of .profile, <esc>-k and others
 
I'm still a newbie, but I have the basics working for me. Now I want to make my Linux environment seem more like my Unix environment back when I worked for a big semiconductor company. (I was spoiled by having excellent IT people in house, and never had to learn the nuts and bolts of Unix, and am now climbing the learning curve where I'm clueless in some areas and quite expert in others. Here's a couple of things I need help with:

1. Appending /home/$USER/bin to PATH


I used to have lines in my .profile which said
PATH=$PATH:$HOME/bin
export PATH

I used to keep executable scripts and little C programs in $HOME/bin and could execute them from anyplace in my environment.

I'm using Red Hat Linux (Workstation) 2.6.9.

I guess my question is: What is the Linux equivalent of .profile (which executes on log in)?

2. Changing prompt from $ to "/home/$USER/... to present directory"\
I had a line in my .profile for many years that did this with a very short command. Once I know the .profile equivalent, I want to add this command to it.

3. Repeating previous command with <esc>-k
I'm not quite sure what shell we were using, but I recall that <esc>-k did not work unless we added a command to our .profile. When it works, the <esc>-k sequence brings the previous command onto the command line. One may repeat it to go back through history and use <esc>-j to go forward. After hitting <esc>-k one may even search through history for part of a command by hitting "/" followed by one or more characters.

I haven't been able to figure this one out either. Can somebody point me to the answer?

Better yet, are answers to these three questions available in a single document somewhere?

Thank you very much.

Bob P.

wolfperkins 08-19-2009 01:58 PM

it all depends on the default shell you select for your user account.

The .profile is usually used by Bourne Shell and Korn Shell. Some distributions have bash as the default shell and this one uses .bash_profile and .bashrc

In order for your older scripts to continue to work it would probably suit you to change your account's default shell to /bin/ksh as opposed to /bin/bash. Just update /etc/passwd accordingly.

chrism01 08-19-2009 06:03 PM

If you want to stick with Linux stds, you're /etc/passwd acct entry will specify the bash shell by default.
As above, the (user specific) login files are .bash_profile (= .profile) & .bashrc (= .kshrc).
You should find that the shell automatically maps the cursor keys, much easier than <esc>h,j,k,l sequences.

This also applies to the default editor vim (Vi IMproved), basically vi with extensions. You may well find that both vi & vim are installed, but by default, 'vi' is symlinked to vim.
I work with both commercial *nix using ksh and Linux + vim,I prefer vim when possible. The extensions can be quite handy eg colour syntax and handles very long lines properly.

You may find these useful:
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
http://www.linuxtopia.org/online_boo...ide/index.html

MBybee 08-19-2009 06:25 PM

1) Seems to have been answered well - also, ~/ is your home, so at worst you can always run "~/script". The usual login scripts are .profile, .login, .cshrc, .bashrc, .tcshrc, etc.

2) For the current directory to show, just set PS1: PS1="[\u@\h:\w ] $ " - which will produce [user@server:~ ] $
(as shown here, for example http://www.cyberciti.biz/tips/howto-...up-prompt.html ) <edit> This one has more details: http://linux-blog.org/bash-prompt-fun/ </edit>

3) If you want the vi style commands, type "set -o vi". I agree that the up and down arrows are easier, but some people like being able to do vi-style substitution and searches in the command history. One I use a lot is "Esc+/partial"

RPeruzzi 08-20-2009 01:53 PM

Thanks, all of you, for your help
 
All answers are spot-on and complete. Thank you. Here's my plan:

1. I will update /etc/passwd to use /bin/ksh
2. I do like the <esc>-k etc. sequences because of the ability to search and substitute in the command history. I'm no fan of either vi or vim -- once I found nedit I never looked back. In fact, it was when trying to put my nedit command into $HOME/bin that I bumped into the frustration of its not being available at the command line.
3. It was the PS1 command which I'd forgotten, as well as the set -o vi. Thanks for jogging my memory.
4. Lots of links for me to follow. Thanks for those too.

Cheers,

Bob P.

jlliagre 08-20-2009 02:48 PM

The syntax suggested for customizing the prompt (PS1="[\u@\h:\w ] $ ") is bash specific and isn't going to give anything useful under ksh.

For a similar result, your might use instead something like:

Code:

PS1=$(whoami)@$(hostname):'$PWD \$ '


All times are GMT -5. The time now is 10:54 PM.