LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 11-10-2009, 07:38 AM   #1
nagavinodh
Member
 
Registered: Aug 2009
Posts: 118

Rep: Reputation: 15
history


Hi,

How to set time for history.And also i want noone edit their bash_profile
in linux.
 
Old 11-10-2009, 08:06 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
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...
 
Old 11-10-2009, 08:12 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,517

Rep: Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039Reputation: 1039
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.
 
Old 11-10-2009, 08:24 AM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958Reputation: 1958
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.
 
  


Reply


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
history junaid18183 Linux - General 14 11-07-2009 08:01 AM
tcsh: can you save the history from multiple shells to one history file? BrianK General 2 04-23-2009 06:19 AM
LQ history corbintechboy LQ Suggestions & Feedback 3 02-24-2006 09:52 AM
Download history and copy history? inverted.gravity Linux - Newbie 1 02-21-2006 01:31 PM
How to find back "history" database after "history -c" ? san_lss Linux - Newbie 1 01-07-2004 12:53 PM


All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration