Solaris History

why in solaris 10 I do not get history when I have the role as root?

computer.root > history

I get history:not found

I am in

computer.root > echo $SHELL
/bin/sh

computer.root >

how can I see roots history in the sh shell?

but in other shells I can only see my history and no one elses who I able to su - root?

I cannot tell what you are doing. So, let's try this as root user:

You are going to enter 4 commands EXACTLY, then when the last command completes, you will enter an ESC-K (escape key - K)

EDITOR=/usr/bin/vi
export EDITOR
ls 
bar

The last command should give you an error - not found. OK, so now we test "history"
Press ESC-k - you should see "bar"
Press ESC-k again - you should see "ls" appear on the command line - if you hit return it runs the ls command.

We just turned on history, I think. So, there should now be a history file in root's home directory.

It is a hidden file - meaning it starts with the . character IRC the file is named .history

ls -la .history

should list the file if you are in your home directory.

Oh. And this shows you how to get what you want,I think, which is nothing like what I think your are trying:
sudo - make sudoers use their own history file - Unix & Linux Stack Exchange

This is a bash example, so be careful.

/bin/sh is an old Bourne shell.
No history, no job control.
If you want history you should switch to bash (or zsh)

exec /bin/bash

Or permanently change root's login from /sbin/sh to /bin/bash with

passwd -e root

After changing the login shell, before you leave the current shell, test with another (parallel) login!

2 Likes

I fully subscribe to the comment above. Solaris comes with an archaic bourne shell.

1 Like
mserver.root > ls -la .history

.history: No such file or directory

---------- Post updated at 06:33 PM ---------- Previous update was at 06:32 PM ----------

I am trying to find out what others are doing as root, but since they use /sbin/sh,i guess that I am out of luck

Hi,

Basically, yes.

However, there is one more thing that may be worth checking. If your Solaris system has accounting enabled, then you might be able to run lastcomm to see the commands executed by users on the system. If this is enabled (and it's not enabled by default), then it will only show you very basic information - just the name of the command and none of the arguments, along with who ran it and when. But it's better than nothing, and could be worth a try before you give up. Note that if it's not enabled then enabling it now won't give you any historical data - it will only log commands from the point of activation onwards.

But really, as previously noted, for proper history logging all users who you want logged will have to use another shell, such as Bash.

2 Likes