Setup time synchronisation in CentOS
Answer:
You can install the NTP server using yum.
# yum install ntp
And enable the services during server startup
# chkconfig --levels 235 ntpd on
# ntpdate 0.pool.ntp.org
# /etc/init.d/ntpd start
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Setup time synchronisation in CentOS
Answer:
You can install the NTP server using yum.
# yum install ntp
And enable the services during server startup
# chkconfig --levels 235 ntpd on
# ntpdate 0.pool.ntp.org
# /etc/init.d/ntpd start
Replace text in vi with confirmation
Answer:
Similar to this article, you want to replace text, but you want to vi/vim to ask for confirmation before the actual replacements.
:%s/foo/bar/gc
Replace text in vi
Answer:
To replace a text in a file using vi/vim
Enter the command mode by typing :, and use the %s/foo/bar/g for global replacement(s).
:%s/foo/bar/g
All foo in the file will be replaced by bar
Convert a Nero .nrg file to .iso file
Answer:
It is easy to convert a Nero .nrg file to an .iso file, using the following command.
# dd bs=1k if=input.nrg of=output.iso skip=300
Capturing group difference in Basic Regular Expressions (BRE) and Extended Regular Expressions (ERE)
Answer:
One of the very confusion issue related to most GNU/Linux utils which are using regular expression library is they are mostly supporting the Basic Regular Expressions (BRE) by default.
E.g.
# echo "(foo)" | sed 's/\(foo\)/bar/gi'
You might expect the result is
bar
But the actual result is...
(bar)
Why the brackets are not replaced? It is because in BRE (which is the default, you don't need to escape, if you escape it, then it will be treated as a capturing group - which is quite non-sense if you came from programming background).
To solve the problem, you can just simply remove the \ escape, or you tell those commands to use ERE, e.g.
# echo "(foo)" | sed -r 's/\(foo\)/bar/gi'
bar