Sponsored Content
Full Discussion: Comande historique
Operating Systems AIX Comande historique Post 99974 by Garry_Garrett on Wednesday 22nd of February 2006 07:21:41 PM
Old 02-22-2006
How your shell history is kept depends upon your shell (sh, csh, ksh, etc.). You are probably using Korn shell, which defaults to using .sh_history in the user's home directory to store a history in. You can change this by setting HISTFILE in your .profile. I would recommend setting the following in /etc/profile:

USER=`/usr/bin/who am i | /bin/cut -d' ' -f 1`
MYTTY=`/usr/bin/tty`
BASETTY=`/bin/basename ${MYTTY}`
HISTFILE=${HOME}/.hist.${USER}.${BASETTY}
export readonly HISTFILE
HISTORY=100000
export readonly HISTORY

A lot of books espouse using $$, your PID. This is dumb. You get a separate shell history per login, but you create a boatload of files that never get reused. These self same books will tell you to do something stupid like create a cron job to delete any of these that are more than 3 days old. 3 days! Try 6 months! With the above, as you only have one (pseudo) terminal for each login session, each login session will get their own history. However, you will reuse the ttys, so you will reuse the history files. If HISTORY is large enough, however, you'll go back far enough. You can, however, trace back who had which tty when via the "last" command. There is no way to historically trace the PID. If you don't want to reuse the history files, add the date:

DATE=`/bin/date "+%Y%m%d.%H%M"`

I would put it between .hist and ${USER}. The ${USER} part may seem superflous, but if you have some account used by multiple users (like say "oracle"), then this allows you to see who did what. Because you take the username off of "who", you see their name before they su'ed (and of course you are going to set RLOGIN to "no" for a user like oracle so that users are forced to login as themselves and then su to the account, so that you have a paper trail to follow).

If we are talking about some derviative of C shell (csh), you have to put something in the user's .cshrc file (.login will not due) like:

set history = 100000
set savehist = 100000

Actually the first one is how many history command to show when they type "history", so that you might make smaller. No way to make it read-only. No way to set the file's name, it saves in $HOME/.history (like it or not). Furthermore, ksh writes to the history as it goes. csh writes to .history when it exits. Login into two windows, exit out of window A, exit out of window B - the history saved by window A gets overwritten and is lost; only the history of window B gets saved. For this reason, if history is important to you, csh is not your first choice.

Bourne shell doesn't do history at all.

The catch 22 is, if users can write to their history files, users can trash their own history files. Nothing you can do about that (other than say frequent backups).

Last edited by Garry_Garrett; 02-22-2006 at 08:25 PM.. Reason: pronoun mistake
 
RXTELNET(1)						    BSD General Commands Manual 					       RXTELNET(1)

NAME
rxtelnet -- start a telnet and forward X-connections. SYNOPSIS
rxtelnet [-l username] [-k] [-t telnet_args] [-x xterm_args] [-K kx_args] [-w term_emulator] [-b telnet_program] [-n] [-v] host [port] DESCRIPTION
The rxtelnet program starts an xterm window with a telnet to host host. From this window you will also be able to run X clients that will be able to connect securely to your X server. If port is given, that port will be used instead of the default. If setting up the X forwarding failes, rxtelnet will still telnet in to the remote host, but without X forwarding. The supported options are: -l Log in on the remote host as user username. -k Disables keep-alives. -t Send telnet_args as arguments to telnet. -x Send xterm_args as arguments to xterm. -X Send kx_args as arguments to kx. -w Use term_emulator instead of xterm. -b Use telnet_program instead of telnet. -n Do not start any terminal emulator. -v Be verbose. EXAMPLE
To login from host foo (where your display is) to host bar, you might do the following. 1. On foo: rxtelnet bar 2. You will get a new window with a telnet to bar. In this window you will be able to start X clients. SEE ALSO
kx(1), rxterm(1), telnet(1), tenletxr(1), kxd(8) KTH_KRB March 7, 2004 KTH_KRB
All times are GMT -4. The time now is 07:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy