Ask Your Question

could not change service name in augtool

asked 2015-02-19 11:19:21 -0500

Chutki gravatar image

I want to edit existing service name from /etc/services, tried below

augtool> print /files/etc/services/service-name[.="test"]
/files/etc/services/service-name[1] = test
/files/etc/services/service-name[1]/port = 01
/files/etc/services/service-name[1]/protocol = tcp
/files/etc/services/service-name[1]/#comment = #test
/files/etc/services/service-name[2] = test
/files/etc/services/service-name[2]/port = 01
/files/etc/services/service-name[2]/protocol = udp
/files/etc/services/service-name[2]/#comment = #test

I want to change service name

method 1:
augtool> set /files/etc/services/service-name[.="test"][protocol = "tcp]  "test1"
autool> save
method 2:
augtool> mv /files/etc/services/service-name[.="test"][protocol = "tcp]  "test1"
autool> save

I got saved file 1, but when checked /etc/services I don't find the changes what I made( both mv and set changes). In the time stamp shows the file edit time.

I am testing for commenting out the file

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-02-19 12:21:48 -0500

GregLarkin gravatar image

updated 2015-02-20 12:25:56 -0500

Method #1 worked fine for me, but your command does have a syntax error. Maybe that's the problem? Please change:

set /files/etc/services/service-name[.="test"][protocol = "tcp]  "test1"


set /files/etc/services/service-name[.="test"][protocol = "tcp"]  "test1"

Note the missing double-quote after tcp


There is no good way to deal with comments in Augeas, and you have to look through this document to determine the best solution for you: Since Puppet wraps the usage of Augeas with the augeas resource, once you decide on a technique, you should be able to implement it in your Puppet code.

edit flag offensive delete link more


Greg, missing double-quote in tcp is typo. but when use "#test1" with set, I am getting error. Also I tried "mv /files/etc/services/service-name[.="test"][protocol = "tcp"] "#test1" " got file 1 saved message. But the entire line missed from /etc/services. Not sure why the commented line missing.

Chutki gravatar imageChutki ( 2015-02-20 12:04:46 -0500 )edit

Thanks Greg, will try to edit augeas module

Chutki gravatar imageChutki ( 2015-02-20 20:02:02 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-02-19 11:19:21 -0500

Seen: 61 times

Last updated: Feb 20 '15