Can we directly edit "/etc/environment" file in AIX using vi ?


 
Thread Tools Search this Thread
Operating Systems AIX Can we directly edit "/etc/environment" file in AIX using vi ?
# 1  
Old 02-24-2014
Can we directly edit "/etc/environment" file in AIX using vi ?

Hi


Is it recommended to edit the file "/etc/environment" directly using vi ?

(like by adding some export something= value staements)
or
do we need to edit /etc/profile file
in order to set the environment variables, globally to the entire AIX LPAR

please suggest.
# 2  
Old 02-24-2014
Either will work. By convention /etc/enviroment is used for environment variable defintions. So that's all you will usually see in it. Whereaas /etc/profile will also contain environmental vars but may contain additional commands. Compare yours to see.
# 3  
Old 02-24-2014
@ blackrageous

yeah agreed. But i read somewhere, that we should not modify the /etc/environment file directly using vi.
i do not know....whether any command to update this file.
instead i usually edit (vi) /etc/profile and export the variables to make it global.

please provide your comments.

thanks
# 4  
Old 03-06-2014
Quote:
Originally Posted by System Admin 77
Is it recommended to edit the file "/etc/environment" directly using vi ?

(like by adding some export something= value staements)
or
do we need to edit /etc/profile file
It is highly recommended to use vi for editing both of these files.

Still, putting "export"-statements into /etc/environment will not work at all and just lead to ignored lines causing error messages. In /etc/environment there are only three types of lines allowed:

1. comments
2. empty lines (white space is ok)
3. lines of the type "identifier=value", where <identifier> is any legal name for a shell variable and <value> is any legal content of same.

It is quite common to attempt the misuse of /etc/environment by adding all sorts of profile statements (export, if....then..., etc.), but all these will not work at all.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 5  
Old 03-07-2014
Quote:
Originally Posted by bakunin
It is highly recommended to use vi for editing both of these files.

Still, putting "export"-statements into /etc/environment will not work at all and just lead to ignored lines causing error messages. In /etc/environment there are only three types of lines allowed:

1. comments
2. empty lines (white space is ok)
3. lines of the type "identifier=value", where <identifier> is any legal name for a shell variable and <value> is any legal content of same.

It is quite common to attempt the misuse of /etc/environment by adding all sorts of profile statements (export, if....then..., etc.), but all these will not work at all.

I hope this helps.

bakunin
Thanks for your time. I got you.

Let me give you an example, so that you can correct me if i misunderstood.

/etc/profile
and /etc/environment
both works in the same way. And we can edit with "vi editor"

my example:

If i want to make some changes on /etc/environment
i just need add the below line
Code:
HISTSIZE=5000

or
i can edit /etc/profile

Code:
export HISTSIZE=5000

both works in the same way. please correct me if am wrong.

Thanks,
# 6  
Old 03-08-2014
Quote:
Originally Posted by System Admin 77
/etc/profile
and /etc/environment
both works in the same way. And we can edit with "vi editor"
More or less: yes. You can and you even should use a plain editor (and which one would be better suited than the system editor itself?).

Quote:
Originally Posted by System Admin 77
both works in the same way. please correct me if am wrong.
You are right. The "export" keyword makes the variable to become exported in forther opened subshells. It is like this:

Consider you start with "shell a", inside "shell a" you open "shell b" (they might be all all instances of the same shell, "ksh", i just named them differently here to address them).

Every environment variable set inside "shell a" will not be set inside "shell b" (=not be "exported"), unless you use "export" before opening "shell b". See here:

Code:
shell_a> varA="something"
shell_a> varB="other"
shell_a> export varB
shell_a> echo varA
something
shell_a> echo varB
other
shell_a> shell_b
shell_b> echo varA

shell_b> echo varB
other
shell_b> exit
shell_a> echo varA
something
shell_a> echo varB
other

Btw., it is not recommended to use "export var=value", because "export" is a keyword in its own right. you should use:

Code:
var=value
export var

instead.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

I need to find first daty of each month. What will I see on AIX "1" or "01"

Could you please let me know the following? I have to find and check first day of each month. I do fdt=`date +%d` will it give me on AIX "1" or "01" I ask you because I couldn't make real test on first day and don't know Thanks for contribution (4 Replies)
Discussion started by: digioleg54
4 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. AIX

How to enable "TCP MD5 Signatures" and "https" on AIX?

I have searched many times but nothing found. Somebody help please :(:(:( (1 Reply)
Discussion started by: bobochacha29
1 Replies

5. Shell Programming and Scripting

"Content-type: text/html No input file specified." Only in CRON but not when executed directly

Hi gang, I have the following code inside a the file script.sh #!/bin/bash todaysdate=$(date --date='7 day' +'%d') todaysmonth=$(date +'%m') todaysyear=$(date +'%Y') yahoodatestring=$todaysyear$todaysmonth$todaysdate nicedate=$(date --date='5 day' +'%A') nice="$nicedate,... (2 Replies)
Discussion started by: phpchick
2 Replies

6. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

7. Shell Programming and Scripting

Problems activating "mod_rewrite" (I can't edit 000-default file)

Hello everyone, Maybe an expert could help me.. I'm trying to activate mod_rewrite module on a Ubuntu 11.04 server (natty) and I having problem to edit the file 000-default in 3rd step, the steps to activate the module are: 1-Install Apache web server in Ubuntu Linux 2-Enable mod_rewrite... (6 Replies)
Discussion started by: cgkmal
6 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. AIX

AIX 5.3 - Discrepancies between "top" and "vmstat"

Can someone explain the differences I'm seeing below in TOP and VMSTAT commands on my AIX 5.3 server? Thanks! CPUs: 4; load averages: 0.86, 0.97, 0.97 18:09:26 926 processes: 4 stopped, 922 running CPU states: 78.4% idle, 8.5% user, 12.6% kernel, 0.3% wait Memory: 23680M Total.... (1 Reply)
Discussion started by: troym72
1 Replies

10. AIX

"pconsole" and "esaadmin" on AIX version 6

Anyone know what is the function of user "pconsole" and "esaadmin" on AIX version 6? (1 Reply)
Discussion started by: ebab3
1 Replies
Login or Register to Ask a Question