Saturday, 7 May 2016

User Administration

Type of Users:
Root user                -           Default user highly privileged UID is 0. This will create while installing the operating system
System users         -           is nothing but services, at the time of installing particular package. UID starts from 1 to 499.
Local users            -           after installing of the operating system admin user will create these users. UID starts from 500 to 65534.
Ø  After creating a user, user home directory will be created in default path /home.
Ø  One group is will be created with same user name (primary group)
Ø  Files from /etc/skel will be copied automatically to user home directory
Ø  /etc/passwd file is updated with user information
Ø  /etc/group file is update with primary group information
Important files
/etc/passwd     User Information
/etc/shadow     User Passwords
/etc/group      Group Information
/etc/gshadow    Group Passwords
User Administration Commands:
# useradd <user name>     -           To create specified local user
# useradd –d <home directory> <user name>  - create a user with specified home path
[root@sankar ~]# useradd -d /users/ san
 

[root@sankar ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin


# useradd –u <UID> <user name>         - create user with specific UID.
# passwd <user name>      -           change the user password
# userdel <user name>      -           delete user
# userdel <user name>      -           delete user including home directory
# finger <user name>         -           See user properties
# chfn <user name>            -           Change user information




 
[root@sankar ~]# chfn root
Changing finger information for root.
Name [root]:





 # chage –l <user name> - to check user password expiry and account expiry information



 chage -l  root
Last password change                                    : May 02, 2015
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
 


 

# su - <user name> -           Switch to other user account
# id <user name>    -           it will show the user id




[root@sankar ~]# id
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys), 6(disk),10(wheel)
[root@sankar ~]#



# system-config-users         -           create and manage user account in GUI
Usermod command options:
-c = We can add comment field for the user account.
-d = To modify the directory for any existing user account.
-e = Using this option we can make the account expiry in specific period.
-g = Change the primary group for a User.
-G = To add a supplementary groups.
-a = To add anyone of the group to a secondary group.
-l = To change the login name from tecmint to tecmint_admin.
-L = To lock the user account. This will lock the password so we can’t use the account.
-m = moving the contents of the home directory from existing home dir to new dir.
-p = To Use un-encrypted password for the new password. (NOT Secured).
-s = Create a Specified shell for new accounts.
-u = Used to Assigned UID for the user account between 0 to 999.
-U = To unlock the user accounts. This will remove the password lock and allow us to use the user account.
Creating Groups:
Group information is located/stored on /etc/group file.
# groupadd <group name>           - Create a group with specified name
# usermod –G <group name> <user name> - Add user to group
# gpasswd –a san Administrators – Adds the user ravi to the group Administrators
# gpasswd –A san  Administrators – give user ravi administrative rights to the group
# gpasswd –d san  Administrators – remove user ravi from the group Administrators
# groupdel <group name> - Delete group name
# groupmod –n <new group name> <old group name> - change group name
# newgrp - <group name> - Login into the group if successful, re-initializes the user environment

Profile Management

A user profile is a visual display of personal data associated with a specific user, or a customized desktop environment. A profile refers therefore to the explicit digital representation of a person's identity. A user profile can also be considered as the computer representation of a user model.
/etc/profile                 -           it contains system void variables, if you do any modification in this file it will effect to the administrator and local user profiles.
~/.bash_profile         -           it contains user specific variables, if you do any modification in this file it will effect to that particular account only.
/etc/bashrc                 -           it contains system void alias variables
~/.bashrc                   -           it contains user specific alias variables
.bash_history           -           it contains all executed commands history
Commands:
# alias                        -           it will show the aliases 

[root@sankar ~]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@sankar ~]#

# unalias <alias name>     -           it will remove mentioned alias
Note: you can always define an alias using /etc/bashrc OR .bashrc files
File Permissions:
Permission
Value
Number
Read
r
4
Write
w
2
Execute
x
1
Default permissions when you create a file or directory
File Permissions
File
644
Directory
755
File and Directory Permissions
In above image explained about file permissions
Commands to Change file/directory permissions
Symbolic permissions
u          -           user/owner
g          -           Group
o          -           Others
w         -           Write
x          -           Execute
+          -           Allow
-           -           deny
# chmod [options] <mode/permissions> <file/directory> - to change permissions file/folder
            Example: chmod 744 file1
# chmod u+rwx file or directory : in case of user only
                        # chmod ug+rwx file or directoty : in case of user and group
                        # chmod u+w,g+r,o+x directory/file
                        # chmod u+rw,g+rw directory/file
                        # chmod u-r, g-w,o-rw directory/file
                        # chmod ugo+rwx file/directory
                        # chmod ugo-rwx file/directory
# chown [options] <new owner> <file/directory> - to change ownership of file/folder
            Example: chown user2 file1
                            chown user1:group1 file2
# chgrp [options] <new group> <file/directory> - to change group of file/folder
            Example: chgrp gorup2 file2

Redhat Linux Installation

This is Red Hat 6 RHEL (Red Hat Enterprise Linux) installation guide, step-by-step walkthrough with screenshots. Current version of Red Hat 6 is Beta, but also this RHEL 6 Beta version looks very stable and good OS, so that’s why I decided to write this RHEL 6 Installation guide.

The Red Hat Enterprise Linux 6 Beta is available on the following architectures:

  • i386
  • AMD64/Intel64
  • System z
  • IBM Power (64-bit)
Download Red Hat 6 Beta DVD images here.

Some of the many improvements and new features that are included in Red Hat Enterprise Linux 6

  • Power management – tickless kernel and improvements through the application stack to reduce wakeups, power consumption measurement by Powertop, Power Management (ASPM, ALPM), and adaptive system tuning by Tuned, all enhance more efficient system power usage.
  • Next generation networking – comprehensive IPv6 support (NFS 4, CIFS, mobile support [RFC 3775], ISATAP support), FCoE, iSCSI, and a new and improved mac 802.11 wireless stack.
  • Scalable filesystems – ext4 file system provides support for larger file sizes and significantly reduces repair times over ext3. XFS® is a high-performance file system that supports extremely large files and is optimized for large data transfers.
  • Virtualization – KVM includes performance improvements and new features, sVirt protects the guest and host from unauthorized access, SR-IOV and NPIV deliver high-performance virtual use of physical devices, and libvirt leverages kernel resource management functionality.
  • Enterprise security enhancement – SELinux includes improved ease of use, application sandboxing, and significantly increased coverage of system services, while SSSD provides unified access to identity and authentication services as well as caching for off-line use.
  • Development and runtime support – SystemTap improvements, ABRT is a new framework for simple collection and reporting of bug information, and improvements are made to GCC (version 4.4.3), glibc (version 2.11.1), and GDB (version 7.0.1).
On this guide I use Graphical Installer. There is also Kickstart automated installation method and Text-based Installer available. And I install this machine for Software Development Workstation and testing environment. So package selection is following: Desktop, Web server, Databases, Compiling tools, Java. Same method works also for servers, normal desktops and other setups, but of course different software selection. So let’s begin installation…

Burn Downloaded Image to DVD and Boot Computer Using Red Hat 6 Installation DVD

Check RHEL image MD5 sum and burn image to DVD with your favourite CD/DVD burner. And boot computer using Red Hat Installation DVD.

Red Hat 6 RHEL Installation

1. Select Install or upgrade an existing system option on Grub Menu

1. Select Install or upgrade an existing system option on Grub Menu

2. Choose a language

2. Choose a language

3. Choose a keyboard type

3. Choose a keyboard type

4. Choose a installation media

4. Choose a installation media

5. Skip DVD media test (or select media test, if you want to test installation media before installation)

5. Skip DVD media test (or select media test, if you want to test installation media before installation)

6. Red Hat 6 graphical installer starts, select next

6. Red Hat 6 graphical installer starts, select next

7. Accepct Pre-Release Installation

7. Accepct Pre-Release Installation

8. Select storage devices

8. Select storage devices

9. Insert computer name

9. Insert computer name

10. Select time zone

10. Select time zone

11. Enter a password for root user

11. Enter a password for root user

12. Select type of installation

Read every options info carefully. And select encrypting if needed and option to review and modify partition layout.
12. Select type of installation

13. Review partition layout

Modify if needed. Default setup with ext4 and LVM looks good for desktop machine.
13. Review partition layout and modify if needed

14. Accept write changes to disc

14. Accept write changes to disc

15. Writing changes (creating partitions) to disc

15. Writing changes (creating partitions) to disc

16. Configure boot loader options

Select device to install bootloader and check/create boot loader operating system list.
16. Configure boot loader options

17. Select softwares to install and enable repositories

This case we select Software Development Workstation and enable Red Hat Enterprise Linux 6.0 Beta Repository and select Customize now.
17. Select softwares to install and enable repositories

18. Customize package selection

Select PHP and Web Server to installation.
18. Customize package selection - Select PHP and Web Server to installation
Select MySQL and PostgreSQL Databases.
18. Customize package selection - Select MySQL and PostgreSQL Databases
Select set of Development tools like Eclipse IDE.
18. Customize package selection - Select set of Development tools like Eclipse IDE

19. Checking dependencies for installation

19. Checking dependencies for installation

20. Starting installation process

20. Starting installation process

21. Installing packages

21. Installing packages 1
21. Installing packages 2

22. Installation is complete

Click reboot computer and remove installation media.
22. Installation is complete - Click reboot computer and remove installation media

Red Hat 6 RHEL Finishing Installation

23. Selecting RHEL 6 from grub

23. Selecting RHEL 6 from grub

24. Booting Red Hat 6

24. Booting Red Hat 6

25. Red Hat 6 Welcome screen

25. Red Hat 6 Welcome screen

26. Create normal user

26. Create normal user

27. Setup date and time and keep up-to-date with NTP

27. Setup date and time
27. Setup date and time and keep up-to-date with NTP

28. Login Red Hat 6 Gnome Desktop

28. Login Red Hat 6 Gnome Desktop

29. Red Hat (RHEL) 6 Gnome Desktop, empty and default look

29. Red Hat (RHEL) 6 Gnome Desktop, empty and default look

Text Editors

Text Editors


Console Based Text Editors:
1.    Emacs
2.    Nano
3.    Vim/vi

Graphical (GUI) Editors:
1.    Gedit
2.    Gvim
3.    Sublime (have to install separately)

Now we are going to discuss about vi/vim editor.
Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the VI editor distributed with most UNIX systems. It is a tool, the use of which you must be learned. Program is written by Bram Moolenaar et al.

Usage of vi/vim, it has three modes
1.    Command mode
2.    Insert Mode
3.    Ex-mode

Command mode: this mode is the default mode following things we can do
Yank/copy (yy)         -           copying the single line
(nyy)   n number of lines at a time you can copy.
p                                  -           Paste a content bellow the cursor
P                                 -           Paste content above the cursor
dd                                -           Delete a single line
ndd  n number of line delete yet a time
x                                  -           Deleting a single character
dw                               -           Deleting a single word
.                      -           redo
u                      -           Undo
J                      -           Joining the line
r                      -           Replace the character

Arrow Keys
h                      -           Left
j                       -           Down
k                      -           Up
l                       -           Right
Ctrl+d            -           Scroll Down
Ctrl+u            -           Scroll UP

Insert Mode: This mode is used to insert the text into the file
i           -           Inserting the content before the cursor position
I          -           it will insert the character starting of the line
a          -           it will insert the character of the cursor append
A         -           It will append the character from end of the line
O         -           It will insert a new line above the cursor
o          -           It will insert a new line below the cursor
s          -           Substitute the stream

EX-Mode:   Esc is used to change the mode. Press Escape key to enter EX-Mode
:w        -           save the modifications
:q         -           quit
:wq      -           save & quit
:w!       -           save forcefully
:q!        -           Quit forcefully
:set nu            -           setting the line numbers
:set nonu       -           Remove line numbers
:<number>    -           it will goes to particular line
:%s/find string name/replace string/g     - to replace the string group of lines
:r         -           reading the another file from here
:!<command>           -           command will execute from here
:r !date           -           output will save in current file