User Management Interview Questions: 1. How to create a user ? Brief with full syntax.. /usr/sbin/useradd -u uid -g gid -c " User De...

User Management Interview Questions:
1. How to create a user ? Brief with full syntax..
/usr/sbin/useradd -u uid -g gid -c " User Descriptions" -m -d "Home Directory Path" -s "Shell" username
Example :
#useradd -u 535 -g unix -c "Unixrock blog" -m -d /export/home/unixrock -s /usr/bin/bash unixrock

–u UID ( From 0 to 65535 ) , 0 is reserved for root
-g Primary Group
-m Force to Create Home Directory Specified by –d and copy default skeleton files in /etc/skel folder
-d User Home Directory Path
-c User Descriptions
-s Shell Path
2. What are the important files for User Management task?
/etc/passwd
/etc/shadow
/etc/group
/etc/default/passwd
/etc/default/login

3. Describe the /etc/passwd fields ?
/etc/passwd file is having 7 fields
username:password:uid:gid:comment:home-directory-path:login-shell
Example :
unixrock:x:535:121:Unixrock blog:/export/home/unixrock:/usr/bin/bash

4. Describe the /etc/shadow file fields ?
/etc/shadow file is having 9 fields
loginID:password:lastchg:min:max:warn:inactive:expire:reserved
Example:
unixrock:R1EbI61VDyM2I:15995:7:91:7:::

5. Describe the /etc/group file fields ?
/etc/group file is having 4 fields
groupname:group-pwd:GID:user-list
Example:
unixrock::121:unixrock, raj

6. What is the different between "su  UserID" and "su - UserID" ?
"su UserID"     -  Doesn't check the PATH and Current Working Directory
"su - UserID"   -  Load the User's Profiles  (PATH/Current Working Directory)

7. Default permission of Passwd/Shadow/Group files ?
/etc/passwd 644
/etc/shadow 644
/etc/group    400
bash-3.00# ls -ld /etc/passwd /etc/shadow /etc/group
-rw-r--r--   1 root     sys          459 Dec 10 16:32 /etc/group
-rw-r--r--   1 root     sys        18498 Dec 11 09:09 /etc/passwd
-r--------   1 root     sys        10334 Dec 11 09:35 /etc/shadow
bash-3.00#

8. Default permission of file and Directory ?
Default permission of file is 644  (666 - 022 (umask vaule))
Default permission of directory is 755  (777 -022 (umask vaule))

9. How to view the list of users who currently logged in the system ?
"who" command will show the users who logged in the current system.
The command refers /var/adm/utmpx to obtain the information.
bash-3.00# who
root       pts/2        Sep 10 22:11    (192.168.10.22)
root       pts/3        Dec 11 22:55    (192.168.10.22)
bash-3.00#
bash-3.00# ls -ld /var/adm/utmpx
-rw-r--r--   1 root     bin         2976 Dec 11 22:55 /var/adm/utmpx
bash-3.00# file /var/adm/utmpx
/var/adm/utmpx: data
bash-3.00#

10. How to view the User's login and logout details ?
"last " command will show the users login and logout details.
The command refers /var/adm/wtmpx to obtain the information.
bash-3.00# last
root      pts/3        192.168.10.22    Wed Dec 11 22:55   still logged in
root      sshd         192.168.10.22    Wed Dec 11 22:55   still logged in
root      pts/2        192.168.10.22    Tue Sep 10 22:11   still logged in
root      sshd         192.168.10.22    Tue Sep 10 22:11 - 22:55 (92+00:43)
reboot    system boot                   Tue Sep 10 22:03
reboot    system down                   Fri Sep  6 17:59
wtmp begins Tue Aug 13 01:32
bash-3.00#
bash-3.00# ls -ld /var/adm/wtmpx
-rw-r--r--   1 adm      adm        68820 Dec 11 22:55 /var/adm/wtmpx
bash-3.00# file /var/adm/wtmpx
/var/adm/wtmpx: data
bash-3.00#

11. How to view details information about the User?
"finger username" will show the details about the user.
bash-3.00# finger unixrock
Login name: unixrock
Directory: /home/unixrock               Shell: /bin/sh
Never logged in.
No unread mail
No Plan.
bash-3.00#

12. Describe about SETUID/SETGID/StickyBIT ?
SETUID/SETGID/StickyBIT

13. How to check Primary and Secondary Group of One User ?
"id -a username" will show the user's Primary and Secondary groups.
FYI, One User can be added in 15 no; of Secondary groups, But Only one Primary Group.
bash-3.00# id -a unixrock
uid=100(unixrock) gid=1(other) groups=1(other)
bash-3.00#
gid - Primary Group
groups - Secondary Group

14. How to rename the existing User ID ?
# usermod -l <newname> <oldname>
bash-3.00# usermod -l unixrock_new unixrock
UX: usermod: unixrock name too long.
bash-3.00# grep -i unixrock /etc/passwd
unixrock_new:x:100:1::/home/unixrock:/bin/sh
bash-3.00#

15. How to lock the User Account ?
# passwd -l UserID
bash-3.00# passwd -s unixrock
unixrock  PS
bash-3.00# passwd -l unixrock
passwd: password information changed for unixrock
bash-3.00# passwd -s unixrock
unixrock  LK
bash-3.00#

16. How to unlock the User Account?
# passwd -u <UserID>
bash-3.00# passwd -s unixrock
unixrock  LK
bash-3.00# passwd -u unixrock
passwd: password information changed for unixrock
bash-3.00# passwd -s unixrock
unixrock  PS
bash-3.00#

17. How to make the user account as non-expriry ?
# passwd -x -1 <userID>
bash-3.00# passwd -s unixrock
unixrock  PS    12/11/13     7    91     7
bash-3.00#
bash-3.00# passwd -x -1 unixrock
passwd: password information changed for unixrock
bash-3.00#
bash-3.00# passwd -s unixrock
unixrock  PS
bash-3.00#

18. How do we set force passwd change for User's first login ?
# passwd -f  <UserID>
bash-3.00# passwd -s unixrock
unixrock  PS    12/11/13     7    91     7
bash-3.00#
bash-3.00# passwd -f unixrock
passwd: password information changed for unixrock
bash-3.00#
bash-3.00# passwd -s unixrock
unixrock  PS    00/00/00     7    91     7
bash-3.00#

19. How to delete the User ID ?
# userdel <UserID> or # userdel -r <UserID>

-r option will delete the User's Home directory too.

20. Type of SHELLs ? What is initialization file for those SHELLS ?

/bin/bash  - Bourne Again shell
/bin/csh    - C shell
/bin/ksh   - Korn shell
/bin/tcsh   - TC shell
/bin/zsh    - Z shell

Bourne   /etc/profile    $HOME/.profile   /bin/sh     /etc/skel/local.profile
Korn      /etc/profile    $HOME/.profile   /bin/ksh   /etc/skel/local.profile
                                  $HOME/.kshrc
C           /etc/.login      $HOME/.cshrc    /bin/csh   /etc/skel/local.cshrc
                                  $HOME/.login                   /etc/skell/local.login

21. How to Check the User's Crontabs ? How to allow the User to access the Cron?
# crontab -l <username>
or
# ls -ltr /var/spool/cron/crontabs/

/etc/cron.d/cron.allow  : If the file exists, the users can use crontab whoever listed in that file.

22. How to check User's Present Working Directory Path? How to check the Obsolete Path of running process ?
Find the Present Working Directory Path
# pwd

Q: Which Users tare not allowed to login via ftp ? Ans: Users mentioned in the file ‘/etc/vsftpd/ftpusers’ are not allowed to login via ft...

Q: Which Users tare not allowed to login via ftp ?
Ans: Users mentioned in the file ‘/etc/vsftpd/ftpusers’ are not allowed to login via ftp.
Q: What is default directory for ftp / Anonymous user ?
Ans : ‘/var/ftp’ is the default directory for ftp or Anonymous user

Q: How to change the default directory for ftp / Anonymous user ?
Ans: Edit the file ‘/etc/vsftpd/vsftpd.conf’ and change the below directive :

anon_root=/<Path-of-New-Directory>
After making above change either restart or reload vsftpd service.

Q: How to disable Anonymous user in vsftpd ?
Ans: Edit the conf file ‘/etc/vsftpd/vsftpd.conf’ and change below directive and restart the ftp service.

anonymous_enable=NO

Q: What is chroot environment in ftp server ?
Ans: chroot environment prevents the user from leaving its home directory means jail like environment where users are limited to their home directory only. It is the addon security of ftp server.

Q: How to enable chroot environment in vsftpd server ?
Ans : To enable chroot environment edit the file ‘/etc/vsftpd/vsftpd.conf’ and enable the below directives :

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
The chroot_list_file variable specifies the file which contains users that are chroot.

Q: How to enable only limited/allowed users are able to login via ftp ?
Ans: This can be done by editing the file ‘/etc/vsftpd/vsftpd.conf’ and add the below directives :

userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

Q: How to set ftp banner in linux ?
Ans: Open the file ‘/etc/vsftpd/vsftpd.conf’ and set the below directive :

ftpd_banner= “Enter New Banner Here”

Q: How To limit the data transfer rate, number of clients & connections per IP for local users ?
Ans: Edit the ftp server’s config file(/etc/vsftpd/vsftpd.conf) and set the below directives :

local_max_rate=1000000 # Maximum data transfer rate in bytes per second
max_clients=50 # Maximum number of clients that may be connect

1. NFS is a protocol that allows a user to access files over a network; Samba is essentially a re-imaging of the Common Internet File Syste...

1. NFS is a protocol that allows a user to access files over a network; Samba is essentially a re-imaging of the Common Internet File System.

2. NFS has four versions, the newest of which includes a stateful protocol; Samba has multiple versions, the latest of which allows file and print sharing between multiple computers.


SMB (Server Message Block)
0:16 – Server Message Block or SMB was originally designed by IBM back in the 80’s. After its inception, Microsoft took the protocol and added some features to it. The additions included features such as LAN Manager. Services such as this allowed Windows systems to map shared drives and have this new share act as a local drive on the computer.  For simplicity’s sake, I will skip the 3rd and 4th point but we will get back to those in a minute. With the release of Windows Vista, Microsoft also released SMB 2.0. This was a major revision of SMB which, besides adding additional features, reduced the “chattiness” of the protocol. In other words, it reduced the bandwidth used or data amount transmitted, over the network. SMB 3.0 was released with Windows 8 and Server 2008 R2. With more improvements and added functionality, SMB 3.0 was aimed towards increasing effectiveness in Datacenters. When mapping a share, Windows will automatically perform the negotiation and sort out what version of SMB to use.

Now what were the points that we skipped? In the late 90’s Microsoft had attempted to rename SMB to CIFS or Common Internet File System. Unfortunately for Microsoft, this attempt was unsuccessful so they were skipped in order to avoid confusion. CIFS had additional features, but the name simply did not catch on and Microsoft simply went back to SMB in future versions. Due to this, CIFS is referred to as a dialect of SMB though you may hear CIFS and SMB used synonymously, but they are basically referring to Windows file sharing. Moving forward however, the term CIFS should really not be used as it is a relic of the past and it should only be considered SMB.

NFS (Network File System)
2:04 – The next file system we will be examining is Network File System, or NFS. Originally developed by Sun in the late 80’s, NFS version 1 was used internally within Sun Microsystems and never released publically. It was Version 2 that was released to the public however. This provided basic file sharing capabilities and was used extensively within Unix based systems. As they released Version 3 in 1995, it was enhanced to add 64bit support and was able to handle files larger than 2 gigabytes. In 2000, Sun released version 4 of NFS with added performance along with security improvements. This allowed for security methods to be applied and utilized to authenticate users, e.g. Kerberos. These security measures made NFS version 4 much more secure when compared to previous revisions.

In The Real World
2:56 - Now I want to ask you a question. In the real world, which protocol would you use? Windows shares support both SMB and NFS, or even both at the same time. It is merely a matter of configuring which one you need or configuring both if you need to utilize both. Ideally, you’ll want to use a native protocol when possible. For example, if you are connecting two Unix systems, it will be best to utilize NFS. If you are connecting two Windows systems, SMB would be the obvious choice. Even though both achieve the goal of file sharing, there are differences in the way Windows and Unix based systems handle file systems and the users that will be using the systems. Mixing the two can lead to compatibility problems. As NFS is good for host authentication, it makes connecting two servers together rather easy. This can be placed in the boot up configuration and the data would be available to the operating system without the need for a user to be logged in. You could even connect to another server based on the IP address alone. Conversely, Windows requires user authentication in order to connect to an SMB share and generally the user is required to be logged in. It is possible to circumvent this and you would do this for some services running on the local system, but it is, unfortunately, not as simple as NFS makes it. Windows is an excellent choice for using authentication. Until NFS version 4, this was something that NFS did not handle well and was prone to more security problems. If you are using a domain, then Windows handles user authentication very well. Ultimately, the decision will be made on what operating systems you are using and your software requirements. In future videos, we will discuss how Windows file sharing (SMB) works and also how to incorporate NFS using Windows Server.  

FTP means File Transfer Protocol while SFTP means Secured File Transfer Protocol. FTP uses Port 21 whereas SFTP uses Port 22. SFTP shares...

FTP means File Transfer Protocol while SFTP means Secured File Transfer Protocol.
FTP uses Port 21 whereas SFTP uses Port 22.
SFTP shares its files with full security whereas FTP uploads or downloads its data without any security.
Filezilla is best for FTP whereas winSCP is regarded best for SFTP.
FTP sends data in plain text while SFTP provides a little bit of privacy.
FTP is used by anyone whereas SFTP is used by server owner because 22 port is not open in case of shared hosting.
SFTP is fully secured and satisfactory whereas FTP is less secured.

OS BOOT TIME RHEL6: 40 sec RHEL7: 20 sec MAXIMUM SIZE OF SINGLE PARTITION RHEL6: 50TB(EXT4) RHEL7: 500TB(XFS) BOOT LOADER RHEL6:...

OS BOOT TIME
RHEL6: 40 sec

RHEL7: 20 sec

MAXIMUM SIZE OF SINGLE PARTITION
RHEL6: 50TB(EXT4)

RHEL7: 500TB(XFS)

BOOT LOADER
RHEL6:  /boot/grub/grub.conf

RHEL7: /boot/grupb2/grub.cfg

PROCESSOR ARCHITECTURE
RHEL6: It support 32bit & 64bit both

RHEL7: It only support 64bit

HOW TO FORMAT OR ASSIGN A FILE SYSTEM IN
RHEL6:      #mkfs.ext4   /dev/hda4

RHEL7:       #mkfs.xfs   /dev/hda3

HOW TO REPAIR A FILE SYSTEM IN
RHEL6:  #fsck -y /dev/hda3

RHEL7:  #xfs_repair /dev/hda3

COMMAND TO MANAGE NETWORK IN RHEL6 AND RHEL7
RHEL6:  #setup

RHEL7:  #nmtui

HOSTNAME CONFIGURATION FILE
RHEL6:    /etc/sysconfig/network

RHEL7:    /etc/hostname

DEFAULT ISO IMAGE MOUNT PATH
RHEL6: /media

RHEL7: /run/media/root

FILE SYSTEM CHECK
RHEL6:   e2fsck

RHEL7:   xfs_repair

RESIZE A FILE SYSTEM
RHEL6:   #resize2fs -p /dev/vg00/lv1

RHEL7:    #xfs_growfs  /dev/vg00/lv1

TUNE A FILE SYSTEM
RHEL6: tune2fs

RHEL7: xfs_admin

IPTABLES AND FIREWALL
RHEL6: iptables

RHEL7: firewalld

IPtables
To see firewall status in RHEL7

#firewall-cmd   –state

To see Firewall status in RHEL6

#service iptables status

To stop firewall in RHEL7

#systemctl stop firewalld.service

To stop firewall in RHEL6

#service iptables stop

COMMUNICATION BETWEEN TCP AND UDP IN BACK END
RHEL6: netcat

RHEL7: ncat

INTERFACE NAME
RHEL6: eth0

RHEL7: ens198(N)

COMBINING NIC
RHEL6: Network Bonding

RHEL7: Team Driver

NSF Server Version
RHEL6:  NFSv2

RHEL7:  NFSV4

DATABASE USED
RHEL6: Mysql

RHEL7: mariaDB

RHEL7 also support Mysql

MANAGING SERVICES
RHEL6:

#service sshd restart

#chkconfig sshd on

RHEL7:

#systemctl restart sshd

#systemctl enable shhd

File System.
RHEL6 default file system is ext4

xfs is RHEL7 default file system.

Kernel Version
RHEL6 default kernel version is 2.6 while RHEL7 is 3.10

UID Allocation
In RHEL6 default UID assigned to users would start from 500 while in RHEL7 it’s starting from 1000.
But this can be changed if required by editing /etc/login.defs file.

Maximum supported File Size.
In RHEL6 maximum file size of an individual file can be up to 16TB while in RHEL7 it can be up to 500TB which is very large in comparison to RHEL6.

Maximum Supported File System Size.
In RHEL6 maximum file system size=16TB (for 64bit Machine) and 8TB (for 32 bit machine). While in RHEL7 maximum file system size is 500TB.

Also keep in mind that RHEL does not support XFS on 32-bit machines.

Change in file system structure.
In rhel6 /bin,/sbin,/lib and /lib64 are usually under /

In rhel7, now /bin,/sbin,/lib and /lib64 are nested under /usr.

The /tmp directory can now be used as a temporary file storage system (tmpfs)

Space Required to Installing RHEL7?

Now if you want to install RHEL7 in your machine, RedHat recommends minimum 5 GB of disk space to install this release of RHEL series for all supported architectures.

.Hostname lookup and setup
In rhel5 and rhel6 versions, we can edit file /etc/sysconfig/network to set hostname but in rhel7 we can directly change the hostname using below commands.

hostnamectl
nmtui
nmcli
Example:

in RHEL6              #hostname

in RHEL7              #hostnamectl  status   and #hostname

Few More notable changes in RHEL 7.
Netstat and ifconfig commands also disappeared from RHEL7 but it can be used by installing net-tools.
The move from sysvinit to systemd is one of most important change that has been made and which is a matter of concerned.
Command tail -n is replaced by journalctl -n
Command tail -f is replaced by journalctl -f
For displaying kernel messages instead of dmesg now in RHEL7 we use journalctl –k

[root@ipaserver ~]# vmstat -s [root@ipaserver ~]# free -g [root@ipaserver ~]# free -h [root@ipaserver ~]# cat /proc/meminfo 

[root@ipaserver ~]# vmstat -s
[root@ipaserver ~]# free -g
[root@ipaserver ~]# free -h
[root@ipaserver ~]# cat /proc/meminfo 

Q. WHAT IS A PORT? A port is piece of software which is used as docking point in your machine, where remote application can communicate. T...

Q. WHAT IS A PORT?
A port is piece of software which is used as docking point in your machine, where remote application can communicate. This is analogy to the physical ports for entering in to a country from different sea ports.

Q. WHAT IS HARDWARE PORT?
This is a physical peripheral connecting point to a machine from a physical device.

Q. WHAT IS A SOCKET?
Socket is combination of software Port and IP address.

Q. WHAT IS THE RANGE OF PORTS OR HOW MANY PORTS ARE THERE?
Port numbers can vary from 0 to 65535, so total we can get 65536 ports

Q. WHY PORT NUMBERS ARE JUST 65536?
This is because limitation in TCP/IP stack where the port number field is just 16bit size. So we get only 2^16(2 to the power of 16) ports which are equal to 65536 available ports

Q. WHAT ARE THE WELL-KNOWN PORTS OR ASSIGNED PORTS OR DEFAULT PORTS?
Well known ports are from 0 to 1023(total 2^10=1024 ports)

Q. WHAT DO YOU MEAN BY DEFAULT PORT?
Default port is a designated port for particular well-known service such as web server, mail server, ftp server etc. By default FTP uses 21 port, DNS uses 53 and Apache uses 80 port.

Q. CAN WE CHANGE DEFAULT PORT FOR A SERVICE(EXAMPLE APACHE, SQUID)?
Yes, we can change. In Apache and DNS we can change this using listen configuration entry in httpd.conf and named.conf. Squid have port entry in it’s squid.conf file to mention port number.

Q. WHAT ARE THE PROTOCOL NUMBERS FOR TCP AND UDP?
Do not confuse this one with port numbers. TCP and UDP have their own numbers in TCP/IP stack.

TCP protocol number: 6

UDP protocol number: 17

Q. IS THERE ANY WAY I CAN SEE ALL THE PORT INFORMATION IN LINUX?
Yes, you can get that from /etc/services files.

Q. HOW CAN I SEE OPEN PORTS IN LINUX?
Use nmap command.

WELL KNOWN PORTS
20 – FTP Data (For transferring FTP data)

21 – FTP Control (For starting FTP connection)

22 – SSH (For secure remote administration which uses SSL to encrypt the transmission)

23 – Telnet (For insecure remote administration)

25 – SMTP (Mail Transfer Agent for e-mail server such as SEND mail)

53 – DNS (Special service which uses both TCP and UDP)

67 – Bootp

68 – DHCP

69 – TFTP (Trivial file transfer protocol uses udp protocol for connection less transmission of data)

80 – HTTP/WWW(Apache)

88 – Kerberos

110 – POP3 (Mail delivery Agent)

123 – NTP (Network time protocol used for time syncing uses UDP protocol)

137 – NetBIOS (nmbd)

139 – SMB-Samba (smbd)

143 – IMAP

161 – SNMP (For network monitoring)

389 – LDAP (For centralized administration)

443 – HTTPS (HTTP+SSL for secure web access)

514 – Syslogd (udp port)

636 – ldaps (both ctp and udp)

873 – rsync

989 – FTPS-data

990 – FTPS

993 – IMAPS

1194 – openVPN

1812 – RADIUS

995 – POP3s

2049 – NFS (nfsd, rpc.nfsd, rpc, portmap)

2401 – CVS server

3306 – MySql

3690 – SVN