LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   history (https://www.linuxquestions.org/questions/linux-newbie-8/history-768160/)

nagavinodh 11-10-2009 07:38 AM

history
 
Hi,

How to set time for history.And also i want noone edit their bash_profile
in linux.

acid_kewpie 11-10-2009 08:06 AM

history is based upon a size, not a time. To my knowledge there is no way to have a time based angle on it. As for the bash_profile, if you don't want users to edit their own, does this not really suggest that there is no user specific configurations permitted? In which case, just don't use it. The file is chained on via /etc/bash_profile (AFAIK) so if you remove the sourcing of it, then there will be no need to worry about users own files. Note that this sort of thing can always be bypassed somehow. A user can spawn a secondary shell, with their own config files which set a bash_history and such...

tronayne 11-10-2009 08:12 AM

By "time" do you mean number of commands to remember; if so, the default is 500 and you can change that by defining HISTSIZE=1000 (or whatever) in a user's profile. If you mean the time format, that can be changed HISTTIMEFORMAT, also an environment variable. See the manual page for BASH.

If you want to establish a standard, system-wide profile, you can add files in /etc/profile.d for that purpose. Also, you can simply change the owner of individual user profile files (/home/userid/.profile, /home/userid/.bashrc and the like) to root; e.g., chown root.root /home/userid/.filename and chmod 644 /home/userid/.filename. They won't be able to fiddle with them that way.

Bear in mind that any additions you make in /etc/profile.d are only executed one time at login; /etc/profile, the system-wide profile settings, is only read once and it executes whatever is found in /etc/profile.d (only once).

Hope this helps some.

David the H. 11-10-2009 08:24 AM

There is a HISTTIMEFORMAT environmental variable, which allows you to set a time string display in the format specified when the history command is called.

As for not allowing individuals to set their own ~/.bashrc files, read the invocation section of the man page:

Quote:

Originally Posted by man bash

When an interactive shell that is not a login shell is started,
bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if
these files exist. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.

Finally, some advice. I can guess that English is not your native language, but simply posting a simple one-line question without any details explaining what you want to do or why can be hard to understand and is considered a little rude. You didn't even use a proper question form above, in fact.

Try using phrases like "How do I....?" and "What's the best way to ...?" Then add some details about what you are trying to do.


All times are GMT -5. The time now is 05:32 AM.