Monday, May 29, 2017

RHEL7 - Install NSCD - Name Service Cache Daemon


Install NSCD - Name Service Cache Daemon

[root@puppet puppet-enterprise-2017.2.1-el-7-x86_64]# yum install nscd

[root@puppet puppet-enterprise-2017.2.1-el-7-x86_64]# systemctl start nscd
[root@puppet puppet-enterprise-2017.2.1-el-7-x86_64]# systemctl status nscd
● nscd.service - Name Service Cache Daemon
   Loaded: loaded (/usr/lib/systemd/system/nscd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-05-29 20:19:53 EDT; 7s ago
  Process: 13229 ExecStart=/usr/sbin/nscd $NSCD_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 13230 (nscd)

To flush/clear DNS Cache you need to restart “nscd” service if installed.

[root@puppet puppet-enterprise-2017.2.1-el-7-x86_64]# systemctl restart nscd

Sunday, April 2, 2017

RHEL7 - LVM

total 396
-rw-r--r--. 1 root root     16 Apr  2 11:16 file1
-rw-r--r--. 1 root root     16 Apr  2 11:16 file2
drwxr-xr-x. 2 root root      6 Apr  2 11:30 html
-rw-r--r--. 1 root root 130532 Apr  2 10:27 index.htm
-rw-r--r--. 1 root root     37 Apr  2 11:30 index.html
-rw-r--r--. 1 root root 130532 Apr  2 10:31 index.html.old
-rw-r--r--. 1 root root 130532 Apr  2 10:27 newindex.html
[root@prema html]# pwd
/var/www/html
[root@prema html]# cd /opt/www/
[root@prema www]# ls
[root@prema www]# ls
[root@prema www]# mkdir html
[root@prema www]# cat >index.html
Testing to see if it works from /opt
[root@prema www]# pwd
/opt/www
[root@prema www]# ls
html  index.html
[root@prema www]# mv index.html html/
[root@prema www]# cd html
[root@prema html]# ls
index.html
[root@prema html]# ls -l
total 4
-rw-r--r--. 1 root root 37 Apr  2 11:31 index.html
[root@prema html]# ls -ld /var/www/html
drwxr-xr-x. 3 root root 122 Apr  2 11:30 /var/www/html
[root@prema html]# ls -l /var/www/html
total 396
-rw-r--r--. 1 root root     16 Apr  2 11:16 file1
-rw-r--r--. 1 root root     16 Apr  2 11:16 file2
drwxr-xr-x. 2 root root      6 Apr  2 11:30 html
-rw-r--r--. 1 root root 130532 Apr  2 10:27 index.htm
-rw-r--r--. 1 root root     37 Apr  2 11:30 index.html
-rw-r--r--. 1 root root 130532 Apr  2 10:31 index.html.old
-rw-r--r--. 1 root root 130532 Apr  2 10:27 newindex.html
[root@prema html]# ls -l
total 4
-rw-r--r--. 1 root root 37 Apr  2 11:31 index.html
[root@prema html]# ls -lZ
-rw-r--r--. root root unconfined_u:object_r:usr_t:s0   index.html
[root@prema html]# chcon -t httpd_sys_content_t /opt/www/html
[root@prema html]# ls -lZ /opt/www/html
-rw-r--r--. root root unconfined_u:object_r:usr_t:s0   index.html
[root@prema html]# ls -ldZ /opt/www/html
drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 /opt/www/html
[root@prema html]# semanage fcontext -a -t httpd_sys_content_t '/opt/www/html(/.*)?'
[root@prema html]#
[root@prema html]# ls -lZ
-rw-r--r--. root root unconfined_u:object_r:usr_t:s0   index.html
[root@prema html]# restorecon -RFvv /opt/www/html
restorecon reset /opt/www/html context unconfined_u:object_r:httpd_sys_content_t:s0->system_u:ont_t:s0
restorecon reset /opt/www/html/index.html context unconfined_u:object_r:usr_t:s0->system_u:objet:s0
[root@prema html]# ls -l
total 4
-rw-r--r--. 1 root root 37 Apr  2 11:31 index.html
[root@prema html]# ls -lZ
-rw-r--r--. root root system_u:object_r:httpd_sys_content_t:s0 index.html
[root@prema html]# systemctl status httmlp
Unit httmlp.service could not be found.
[root@prema html]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sun 2017-04-02 11:30:15 EDT; 5min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 12078 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 12072 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE
 Main PID: 12072 (code=exited, status=1/FAILURE)

Apr 02 11:30:15 prema.expanor.local systemd[1]: Starting The Apache HTTP Server...
Apr 02 11:30:15 prema.expanor.local httpd[12072]: AH00526: Syntax error on line 121 of /etc/htt
Apr 02 11:30:15 prema.expanor.local httpd[12072]: DocumentRoot '/opt/www/html' is not a directo
Apr 02 11:30:15 prema.expanor.local systemd[1]: httpd.service: main process exited, code=exited
Apr 02 11:30:15 prema.expanor.local kill[12078]: kill: cannot find process ""
Apr 02 11:30:15 prema.expanor.local systemd[1]: httpd.service: control process exited, code=exi
Apr 02 11:30:15 prema.expanor.local systemd[1]: Failed to start The Apache HTTP Server.
Apr 02 11:30:15 prema.expanor.local systemd[1]: Unit httpd.service entered failed state.
Apr 02 11:30:15 prema.expanor.local systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
[root@prema html]# systemctl start httpd
[root@prema html]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2017-04-02 11:35:42 EDT; 2s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 12078 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
 Main PID: 12216 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─12216 /usr/sbin/httpd -DFOREGROUND
           ├─12242 /usr/sbin/httpd -DFOREGROUND
           ├─12243 /usr/sbin/httpd -DFOREGROUND
           ├─12245 /usr/sbin/httpd -DFOREGROUND
           ├─12246 /usr/sbin/httpd -DFOREGROUND
           └─12247 /usr/sbin/httpd -DFOREGROUND

Apr 02 11:35:35 prema.expanor.local systemd[1]: Starting The Apache HTTP Server...
Apr 02 11:35:42 prema.expanor.local systemd[1]: Started The Apache HTTP Server.
[root@prema html]# netstat -an | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN
[root@prema html]# pwd
/opt/www/html
[root@prema html]# ls
index.html
[root@prema html]# netstat -an | grep 8080^C
[root@prema html]# ls -lZ ../
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 html
[root@prema html]# pwd
/opt/www/html
[root@prema html]# ls -l
total 4
-rw-r--r--. 1 root root 37 Apr  2 11:31 index.html
[root@prema html]# firewall-cmd --reload
success
[root@prema html]# pwd
/opt/www/html
[root@prema html]# ls -l
total 4
-rw-r--r--. 1 root root 37 Apr  2 11:31 index.html
[root@prema html]# ls -lZ
-rw-r--r--. root root system_u:object_r:httpd_sys_content_t:s0 index.html
[root@prema html]# ls -l /var/www/html
total 396
-rw-r--r--. 1 root root     16 Apr  2 11:16 file1
-rw-r--r--. 1 root root     16 Apr  2 11:16 file2
drwxr-xr-x. 2 root root      6 Apr  2 11:30 html
-rw-r--r--. 1 root root 130532 Apr  2 10:27 index.htm
-rw-r--r--. 1 root root     37 Apr  2 11:30 index.html
-rw-r--r--. 1 root root 130532 Apr  2 10:31 index.html.old
-rw-r--r--. 1 root root 130532 Apr  2 10:27 newindex.html
[root@prema html]# pwd
/opt/www/html
[root@prema html]# vi /etc/
Display all 287 possibilities? (y or n)
[root@prema html]# vi /etc/h
host.conf    hostname     hosts        hosts.allow  hosts.deny   hp/          httpd/
[root@prema html]# vi /etc/httpd/conf
conf/           conf.d/         conf.modules.d/
[root@prema html]# vi /etc/httpd/conf/
httpd.conf  magic
[root@prema html]# vi /etc/httpd/conf/httpd.conf
[root@prema html]# systemctl stop httpd
[root@prema html]# systemctl start httpd
[root@prema html]# pwd
/opt/www/html
[root@prema html]# ls
index.html
[root@prema html]# cat >prema.html
This file is to test Prema's page
[root@prema html]# vi /etc/httpd/conf/httpd.conf
[root@prema html]# systemctl stop httpd
[root@prema html]# systemctl start httpd
[root@prema html]# pwd
/opt/www/html
[root@prema html]# cd /var/www/html/
[root@prema html]# ls
file1  file2  html  index.htm  index.html  index.html.old  newindex.html
[root@prema html]# cat index.htm | more
[root@prema html]# ls
file1  file2  html  index.htm  index.html  index.html.old  newindex.html
[root@prema html]# cat index.html
Testing to see if it works from /opt
[root@prema html]# cat > index.html
Just addedd !!!
[root@prema html]# getsebool -a | more
abrt_anon_write --> off
abrt_handle_event --> off
abrt_upload_watch_anon_write --> on
antivirus_can_scan_system --> off
antivirus_use_jit --> off
auditadm_exec_content --> on
authlogin_nsswitch_use_ldap --> off
authlogin_radius --> off
authlogin_yubikey --> off
awstats_purge_apache_log_files --> off
boinc_execmem --> on
cdrecord_read_content --> off
cluster_can_network_connect --> off
cluster_manage_all_files --> off
cluster_use_execmem --> off
cobbler_anon_write --> off
cobbler_can_network_connect --> off
cobbler_use_cifs --> off
cobbler_use_nfs --> off
collectd_tcp_network_connect --> off
condor_tcp_network_connect --> off
conman_can_network --> off
cron_can_relabel --> off
cron_system_cronjob_use_shares --> off
cron_userdomain_transition --> on
cups_execmem --> off
cvs_read_shadow --> off
daemons_dump_core --> off
daemons_enable_cluster_mode --> off
daemons_use_tcp_wrapper --> off
daemons_use_tty --> off
dbadm_exec_content --> on
dbadm_manage_user_files --> off
dbadm_read_user_files --> off
deny_execmem --> off
deny_ptrace --> off
dhcpc_exec_iptables --> off
dhcpd_use_ldap --> off
docker_connect_any --> off
domain_fd_use --> on
domain_kernel_load_modules --> off
entropyd_use_audio --> on
exim_can_connect_db --> off
exim_manage_user_files --> off
[root@prema html]# getsebool -a | grep http
httpd_anon_write --> off
httpd_builtin_scripting --> on
httpd_can_check_spam --> off
httpd_can_connect_ftp --> off
httpd_can_connect_ldap --> off
httpd_can_connect_mythtv --> off
httpd_can_connect_zabbix --> off
httpd_can_network_connect --> off
httpd_can_network_connect_cobbler --> off
httpd_can_network_connect_db --> off
httpd_can_network_memcache --> off
httpd_can_network_relay --> off
httpd_can_sendmail --> off
httpd_dbus_avahi --> off
httpd_dbus_sssd --> off
httpd_dontaudit_search_dirs --> off
httpd_enable_cgi --> on
httpd_enable_ftp_server --> off
httpd_enable_homedirs --> off
httpd_execmem --> off
httpd_graceful_shutdown --> on
httpd_manage_ipa --> off
httpd_mod_auth_ntlm_winbind --> off
httpd_mod_auth_pam --> off
httpd_read_user_content --> off
httpd_run_ipa --> off
httpd_run_preupgrade --> off
httpd_run_stickshift --> off
httpd_serve_cobbler_files --> off
httpd_setrlimit --> off
httpd_ssi_exec --> off
httpd_sys_script_anon_write --> off
httpd_tmp_exec --> off
httpd_tty_comm --> off
httpd_unified --> off
httpd_use_cifs --> off
httpd_use_fusefs --> off
httpd_use_gpg --> off
httpd_use_nfs --> off
httpd_use_openstack --> off
httpd_use_sasl --> off
httpd_verify_dns --> off
named_tcp_bind_http_port --> off
prosody_bind_http_port --> off
[root@prema html]# getsebool -a | grep nfs
cobbler_use_nfs --> off
ftpd_use_nfs --> off
git_cgi_use_nfs --> off
git_system_use_nfs --> off
httpd_use_nfs --> off
ksmtuned_use_nfs --> off
logrotate_use_nfs --> off
mpd_use_nfs --> off
nfs_export_all_ro --> on
nfs_export_all_rw --> on
nfsd_anon_write --> off
openshift_use_nfs --> off
polipo_use_nfs --> off
samba_share_nfs --> off
sanlock_use_nfs --> off
sge_use_nfs --> off
tmpreaper_use_nfs --> off
use_nfs_home_dirs --> off
virt_use_nfs --> off
xen_use_nfs --> off
[root@prema html]# ls -l /var/tmp | more
total 20
drwxr-xr-x. 2 abrt   abrt       6 Feb 11 12:56 abrt
drwxrwxr-x. 2 kamal  kamal     61 Apr  2 08:26 book
-rw-------. 1 prema  prema  12288 Apr  2 08:25 crontab.swp
-rw-r--r--. 1 pradip pradip    24 Apr  2 10:14 echo.txt
-rw-r--r--. 1 root   root      16 Apr  2 11:16 file1
drwx------. 3 root   root      17 Mar 30 07:07 systemd-private-7ba6bfa692bc4b53a1e4afb7398d3acd
-colord.service-msbY68
drwx------. 3 root   root      17 Mar 30 07:07 systemd-private-7ba6bfa692bc4b53a1e4afb7398d3acd
-cups.service-yEjooP
drwx------. 3 root   root      17 Mar 30 02:07 systemd-private-7ba6bfa692bc4b53a1e4afb7398d3acd
[root@prema html]# cp echo.txt .
cp: cannot stat ‘echo.txt’: No such file or directory
[root@prema html]# cp /var/tmp/echo.txt .
[root@prema html]# mv /var/tmp/echo.txt .
mv: overwrite ‘./echo.txt’? y
[root@prema html]# restorecon /var/tmp/echo.txt
restorecon:  lstat(/var/tmp/echo.txt) failed:  No such file or directory
[root@prema html]# restorecon echo.txt
[root@prema html]# ls -lZ
-rw-r--r--. pradip pradip unconfined_u:object_r:httpd_sys_content_t:s0 echo.txt
-rw-r--r--. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 file1
-rw-r--r--. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 file2
drwxr-xr-x. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 html
-rw-r--r--. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 index.htm
-rw-r--r--. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 index.html
-rw-r--r--. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 index.html.old
-rw-r--r--. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 newindex.html
[root@prema html]# pwd
/var/www/html
[root@prema html]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00049362

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e7d729c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     2099200           0   83  Linux
/dev/sdb3         2099200     3123199      512000   83  Linux
/dev/sdb4         3123200     4194303      535552    5  Extended
/dev/sdb5         3125248     4194303      534528   83  Linux
[root@prema html]# pwd
/var/www/html
[root@prema html]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00049362

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e7d729c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     2099200           0   83  Linux
/dev/sdb3         2099200     3123199      512000   83  Linux
/dev/sdb4         3123200     4194303      535552    5  Extended
/dev/sdb5         3125248     4194303      534528   83  Linux
[root@prema html]# echo "- - -" >/sys/class/scsi_host/host0/scan
[root@prema html]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00049362

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e7d729c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     2099200           0   83  Linux
/dev/sdb3         2099200     3123199      512000   83  Linux
/dev/sdb4         3123200     4194303      535552    5  Extended
/dev/sdb5         3125248     4194303      534528   83  Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@prema html]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x62acd18b.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x62acd18b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     2097151     1047552   83  Linux

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x62acd18b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     2097151     1047552   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@prema html]# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xaa83a64b.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set

Command (m for help): p

Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xaa83a64b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048     2097151     1047552   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xaa83a64b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048     2097151     1047552   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@prema html]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00049362

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e7d729c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     2099200           0   83  Linux
/dev/sdb3         2099200     3123199      512000   83  Linux
/dev/sdb4         3123200     4194303      535552    5  Extended
/dev/sdb5         3125248     4194303      534528   83  Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x62acd18b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     2097151     1047552   8e  Linux LVM

Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xaa83a64b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048     2097151     1047552   8e  Linux LVM
[root@prema html]# pvcreate /dev/sdc1 /dev/sdd1
  Physical volume "/dev/sdc1" successfully created.
  Physical volume "/dev/sdd1" successfully created.
[root@prema html]# pvs
  PV         VG Fmt  Attr PSize    PFree
  /dev/sdc1     lvm2 ---  1023.00m 1023.00m
  /dev/sdd1     lvm2 ---  1023.00m 1023.00m
[root@prema html]# vgcreate datavg /dev/sdc1 /dev/sdd1
  Volume group "datavg" successfully created
[root@prema html]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  datavg   2   0   0 wz--n- 1.99g 1.99g
[root@prema html]# vgdisplay
  --- Volume group ---
  VG Name               datavg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1.99 GiB
  PE Size               4.00 MiB
  Total PE              510
  Alloc PE / Size       0 / 0
  Free  PE / Size       510 / 1.99 GiB
  VG UUID               2TwgJD-hFfO-Gplq-loDa-x2t1-Danh-M1exWA

[root@prema html]# lvcreate -n datavol -L 500mb datavg
  Logical volume "datavol" created.
[root@prema html]# lvs
  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  datavol datavg -wi-a----- 500.00m
[root@prema html]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  datavg   2   1   0 wz--n- 1.99g 1.50g
[root@prema html]# lvscan
  ACTIVE            '/dev/datavg/datavol' [500.00 MiB] inherit
[root@prema html]# mkfs.
mkfs.btrfs   mkfs.ext2    mkfs.ext4    mkfs.minix   mkfs.vfat
mkfs.cramfs  mkfs.ext3    mkfs.fat     mkfs.msdos   mkfs.xfs
[root@prema html]# mkfs.xfs /dev/datavg/datavol
meta-data=/dev/datavg/datavol    isize=512    agcount=4, agsize=32000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=128000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@prema html]# blkid /dev/datavg/datavol
/dev/datavg/datavol: UUID="a834ee86-6aa9-4efc-b023-030bafb22343" TYPE="xfs"
[root@prema html]# blkid /dev/datavg/datavol >>^C
[root@prema html]# cp -p /etc/fstab /etc/fstab.bakk
[root@prema html]# blkid /dev/datavg/datavol >> /etc/fstab
[root@prema html]# vi /etc/fstab
[root@prema html]# ls -ld /opt/oracle
ls: cannot access /opt/oracle: No such file or directory
[root@prema html]# mkdir /opt/oracle
[root@prema html]# df -h /opt/oracle
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  4.5G   14G  25% /
[root@prema html]# mount -a
[root@prema html]# echo $?
0
[root@prema html]# df -h /opt/oracle/
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datavol  497M   26M  472M   6% /opt/oracle
[root@prema html]# vgdisplay
  --- Volume group ---
  VG Name               datavg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               1.99 GiB
  PE Size               4.00 MiB
  Total PE              510
  Alloc PE / Size       125 / 500.00 MiB
  Free  PE / Size       385 / 1.50 GiB
  VG UUID               2TwgJD-hFfO-Gplq-loDa-x2t1-Danh-M1exWA

[root@prema html]# lvscan
  ACTIVE            '/dev/datavg/datavol' [500.00 MiB] inherit
[root@prema html]# lvcreate -n appvol -l 125 datavg
  Logical volume "appvol" created.
[root@prema html]# lvscan
  ACTIVE            '/dev/datavg/datavol' [500.00 MiB] inherit
  ACTIVE            '/dev/datavg/appvol' [500.00 MiB] inherit
[root@prema html]# blkid
/dev/mapper/datavg-datavol: UUID="a834ee86-6aa9-4efc-b023-030bafb22343" TYPE="xfs"
/dev/sda1: UUID="05166f97-2ea9-4e49-8ab1-f8127e20766f" TYPE="xfs"
/dev/sda2: UUID="5117d513-bfe3-454e-b5bf-7f7e84e932c8" TYPE="swap"
/dev/sda3: UUID="6e26e829-ddcb-4581-988d-8b219b56d650" TYPE="xfs"
/dev/sdb1: UUID="e5a01988-2f62-4b79-9fc7-053471690c62" TYPE="xfs"
/dev/sdc1: UUID="37Y2Wd-6JhU-NfSQ-HE0q-H1Cv-s1Qv-Az9kIM" TYPE="LVM2_member"
/dev/sdd1: UUID="8eAELG-B9xo-zdHL-8yJl-UXMH-TyIM-XX8uBp" TYPE="LVM2_member"
[root@prema html]# lvremove /dev/datavg/appvol
Do you really want to remove active logical volume datavg/appvol? [y/n]: y
  Logical volume "appvol" successfully removed
[root@prema html]# lvscan
  ACTIVE            '/dev/datavg/datavol' [500.00 MiB] inherit
[root@prema html]# echo "- - -" /sys/class/scsi_host/host0/scan
- - - /sys/class/scsi_host/host0/scan
[root@prema html]# echo "- - -" >/sys/class/scsi_host/host0/scan
[root@prema html]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00049362

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x7e7d729c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     2099199     1048576   83  Linux
/dev/sdb2         2099200     2099200           0   83  Linux
/dev/sdb3         2099200     3123199      512000   83  Linux
/dev/sdb4         3123200     4194303      535552    5  Extended
/dev/sdb5         3125248     4194303      534528   83  Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x62acd18b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048     2097151     1047552   8e  Linux LVM

Disk /dev/sdd: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xaa83a64b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048     2097151     1047552   8e  Linux LVM

Disk /dev/mapper/datavg-datavol: 524 MB, 524288000 bytes, 1024000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@prema html]# fdisk /dev/sde
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x52c9c6ba.

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sde: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x52c9c6ba

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1            2048     2097151     1047552   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@prema html]# pvcreate /dev/sde1
  Physical volume "/dev/sde1" successfully created.
[root@prema html]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  datavg   2   1   0 wz--n- 1.99g 1.50g
[root@prema html]# vgextend datavg /dev/sde1
  Volume group "datavg" successfully extended
[root@prema html]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  datavg   3   1   0 wz--n- 2.99g 2.50g
[root@prema html]# df -h /opt/apps1/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  4.5G   14G  25% /
[root@prema html]# df -h /opt/oracle/
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datavol  497M   26M  472M   6% /opt/oracle
[root@prema html]# lvextend -L 2G /dev/mapper/datavg-datavol
  Size of logical volume datavg/datavol changed from 500.00 MiB (125 extents) to 2.00 GiB (512 extents).
  Logical volume datavg/datavol successfully resized.
[root@prema html]# ls -l /dev/mapper/datavg-datavol
lrwxrwxrwx. 1 root root 7 Apr  2 12:40 /dev/mapper/datavg-datavol -> ../dm-0
[root@prema html]# ls -l /dev/datavg-datavol
ls: cannot access /dev/datavg-datavol: No such file or directory
[root@prema html]# ls -l /dev/datavg/datavol
lrwxrwxrwx. 1 root root 7 Apr  2 12:40 /dev/datavg/datavol -> ../dm-0
[root@prema html]# df -h /opt/oracle/
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datavol  497M   26M  472M   6% /opt/oracle
[root@prema html]# lvscan
  ACTIVE            '/dev/datavg/datavol' [2.00 GiB] inherit
[root@prema html]# xfs_growfs /opt/oracle
meta-data=/dev/mapper/datavg-datavol isize=512    agcount=4, agsize=32000 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=128000, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 128000 to 524288
[root@prema html]# df -h /opt/oracle/
Filesystem                  Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datavol  2.0G   26M  2.0G   2% /opt/oracle
[root@prema html]#

Sunday, March 5, 2017

User create


for users in ram sam sita rita
do
useradd $user
# usermod -G flinstone $user
done

for group in sales markt delivery
do 
   groupadd $group
   usermod -G sales sam
   usermod -G sames sita
   usermod -G markt sita
  usermod -G delivery rita
done

066
---
600


[MYREPO]
name=My Centos Repo
baseurl=file:///opt/os_image
gpgcheck=0
enabled=1





1. Edit sudoers file
# visudo
2. Create Alias
a. User alias
UserAlias SALES = prema, bishal, pradip, kamal
b. create Command alias
Cmnd_Alias APPS = /sbin/useradd; /sbin/userdel, /bin/passwd
c. Create Host Alias
Host_Alias  HSALES = hhbs-mp-v01, dhmr-ap-v02
3. Grant the permission to the user
User_Alias Host_Alias=Cmnd_Alias
SALES HSALES=APPS

User_Alias SALES = prema, bishal, pradip
Cmnd_Alias APPS = /sbin/useradd, /sbin/userdel, /bin/passwd
Host_Alias  HSALES = hhbs-mp-v01, dhmr-ap-v02
SALES HSALES=APPS

$ sudo useradd testuser
$ sudo passwd testuser
$ id -a testuser
$ sudo userdel testuser

**********************************
Display available unit types
# systemctl -t help
systemctl command is used to manage different types of systemd objects, called units.
systemctl status name.type
systemctl status named.service

1. list all service unit on the system
# systemctl list-units --type=service
2. List all socket units that are active and inactive on the system
# systemctl list-units --type=socket
3. Check status of service chronyd
# systemctl status chronyd
# check if the process is running
# ps -p <PID>
4. Check if service is enable to start a boot
# systemctl is-enabled sshd
check if serice is active
# systemctl is-active sshd
5. Check enabled or disabled state of all services
# systemctl list-unit-files --type=service


Unit dependencies
# systemctl stop cups
systemctl stop cups
Warning: Stopping cups.service, but it can still be activated by:
  cups.path
  cups.socket
[root@rhel7-3 ~]#

to completely stop the service, you have to disable all services that this service depend up on.
# systemctl list-dependencies UNIT
# systemctl list-dependencies cups
Masking the service
# systemctl mask httpd.service
# systemctl unmask httpd.service
***************************

Three types of alias
1. User Alias
User_Alias ADMINS = prema, bishal, pradip, kamal
User_Alias SALES = john,mary,bill
2. Command Alias
Cmnd_Alias CMNDS = /sbin/useradd,/bin/passwd
CMD_Alias SCMDS = /usr/loca/bin/app2
3. Host alias
Host_Alias LSERVS = prema,bishal,pradip
User_Alias Host_Alias=Cmd_Alias
ADMINS LSERVS=CMNDS

Host_Alias LSERVS = prema, bishal, pradip
User_Alias ADMINS = prema, bishal, pradip, kamal
Cmnd_Alias CMNDS = /sbin/useradd, /bin/passwd




sales - ram sam sita
marketing - john bill, ram
hr - mary, jackson

a b c d e f g h i
1 2 3 4 5 6 7
addbc
+3
cffde - 3
amjhdh+changeme
dfsdaf+changeme
Who
md5 ->



ADMINS LSERVS=CMNDS




*******************************



Fun time

So, fun time begins now.. lets cheers for Spring.

Coll, excited

Just testing to  how it will be going..