How to add an entry in a configration file using shell

Taking care of your Linux box.
we
Lance Naik
Posts: 43
Joined: Wed Jan 21, 2004 6:36 pm
Location: Dubai, UAE
Contact:

How to add an entry in a configration file using shell

Postby we » Wed Jan 21, 2004 6:57 pm

How to add an entry in a configration file using shell without editing it...
Regards
EKF
+971 50 7861136

s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

ans.

Postby s7r1k3r » Wed Jan 21, 2004 7:14 pm

echo "option=value" >> configuration_file

for example:

echo "servername=testhost" >> /etc/httpd.conf
a10n3 s7r1k3r

LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re: ans.

Postby LinuxFreaK » Sat Jan 24, 2004 3:52 am

Dear s7r1k3r,
Salam,

s7r1k3r wrote:echo "option=value" >> configuration_file
for example: echo "servername=testhost" >> /etc/httpd.conf


This will only works for apending file not for Editing or removing content of file :) if you want to remove file content of file then you can also use ...

# echo > filename
or
# cat > file

Best Regards.
Farrukh Ahmed

s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

SED

Postby s7r1k3r » Sat Jan 24, 2004 2:06 pm

Of course, if you want full control, you can use sed.
a10n3 s7r1k3r

hb
Lance Naik
Posts: 36
Joined: Sun Jul 13, 2003 12:45 pm
Location: internet

Postby hb » Sat Jan 24, 2004 2:28 pm

aoa.

to edit most conf files u gota b root

if in shell u r not root

do 'su' command
then ur root passwd.

pwd
/home/username

cd /etc

vi resolv.con

then use vi commands.
initiallly it looks very irratiting, but later, u will enjoy it.
its so kewl.
i hav told u tool, now do google and get vi commands.
or man vi
blah..

hav phun
:p

tc all,
AH.
Never be afraid to try something new. Remember, amateurs built the ark; professionals built the Titanic. -- Anonymous

s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

Not to the point

Postby s7r1k3r » Sat Jan 24, 2004 8:38 pm

The author of this thread wanted to know how to edit without using an editor.
a10n3 s7r1k3r


Return to “Administration”

Who is online

Users browsing this forum: No registered users and 2 guests