≡ Menu

etc passwd

Linux / Unix AWK: Read a Text File

How do I read a text file using awk pattern scanning and text processing language under Linux / Unix like operating systems?
[click to continue…]

Grep Count Lines If a String / Word Matches

How do I count lines if given word or string matches for each input file under Linux or UNIX operating systems?
[click to continue…]

Shell script reverse lines of a file

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

Linux Changing DNS Search Order

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.

Q. How do I Move or migrate user accounts to from old Linux server a new Cent OS Linux server including mails? This new system a fresh installation.

A. You can migrate users from old Linux server to new Linux sever with standard commands such as tar, awk, scp and others. This is also useful if you are using old Linux distribution such as Redhat 9 or Debian 2.x.

Following files/dirs are required for traditional Linux user management:
* /etc/passwd - contains various pieces of information for each user account

* /etc/shadow - contains the encrypted password information for user's accounts and optional the password aging information.
[click to continue…]

Understanding /etc/passwd File Format

Can you explain /etc/passwd file format for Linux and UNIX operating systems?
[click to continue…]

Linux – What defines a user account?

Q. Can you tell us what defines a user account under Linux operating system?
[click to continue…]