How do I read a text file using awk pattern scanning and text processing language under Linux / Unix like operating systems?
[continue reading…]
etc passwd
[continue reading…]
Q. How do I reverse lines of a file under Linux / UNIX bash shell?
A. You need to use the rev utility or command. It copies the specified files to the standard output, reversing the order of characters in every line. If no files are specified, the standard input is read.
Display one line
tail -1 /etc/passwd
Output:
dnsmasq:x:111:65534:dnsmasq,,,:/var/lib/misc:/bin/false
Reverse one line
$ tail -1 /etc/passwd | rev
Output:
eslaf/nib/:csim/bil/rav/:,,,qsamsnd:43556:111:x:qsamsnd
Q. How do I change DNS search order in Linux? In order to improve performance I need to make changes.
A. Under Linux you need to use /etc/nsswitch.conf file which is used by system databases and Name Service Switch configuration file
Various functions in the C Library need to be configured to work correctly in the local environment. Tradition ally, this was done by using files (e.g., ‘/etc/passwd’), but other nameservices (like the Network Information Service (NIS) and the Domain Name Service (DNS)) became popular, and were hacked into the C library, usually with a fixed search order.
Step # 1: /etc/nsswitch.conf
Open /etc/nsswitch.conf file using text editor:
# vi /etc/nsswitch.conf
Look for hosts:
hosts: files dns mdns4
Set above order as per your requirement. Close and save the file.
host.conf – resolver configuration file
The file /etc/host.conf contains configuration information specific to the resolver library. It should contain one configuration keyword per line, followed by appropriate configuration information.
Open /etc/host.conf file
# vi /etc/host.conf
Find order line which specifies how host lookups are to be performed. It should be followed by one or more lookup methods, separated by commas. Valid methods are bind (dns server), hosts (/etc/hosts file), and nis (old method).
order hosts,bind
Save and close the file.
See the nsswitch.conf and host.conf man pages for details.
[continue reading…]
[continue reading…]
Q. Can you tell us what defines a user account under Linux operating system?
[continue reading…]