LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 05-30-2010, 03:33 AM   #1
aceone
Member
 
Registered: Apr 2009
Posts: 55

Rep: Reputation: 15
changing env variables


hi,
I want to know two things:

1.what is the process of changing values of environment variables
like we use set $VARIABLE=value. then why we log off?if possible plz explain the steps and why we do so

2.How do I change size of HISTORY?I changed HISTSIZE in /etc/profile to "5",when i execute "history" it shows last "5" commands.I wanted to limit total number of commands in history to be 5.

Thanks & regards
 
Old 05-30-2010, 03:40 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,551
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Which shell are you using?
 
Old 05-30-2010, 03:52 AM   #3
aceone
Member
 
Registered: Apr 2009
Posts: 55

Original Poster
Rep: Reputation: 15
I am using bash ,RHEL5
 
Old 05-30-2010, 04:38 AM   #4
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
The simplest way, if you want to set it just for your users, is to edit the .bashrc file in your home directory, and add the lines to set the variable to this:

Code:
VARIABLE=value
export VARIABLE
If you wanted to do it for all users, you could add the lines to /etc/profile.
 
Old 05-30-2010, 10:09 AM   #5
aceone
Member
 
Registered: Apr 2009
Posts: 55

Original Poster
Rep: Reputation: 15
still not clear
 
Old 05-30-2010, 11:48 AM   #6
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 85
There are actually separate environment variables for the length of the history list in the shell (HISTSIZE), and the number of commands stored in .bash_history on exit(HISTFILESIZE), so you might want to set both of these. From man bash:

Code:
HISTFILESIZE
       The maximum number of lines contained in  the  history  file.
       When  this  variable is assigned a value, the history file is
       truncated, if necessary, by removing the oldest  entries,  to
       contain no more than that number of lines.  The default value
       is 500.  The history file is  also  truncated  to  this  size
       after writing it when an interactive shell exits.
HISTSIZE
       The number of commands to remember  in  the  command  history
       (see HISTORY below).  The default value is 500.
For shell variables, you only add the $ symbol when you are accessing the value stored (dereferencing). To assign a value to a variable, you use the name on its own:

VARIABLE=value # set the value

echo $VARIABLE # access it again

To then make a variable into an environment variable, you need to export it (which again uses the name on its own):

export VARIABLE

To set environment variables permanently for user(s), you can add the assignment and export statements to one of the following files:
  • /etc/profile - sets defaults for all users
  • /home/<username>/.profile - read when a user logs in, used by all shells (not just bash)
  • /home/<username>/.bashrc - read whenever a new bash session is started, but used only by bash

Changes might not take effect until you've logged out and in again.

Is that any clearer?

Rob
 
Old 05-31-2010, 03:52 PM   #7
aceone
Member
 
Registered: Apr 2009
Posts: 55

Original Poster
Rep: Reputation: 15
crystal clear
thanks
 
Old 06-25-2012, 06:13 AM   #8
cepal
LQ Newbie
 
Registered: Jan 2008
Posts: 7

Rep: Reputation: 0
related question

Lo,
I've go a related question - http://www.linuxquestions.org/questi...ns-4175413246/ .
The thing is, how do I change (in my particulare case HISTSIZE and HISTFILESIZE :-) ) to all currently running sessions of a particular (generic) user without actually telling the people using it to do it manually. Can root simply write to /proc/[PID]/environ? Yet I didn't find HISTSIZE in that environ file (how comes?)...

Thanks.
 
  


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
setting env variables. mannclay Programming 11 03-27-2009 08:14 PM
Getting env variables in X wild_oscar Linux - General 3 04-29-2007 09:49 AM
env variables AbrahamJose Solaris / OpenSolaris 4 04-18-2006 12:31 PM
env variables ekdya Debian 3 03-14-2006 01:33 PM
Open GL env.variables UB_KMA Linux - Newbie 1 08-04-2002 05:41 PM


All times are GMT -5. The time now is 07:26 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration