Visit Jeremy's Blog.
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 08-19-2009, 02:25 PM   #1
LQ Newbie
Registered: Jun 2009
Location: Bethlehem, PA
Distribution: RHEL Workstation 4.8
Posts: 11

Rep: Reputation: 0
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
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.
Old 08-19-2009, 02:58 PM   #2
Registered: Oct 2007
Location: Val-des-Monts, Québec, Canada
Distribution: CentOS, RHEL, Fedora
Posts: 110

Rep: Reputation: 16
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.
Old 08-19-2009, 07:03 PM   #3
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,700

Rep: Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494Reputation: 2494
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:
Old 08-19-2009, 07:25 PM   #4
Registered: Jan 2009
Location: wherever I can make a living
Distribution: OpenBSD / Debian / Ubuntu / Win7 / OpenVMS
Posts: 440

Rep: Reputation: 57
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 ) <edit> This one has more details: </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"

Last edited by MBybee; 08-19-2009 at 08:31 PM. Reason: Added an even better bash customization link. And fixed a typo cause I just can't type today
Old 08-20-2009, 02:53 PM   #5
LQ Newbie
Registered: Jun 2009
Location: Bethlehem, PA
Distribution: RHEL Workstation 4.8
Posts: 11

Original Poster
Rep: Reputation: 0
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.


Bob P.
Old 08-20-2009, 03:48 PM   #6
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Tribblix, Ubuntu/WSL
Posts: 9,771

Rep: Reputation: 468Reputation: 468Reputation: 468Reputation: 468Reputation: 468
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:

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


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
Linux equivalents for Windows stomfi Linux - General 5 09-04-2007 05:02 PM
ESC/POS printer in Linux : Very Urgent! VirTualLoPeZ Linux - Newbie 2 10-19-2006 04:27 PM
LXer: Linux prominent at ESC Boston LXer Syndicated Linux News 0 10-05-2006 12:54 AM
I'm looking for Linux equivalents to these programs please... TippyToes Linux - Software 3 11-11-2005 10:04 PM
Linux equivalents for #pragma DavidW567 Programming 2 03-09-2005 02:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:22 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