Search This Blog

Thursday 29 December 2016

Sync Windows Time with External NTP Server

​​Time synchronization is an important aspect for all computers on the network. By default, the clients computers get their time from a Domain Controller and the Domain Controller gets his time from the domain's PDC Operation Master. Therefore the PDC must synchronize his time from an external source. I usually use the servers listed at the NTP Pool Project website. Before you begin, don't forget to open the default UDP 123 port (in- and outbound) on your (corporate) firewall.
  1. Log in to your PDC Server and open the command prompt.
  2. Stop the W32Time service: C:>net stop w32time
  3. Configure the external time sources, type: C:> w32tm /config /syncfromflags:manual /manualpeerlist:3.in.pool.ntp.org
  4. Make your PDC a reliable time source for the clients. Type: C:>w32tm /config /reliable:yes
  5. Start the w32time service: C:>net start w32time
  6. The windows time service should begin synchronizing the time. You can check the external NTP servers in the time configuration by typing: C:>w32tm /query /configuration
  7. Check the status of the Clock Synchronization by typing : C:>w32tm /query /status

From Above image you can verify your Time Service is synced with External NTP Server and Last successful Sync Time.


Sunday 25 December 2016

Ubuntu 12.04 Grub to boot into single user mode

​Steps to boot in single user mode in Ubuntu 12.04:

Step 1: When you start your system, press "shift" key continuously to get the grub loader screen.

Step 2: In Grub 2 menu, select the menu with Linux 3.2.0.23-generic-pae highlighted.

Step3: Press 'e' to edit the grub2 menu.

Step 4:  Move the cursor to the line that starts with "linux /boot/vmlinuz-3.2.0-23-generice-pae".

Step 5: Change the content "ro quiet spalsh $vt_handoff" To "rw init=/bin/bash".

Step 6: Press "Ctrl+x" to continue boot to in single user mode.

Step 7: Now you will get prompt of the root user.

Step 8: Change root user password,
# passwd root

Step 9: Now sync and reboot the system i.e.
# sync
# reboot -f

Monday 19 December 2016

Eclipse birt environmental setup

Eclipse required 32 bit java environment.

In eclipse.ini file,add java version is requied for that specific Eclipse version.

For windows:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
–launcher.defaultAction
openFile
-vm
C:\Program Files (x86)\Java\jdk1.6.0_25\bin\javaw.exe
-vmargs
-Xms40m
-Xmx384m

For Linux:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-showsplash
org.eclipse.platform
–launcher.XXMaxPermSize
256m
–launcher.defaultAction
openFile
-vm
/opt//opt/jdk1.6.0_43/jre/bin/java
-vmargs
-Xms40m
-Xmx384m

Allow non-admin user to shutdown/reboot Window Server

​You can assign this in either a GPO or Local Security Policy.

The setting that you're looking for is in Computer Configuration > Windows Settings > Security Settings > Local Policies > User Rights Assignment > Shutdown the system


Granting Users to see the Definition of Stored Procedure created by Super User

Problem:

The Users in MySQL could not able to view definition of the store Procedures that are created by super users…

Cause:

You have to grant your "application user" select permissions on mysql.proc otherwise the connector can't see the sproc you're trying to call through it.

Solution:

Login as super user and grant the following select privilege to user who want to see the definition of stored procedure..

grant select on mysql.proc to user@localhost;

SQL Developer can’t start because MSVCR71.dll is missing (On Windows)

SQL Developer on Windows received above system error: due to mismatch of Java version.

error_sqldeveloper

Fix the issue by following steps:

  1. Run regedit (remember to run it as the administrator)
  2. Expand HKEY_LOCAL_MACHINE
  3. Expand SOFTWARE
  4. Expand Microsoft
  5. Expand Windows
  6. Expand CurrentVersion
  7. Expand App Paths
  8. At App Paths, add a new KEY called sqldeveloper.exe
  9. Expand sqldeveloper.exe
  10. Modify the (DEFAULT) value to the full pathway to the sqldeveloper executable (See example below step 11)
  11. Create a new STRING VALUE called Path and set it value to the sqldeveloper pathway + \jdk\jre\bin                                                                                 
  12. After the step 11 is completed, you van able to access sqldeveloper.exe

Grant select on all views and tables to user in Oracle

​To grant select on all views to  user, execute the query as follows

Query:

"select 'grant select on '||view_name||' to <user_name>;' from user_views"

 

To grant select on all tables to user, execute the query as follows

Query:

"select 'grant select on '||table_name||' to <user_name>;' from user_tables"


Getting detailed domain user info from the command line

Command:
start -> Run -> cmd    C:\>net user "username" /domain    For Eg: C:\> net user billyg /doamin    Results:    
The request will be processed at a domain controller for domain fakedomain.com.    User name                    billyg  Full Name                    Bill Gates  Comment  User's comment  Country code                 (null)  Account active               Yes  Account expires              Never    Password last set            12/1/2008 9:30 AM  Password expires             Never  Password changeable          9/25/2001 8:15 AM  Password required            Yes  User may change password     Yes    Workstations allowed         All  Logon script  User profile  Home directory  Last logon                   1/4/2009 2:04 PM    Logon hours allowed          All    Local Group Memberships      *Administrators  Global Group memberships     *Domain Admins        *Domain Users  The command completed successfully.

Grant Select privilege on all tables in schema to user in DB2

Query:

1) Generate grant statement to grant select privilege to user on all tables in schema

select concat(concat('grant select,update on xmeta.',tabname),' to user iersuser;') T from syscat.tables where owner='XMETA'

The above query generate grant statements

2) Run the Grant Statement to grant select and update access for all tables to user in schema

grant select,update on xmeta.REPORTING_PARAMETERVALUE to user iersuser

Procedure to add script in Ubuntu Run level

​To enable script in  ubuntu run level.

Terms:

  • /etc/init is where the upstart init configs live. While they are not scripts themselves, they essentially execute whatever is required to replace sysvinit scripts.

  • /etc/init.d is where all the traditional sysvinit scripts and the backward compatible scripts for upstart live. The backward compatible scripts basically run service myservice start instead of doing anything themselves. Some just show a notice to use the "service" command.

  • /etc/init/rc-sysinit.conf controls execution of traditional scripts added manually or with update-rc.d to traditional runlevels in /etc/rc*

  • /etc/default has configuration files allowing you to control the behaviour of both traditional sysvinit scripts and new upstart configs.

Using Services

Starting a Service

# Traditional:  /etc/init.d/myservice start  # Upstart  service myservice start

Stopping a Service

# Traditional:   /etc/init.d/myservice stop  # Upstart  service myservice stop

Getting a list of Services

# Traditional:  ls /etc/init.d  # Upstart:   service --status-all
  • Note: Upstart method will show both traditional and upstart services.

Adding a Service to Default runlevels

# Traditional  update-rc.d apache2 defaults    Upstart: there is no concept of runlevels, everything is event driven with dependencies. You would add an upstart config to /etc/init and potentially source a config file in /etc/default to allow users to override default behaviour. 

Removing a Service from Default runlevels

# Traditional - Something along the lines of  rm /etc/rc*/*myscript    Upstart: If no config is available in /etc/default, edit config in /etc/init

Sunday 18 December 2016

[Fix] Windows directory deleted without removing the share that points to the directory

SYMPTOMS

If you delete a directory before removing the share that points to the directory, the following message appears in the Event Viewer:

Event ID: 2511 Source: Server Type: Error
Description: The server service was unable to recreate the share <sharename> because the directory <drive>:\<directory> no longer exists.
RESOLUTION
  • Run Registry Editor (cmd->regedit).
  • From the View menu, select the Tree and Data option.
  • Navigate to the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares
  • Select the Share that no longer exists.
  • From the Edit menu, click Delete.
  • Quit Registry Editor.

Windows Net Command to Manage Network Share

​The NET Command is used to manage File Shares, Printer Shares and sessions as follows:

Display a local share:
NET SHARE sharename
———————————————————————————————————————————————————————
Display a list of computers in the current domain:
NET VIEW

———————————————————————————————————————————————————————

To see a list of shares on a remote computer:
NET VIEW \\ComputerName
———————————————————————————————————————————————————————
To see a list of all shares in the domain:
NET VIEW /DOMAIN
———————————————————————————————————————————————————————
To see a list of shares on a different domain:
NET VIEW /DOMAIN:domainname
———————————————————————————————————————————————————————
To see a list of shares on a remote Netware computer:
NET VIEW /NETWORK:NW [\\ComputerName]

———————————————————————————————————————————————————————
Create a new local file share:
NET SHARE sharename=drive:path /REMARK:"text" [/CACHE:Manual | Automatic | No ]

———————————————————————————————————————————————————————
Limit the number of users who can connect to a share:
NET SHARE sharename /USERS:number /REMARK:"text"

———————————————————————————————————————————————————————
Remove any limit on the number of users who can connect to a share:
NET SHARE sharename /UNLIMITED /REMARK:"text"
———————————————————————————————————————————————————————
Delete a share:
NET SHARE {sharename | devicename | drive:path} /DELETE

———————————————————————————————————————————————————————
Delete all shares that apply to a given device:
NET SHARE devicename /DELETE
In this case the devicename can be a printer (Lpt1) or a pathname (C:\Docs\)

============================================================================================
Join a file share (Drive MAP)
Using Command:NET USE

Display all the open shared files on a server and the lock-id:
NET FILE
———————————————————————————————————————————————————————
Close a shared file (disconnect other users and remove file locks):
NET FILE id /CLOSE
———————————————————————————————————————————————————————
List all sessions connected to this machine:
NET SESSION
———————————————————————————————————————————————————————
List sessions from a given machine:
NET SESSION \\ComputerName
———————————————————————————————————————————————————————
Disconnect all sessions connected to this machine:
NET SESSION /DELETE
———————————————————————————————————————————————————————
Disconnect all sessions connected to this machine (without any prompts):
NET SESSION /DELETE /y
———————————————————————————————————————————————————————
Disconnect sessions from a given machine:
NET SESSION \\ComputerName /DELETE

NET SESSION displays incoming connections only, in other words it must be run on the machine that is acting as the server.
———————————————————————————————————————————————————————

To create file shares, File and Printer sharing must be enabled on the (server) computer.


Oracle Password Complexity Verification

​The password complexity verification routine ensures that the password meets the following requirements:
  • Is at least four characters long
  • Differs from the user name
  • Has at least one alpha, one numeric, and one punctuation mark character
  • Is not simple or obvious, such as welcome, account, database, or user
  • Differs from the previous password by at least 3 characters
  • creating password with special character should enclosed in double quotation.
  • Special Characters Accepted by Oracle: [ ! # % * + – : ; > ? _ ( ) ~ ^ { } | [ ] \ . ]

Granting permission to users on different schema in Oracle

In Oracle,Granting privileges for objects to users in schema A to users of schema B,

1) User in Schema A should have DBA role or "WITH GRANT " privileges for providing access to user of schema B.

2) From System/Sys login,can't provide objects privileges to user of Schema A to B and vise versa.

"With Grant" option:

  • Only for object privileges, not system privileges.
  • Only the person who granted the privilege can revoke the privilege.
  • Revoked privileges can "cascade", allowing the first grantor to revoke many subsequent grants.

Mixed content blocking in Firefox

About mixed content:

HTTPS page you visit includes HTTP content, the HTTP portion can be read or modified by attackers, even though the main page is served over HTTPS. When an HTTPS page has HTTP content, we call that content "mixed". The page you are visiting is only partially encrypted and even though it appears to be secure, it isn't.

Steps to unblock mixed content :

1) For Temporary disable:

click on "Disable protection on this page", Firefox seems to remember the choice till the end of the session.

 

2) For  permanently disable:

Enter about:config into the Firefox address bar (confirm the info message in case it shows up) & search for the preference named security.mixed_content.block_active_content. Double-click it and change its value to false.

3) Other Fix:

You can add the toggle mixed content add-on from here https://addons.mozilla.org/en-us/firefox/addon/toggle-mixed-active-content/


Installing scripts into Ubuntu boot sequence (update-rc.d instead of Chkconfig)

Debian and Ubuntu use the service command to control services and update-rc.d for adding and removing services from start up. Using the service command we can start, stop, restart and display all available services. With update-rc.d we can add and remove services and add them to the Ubuntu/ Debian start up scripts. As Linux operating systems have multiple states, or runlevels, you need to make sure you add any new services to the correct runlevels. For example, you would not want to start a web service application before starting networking.

 

What services are available for startup?

Use the status-all switch to list all services which are registered with the OS and issues them a status command. You will then get one of the following displayed next to each service:

  • [ + ] – Services with this sign are currently running.
  • [ – ] – Services with this sign are not currently running..
  • [ ? ] – Services that do not have a status switch.
1
service statusall

Sample output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
service statusall
[ ? ] acpid
[ ] apparmor
[ ? ] apport
[ ? ] atd
[ ] bootlogd
[ ? ] consolesetup
[ ? ] cron
[ ? ] dbus
[ ? ] dmesg
[ ? ] dnsclean
[ ? ] friendlyrecovery
[ ? ] glusterfsserver
[ ] grubcommon
[ ? ] gssd
[ ? ] hostname
[ ? ] hwclock
[ ? ] hwclocksave
[ ? ] idmapd
[ ? ] irqbalance
[ ? ] killprocs
[ ? ] moduleinittools
[ ? ] networkinterface
[ ? ] networkinterfacecontainer
[ ? ] networkinterfacesecurity
[ ? ] networking
[ ? ] ondemand
[ ? ] passwd
[ ? ] plymouth
[ ? ] plymouthlog
[ ? ] plymouthready
[ ? ] plymouthsplash
[ ? ] plymouthstop
[ ? ] plymouthupstartbridge
[ ? ] portmap
[ ? ] portmapwait
[ ? ] pppddns
[ ? ] procps
[ ? ] rc.local
[ ? ] resolvconf
[ ? ] rpcbindboot
[ ] rsync
[ ? ] rsyslog
[ ? ] screencleanup
[ ? ] sendsigs
[ ? ] setvtrgb
[ + ] ssh
[ ? ] statd
[ ? ] statdmounting
[ ] stopbootlogd
[ ] stopbootlogdsingle
[ ? ] sudo
[ ? ] udev
[ ? ] udevfallbackgraphics
[ ? ] udevfinish
[ ? ] udevmonitor
[ ? ] udevtrigger
[ ? ] ufw
[ ? ] umountfs
[ ? ] umountnfs.sh
[ ? ] umountroot
[ ] unattendedupgrades
[ ] urandom
[ ? ] whoopsie

Start a service

Starting a service is done using the command service followed by the service name and the command to start the service.

1
service apache2 start

Stop a service

Use the stop keyword with service to stop a service.

1
service apache2 stop

Check the status of a service

Each service has a status, usually running or not running. Some services, such as network, may have a different output and output more information on the service.

1
service apache2 status

Remove a service

Use the remove keyword with update-rc.d to remove the service start up command for an application. You will need to use the -f switch if the applications /etc/init.d start up file exists.

1
updaterc.d f apache2 remove

 Add a service

Adding a service to Ubuntu or Debian is done with the update-rc.d command. You can specify which runlevels to start and stop the new service or accept the defaults. The init.d file will be added to the relevent rc.d startup folders.

1
 updaterc.d apache2 defaults

Setting Start and Kill priority

If you need more control over when your service is asked to start and stop, you may need to set the start and kill (S and K) values.

For a given runlevel, you may have several services starting. For example, you may have apache2 and mysql both starting on runlevel 3. Ideally, you'd want mysql to start before apache2 and shutdown after apache2. In this case we need to give mysql the priority in startup, but apache2 the priority in shutdown.

When starting, the lower the number, the earlier it will start. A start priority of 10 will start before a priority of 20. When killing, it's the opposite. A higher number will be killed before a lower number.

To set the start and kill priority we simply add them to the above update-rc.d command with the start priority first, followed by the kill priority.

1
updaterc.d apache2 defaults [START] [KILL]

The below command will start mysql first, then apache2. On shutdown, the kill will be the reverse of the start with apache2 being killed first and mysql second.

1
2
updaterc.d apache2 defaults 90 90
updaterc.d mysql defaults 10 10

Because, in our example, both start and kill priorities are the same we can shorted the command to just

1
2
updaterc.d apache2 defaults 90
updaterc.d mysql defaults 10

Manually set the RunLevel to Start and Kill a service

You can manually specify the Linux RunLevel that the system must be in to Start and Kill your service. See my other blog post for more information on RunLevels.

To extend the above example, we can specify exactly which RunLevel apache2 will be started and stopped.

1
updaterc.d apache2 start 10 2 3 4 5 . stop 90 0 1 6 .

apache2 will be started (as long as it isn't already) when the system enters RunLevel 234 or 5 with a priority of 10. It will then be asked to stop when the system enters RunLevel 01 or 6 with a priority of 90.


Create a New DB2 Database and Granting All privileges to User in Linux

Step 1: Login a db2inst1 user

Step 2: Issue the following command to create a New Database

#db2 CREATE DATABASE <Database_Name>

E.g. #db2 CREATE DATABASE TESTDB

Step 3: Create a new user in Linux as root

#useradd -m testuser

Step 4: Grant All the privileges to user by connecting to newly created DB

"GRANT CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT,SECADM ON DATABASE TO USER testuser;"


Synchronize the system clock to Network Time Protocol under Red Hat Linux

The Network Time Protocol daemon (ntpd) program is a Linux operating system daemon. It sets and maintains the system time in synchronism with time servers.

To do this, Configure ntpd via /etc/ntp.conf configuration file.

If ntpd is not installed use  the following command to install ntpd

# yum install ntp

OR

# up2date ntp

Configuration

Open /etc/ntp.conf file using vi text editor:

# vi /etc/ntp.conf

Locate server parameter and set it as follows:

server pool.ntp.org

Save the file and restart the ntpd service:

# /etc/init.d/ntpd start

You can also synchronize the system clock to an NTP server immediately with following command:

# ntpdate pool.ntp.org

Output:

29 Mar 14:07:21 ntpdate[12225]: step time server 125.62.193.121 offset -19767.752487 sec


Kernel Panic – not syncing :VFS: unable to mount root fs on unknown block (0,0)

While Linux/Ubuntu OS is Booting, You may get this error

Kernel Panic – not syncing :VFS: unable to mount root fs on unknown block (0,0)

This is Because initramfs for that Kernel is Missing.

Choose another kernel from the Grub menu,

  • Run update-initramfs -u -k (your version) or update-initramfs -u -k all 

This will generate the initrd for that version.

  • Run update-grub
  • Reboot the System

For more Information about initramfs,

visit http://www.linuxfromscratch.org/blfs/view/svn/postlfs/initramfs.html


Thursday 15 December 2016

resize2fs: Bad magic number in super-block or Couldn't find valid filesystem superblock.

Above error due to filesystem type is not EXT3/EXT4. Its belonging to xfs file type.

To see the info of your block device, use xfs_info.

$ xfs_info /dev/mapper/centos-root  meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1210880 blks           =                       sectsz=512   attr=2, projid32bit=1           =                       crc=0  data     =                       bsize=4096   blocks=4843520, imaxpct=25           =                       sunit=0      swidth=0 blks  naming   =version 2              bsize=4096   ascii-ci=0 ftype=0  log      =internal               bsize=4096   blocks=2560, version=2           =                       sectsz=512   sunit=0 blks, lazy-count=1  realtime =none                   extsz=4096   blocks=0, rtextents=0  

$  xfs_growfs /dev/mapper/centos-root  meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1210880 blks           =                       sectsz=512   attr=2, projid32bit=1           =                       crc=0  data     =                       bsize=4096   blocks=4843520, imaxpct=25           =                       sunit=0      swidth=0 blks  naming   =version 2              bsize=4096   ascii-ci=0 ftype=0  log      =internal               bsize=4096   blocks=2560, version=2           =                       sectsz=512   sunit=0 blks, lazy-count=1  realtime =none                   extsz=4096   blocks=0, rtextents=0


Using just xfs_growfs, the filesystem will be increased to its maximum available size. If you want to only increase for a couple of blocks, use the -D option.

Saturday 10 December 2016

Enable root login over SSH

​As root, edit the sshd_config file in /etc/ssh/sshd_config:
  1. vim /etc/ssh/sshd_config
  2. Add a line in the Authentication section of the file that says PermitRootLogin yes. This line may already exist and be commented out with a "#". In this case, remove the "#".
    # Authentication:  #LoginGraceTime 2m  PermitRootLogin yes  #StrictModes yes  #MaxAuthTries 6  #MaxSessions 10
  3. Save the updated /etc/ssh/sshd_config file.
  4. Restart the SSH server:
    service sshd restart

Wednesday 7 December 2016

How to change character set in mysql

​ALTER SCHEMA `dgc460`  DEFAULT CHARACTER SET utf8  DEFAULT COLLATE utf8_general_ci ;​

Monday 5 December 2016

Oracle 11gR2 - MEMORY_MAX_TARGET and MEMORY_TARGET

Adjusting the memory_max_target based on available memory. 
This example is Linux x86-64.

If you can afford to set the memory_max_target higher then the memory_target this will give you room to grow the memory_target without restarting the database. 

SQL> show parameters memory_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_target big integer 17920M

SQL> show parameters memory_max_target
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 17920M

System has 36GB physical RAM available.
SQL> !grep MemTotal /proc/meminfo
MemTotal: 36912956 kB

Server has now set aside 24GB for use with Oracle. Kernel shared memory parameter.
SQL>!df -h /dev/shm/
Filesystem Size Used Avail Use% Mounted on
tmpfs 24G 11G 14G 44% /dev/shm

Increase memory_max_target to 24GB.
SQL> ALTER SYSTEM SET memory_max_target = 24G SCOPE=SPFILE;
System altered.

Shutdown Oracle.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

Startup Oracle.
SQL> startup
ORACLE instance started.

Total System Global Area 2.5655E+10 bytes
Fixed Size 2213776 bytes
Variable Size 2.0133E+10 bytes
Database Buffers 5368709120 bytes
Redo Buffers 151166976 bytes
Database mounted.
Database opened.

Update your pfile.
SQL> create pfile from spfile;
File created.

Verify the new settings. Max now 24GB and memory target is 17.9GB. We can now increase the memory_target if the need arises without shutting the database down.

SQL> sho parameters memory_max_target

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_max_target big integer 24G
SQL> sho parameters memory_target

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
memory_target big integer 17920M

Sunday 4 December 2016

Ubuntu desktop join to Windows AD

Before we get started I need to point out a few things …

The following steps will be based on these specifications:



Install Ubuntu Desktop/Server

Update Ubuntu

sudo apt update
sudo apt dist-upgrade

NTP

  • ntp client which should point your nameserver to sync time.
sudo apt-get update  sudo apt-get dist-upgrade  sudo apt-get install ntp ntpdate

sudo vim /etc/ntp.conf

server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org # Use Ubuntu's ntp server as a fallback. server ntp.ubuntu.com
server 192.168.1.1 (your server IP)
 (or)
server 192.168.1.1 prefer iburst (High priority)

sudo service ntp start sudo service ntp stop sudo service ntp restart


Edit avahi config

If you don't do this you will get conflicts later when installing PBIS.

sudo nano /etc/avahi/avahi-daemon.conf

replace: #domain-name=local

with: domain-name=easygo

Install ssh:

sudo apt install ssh

Install PBIS:

  • Download install file >

LINK

(Download website: http://download1.beyondtrust.com/Technical-Support/Downloads/PowerBroker-Identity-Services-Open-Edition/?Pass=True)

  • Make install file executable >

sudo chmod +x Downloads/pbis-open-8.5.0.153.linux.x86_64.deb.sh

  • Execute install file

sudo ./Downloads/pbis-open-8.5.0.153.linux.x86_64.deb.sh

Install package for legacy links? -> no
Would you like to install now? -> yes

After install you might get a GUI tool asking you to join the domain. I prefer to close it and to continue via the terminal.

Restart avahi service

sudo service avahi-daemon restart

Join PC to domain

sudo domainjoin-cli join domain.local domain-administrator-username

So for our example it would be:

sudo domainjoin-cli join easygo administrator@easygo.com

You will be prompted for the Domain Administrator password and then should see "SUCCESS".

Restart ssh service

sudo service ssh restart

Set AD login settings

sudo /opt/pbis/bin/config UserDomainPrefix easygo
sudo /opt/pbis/bin/config AssumeDefaultDomain true
sudo /opt/pbis/bin/config LoginShellTemplate /bin/bash
sudo /opt/pbis/bin/config HomeDirTemplate %H/%U
# sudo /opt/pbis/bin/config RequireMembershipOf easygo\\DomainUsers (if need to add to any specific group which has admin rights)

DomainUsers = Domain Users Security Group

Edit lightdm (login screen settings)

sudo vim /usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf

  • Insert the following >

allow-guest=false
greeter-show-manual-login=true

… then Reboot

Thursday 1 December 2016

USB mouse not working properly on Ubuntu 16.04

power management switches off usb devices in order to save power after a certain period of inactivity.

Solution1:
$ sudo apt remove laptop-mode-tools  $ sudo reboot

Solution2:
 Recommend to install software called tlp.
$ sudo add-apt-repository ppa:linrunner/tlp    $ sudo apt-get update    $ sudo apt-get install tlp    $ sudo tlp start  

Wednesday 30 November 2016

“Login Failure: the target account name is incorrect” on a Windows file share

The solution was to Uninstall the 'Client for Microsoft Networks' from the network adapter, reboot, reinstall and reboot.

Problem will be fixed.

Shink log file in sql server 2008 r2

USE alphago;
GO  -- Truncate the log by changing the database recovery model to SIMPLE.  ALTER DATABASE AdventureWorks2008R2  
SET
RECOVERY SIMPLE; GO -- Shrink the truncated log file to 1 MB.
DBCC
SHRINKFILE (
alphago_Log, 1); GO -- Reset the database recovery model. ALTER DATABASE alphago SET RECOVERY FULL; GO

Tuesday 29 November 2016

Oracle database ​size in MB/GB query​ with creation date.

Query to find SID used & free space in it.

col "Database Size" format a20
col "Free space" format a20
col "Used space" format a20
select round(sum(used.bytes) / 1024 / 1024 / 1024,2 ) || ' GB' "Database Size"
, round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024,2) || ' GB' "Used space"
, round(free.p / 1024 / 1024 / 1024,2) || ' GB' "Free space"
from (select bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used
, (select sum(bytes) as p
from dba_free_space) free
group by free.p

Query to find database size in MB/GB with creation date.

select
  a.owner,b.created, ROUND(sum(bytes)/1024/1024,2) as size_in_MB, ROUND(sum(bytes)/1024/1024/1024,2) as size_in_GB
  from
  dba_segments  a inner join dba_users  b
  on a.owner=b.username
group by
 a.owner,b.created;





MYSQL database ​size in MB/GB query​ with creation date.

SELECT table_schema "Database Name", create_time, ROUND(SUM(data_length+index_length)/1024/1024, 0)
"Database Size (MB)",ROUND(SUM(data_length+index_length)/1024/1024/1024)
"Database Size (GB)"  FROM information_schema.TABLES GROUP BY table_schema;

MSQL database ​size in MB/GB query​ with creation date.

SELECT d.NAME, create_date,
    ROUND(SUM(mf.size) * 8 / 1024, 0) Size_MBs
    ,(SUM(mf.size) * 8 / 1024) / 1024 AS Size_GBs
FROM sys.master_files mf
INNER JOIN sys.databases d ON d.database_id = mf.database_id
WHERE d.database_id > 4 -- Skip system databases
GROUP BY d.NAME,create_date
ORDER BY d.NAME

kill/remove a process running on particular port in Linux

​Use the command
option 1:

 
netstat -tulpn | grep 1100

It will show the list of processes with port number and process id

tcp        0      0 0.0.0.0:1100                0.0.0.0:*                   LISTEN      22746/Rserve.dbg

the number before  /Rserve.dbg is a process id. Now use kill command to kill the process

kill -9 22746

-9 implies the process will be killed forcefully.

option 2:
lsof -i:1100;kill -9 22746

oneshot: kill -9 $(lsof -t -i:1100)


option 3:


# fuser 1100/tcp
#
fuser -k 1100/tcp (kill)


Wednesday 23 November 2016

How to check mysql dsn entry in Linux box

isql -v mydsn myusername mypassword

​[root@linuxmysql opt]# isql -v analyt_52 reuser resuer
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>    

Friday 18 November 2016

Creating a New DB2 Database Using a SQL Script

To create a new DB2 database using a SQL script

  1. Create a user for the new database. For example, to create a user named csuser on Linux:
    useradd -d /home/csuser -m -p welcome1 csuser  
  2. Log in with DB2 instance owner credentials. For example, db2inst1.
  3. Create a file with the following DB2 commands. (For example, create db.sql and modify the database name, path, and user variables to match your installation):
    CREATE DATABASE <DBNAME> AUTOMATIC STORAGE YES ON '<DB2_HOME>/Databases/<DBNAME>'   DBPATH ON '<DB2_HOME>/Databases/<DBNAME>'   USING CODESET UTF-8 TERRITORY US COLLATE USING SYSTEM PAGESIZE 32768;  CONNECT TO <DBNAME>;  GRANT DBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT,SECADM ON DATABASE TO USER <DBUSER>;  UPDATE DATABASE CONFIGURATION USING APPLHEAPSZ 1024 DEFERRED;  UPDATE DATABASE CONFIGURATION USING LOCKTIMEOUT 30 DEFERRED;  UPDATE DATABASE CONFIGURATION USING APP_CTL_HEAP_SZ 1024 DEFERRED;  UPDATE DATABASE CONFIGURATION USING LOGFILSIZ 32768 DEFERRED;  UPDATE DATABASE CONFIGURATION USING LOGSECOND 8 IMMEDIATE ;  CONNECT RESET;  
  4. Create the directory for your database.
    mkdir -p <DB2_HOME>/Databases/<DBNAME>  
  5. Execute the sql script. For example:
    db2 -tvsf createdb.sql  

Useful DB2 Commands

CommandDescription
db2cmdOpen DB2 Command line Tool
db2ccOpen DB2 Control Centre
db2startStart Database Normaly
db2stopStop Database Normaly
db2stop forceStop Database forcely
db2 force application allClose all applications that uses DB2 Database.
db2levelDisplay DB2 version and fix pack level
db6levelDisplay DB2 Client Version
db2 terminateClose the database connection
db2_kill -allKill a hanged instance
db2licm -lView license information
db2 connect to <db2sid>Establish connection to an instance
db2 list tablespaces show detailDisplays table space information
db2 get dbm cfgDisplay configuration parameter of database manager.
db2 get db cfg for <db2 sid>Display configuration parameter of an instance
db2 update dbm cfg using <parameter_name> <new value>Change value of a database manager configuration parameter.
db2 update db cfg for <db2 sid> using <parameter_name> <new value>Change value of a instance configuration parameter.
db2 drop database <target db2sid>Delete and instance
db2 activate db <dbsid>Activate Database
db2 deactivate <dbsid>Deactivate an active database
db2 rollforward db <SID> to end of logsApply all pending logs
db2 rollforward db <db2sid> query statusDisplay rollforward status
db2 backup database <sid> to "disk:\location"Take an offline backup to specified location
db2 list utilities show detailDisplay Database backup status
db2 restore db <sid> from "disk:\path" replace history fileRestore database from a backup image

DB2 license installation steps

To apply any of the DB2 Enterprise Server Edition, DB2 Advanced Enterprise Server Edition, DB2 Workgroup Server Edition, or DB2 Advanced Workgroup Server Edition licenses:

  1. Install the DB2 Version 10.5 – Workgroup, Enterprise, and Advanced Editions common image using the DB2 Setup wizard.
  2. Run the db2licm -a command, to apply the relevant licenses for either the DB2 Enterprise Server Edition, DB2 Advanced Enterprise Server Edition, DB2 Workgroup Server Edition, or DB2 Advanced Workgroup Server Edition.

    Windows

    db2install_path\bin\db2licm -a filename

    where db2install_path is the DB2 installation path, filename is the full path name and file name for the license certificate file that corresponds to the DB2 product edition you have purchased.

    Linux or UNIX

      INSTHOME/sqllib/adm/db2licm -a filename

    where INSTHOME represents the home directory of the instance owner and filename is the full path name and file name for the license certificate file that corresponds to the DB2 product edition you have purchased. The db2licm command can also be found in the path where the DB2 database product is installed. For example, /opt/IBM/db2/V10.5/adm on Linux or UNIX operating system, if you use the default installation directory.

  3. Start of changeIf you have purchased a DB2 add-on offering, run the db2licm -a command to activate the relevant functionalities for the DB2 offering. For example: if you purchased the IBM® DB2 BLU Acceleration In-Memory Offering:

    Windows

    db2install_path\bin\db2licm -a <license_path>/db2baf.lic

    where db2install_path is the DB2 installation path, <license_path> is the full path name for the license file, and db2baf.lic is the license certificate file of IBM DB2 BLU Acceleration In-Memory Offering.

    Linux or UNIX

      INSTHOME/sqllib/adm/db2licm -a <license_path>/db2baf.lic

    where INSTHOME represents the home directory of the instance owner and <license_path> is the full path name for the license file, and db2baf.lic is the license certificate file of IBM DB2 BLU Acceleration In-Memory Offering.End of change

  4. To verify the DB2 product license information, run the db2licm -l command.

that key can’t be used to activate this edition of windows

Method 1:

This may work for other later Operating Systems but it has been tested on 2012 R2.

I installed 2012 R2 on a brand new server as a trial and then later the license arrived, while trying to install the license, it was failed with error saying "that key is not valid for this version of Windows".

Firstly, check to make sure of what version you are using by running the following command

dism /online /get-currentedition

and check the possible target edition

dism /online /get-targeteditions

and if yours is supported then all you need is the new key and run the following command, be sure you are connected to the internet.

dism /online /set-edition:EDITION /product xxxxx-xxxxx-xxxxx-xxxxx-xxxxx /accepteula

if you don't put /accepteula it will not work.


SCREEN SHOTS:

Windows 2012 R2 - 2 days remaining

If you try and enter the new product key from the System Control Panel you'll receive an activation error like below.

Windows 2012 R2 activation failed

Open an Administrative Command Prompt. Then run the command:

slmgr.vbs /dlv

Administrative Command Prompt - slmgr -dlv

Slmgr.vbs /dlv is used for volume licensing, and this step is to gather information only. The /dlv switch displays detailed license information. As you can see below we are currently running the ServerStandardEval edition.

If you wanted to continue using the trial for another 180 days, your could use the /rearm switch.

Results of slmgr -dlv

From the Administrative Command Prompt, run the command:

dism /online /get-currentedition

This will confirm the information we obtained from slmgr.vbs /dlv, as you can see the current version is ServerStandardEval.

Administrative Command Prompt - dism online get-currentedition

Next, run the command:

dism /online /get-targeteditions

This will show you which versions the current evaluation license can be upgraded to, in our case it can be upgraded to ServerStandard or ServerDatacenter.

Administrative Command Prompt - dism get-targeteditions

Next run the command:

dism /online /set-edition:ServerStandard /ProductKey:xxxxx-xxxxx-xxxxx-xxxxx-xxxxx /AcceptEula

This command selects the version of Windows 2012 R2 you want to upgrade to, specifies the product key and Accepts the Eula.

Administrative Command Prompt - 9. dism online set-edition productkey accepteula

Once the process has completed it will prompt you to restart your computer.

Administrative Command Prompt - dism online set-edition productkey accepteula - completed

The process will reboot the server twice.

Reboot adding features

Cleaning up installation

Once completed and logged in you can see in the bottom right hand corner that the server is no longer running and evaluation version. Also on my test server I received an Shutdown Event Tracker.

Windows Server 2012 R2 Standard unexpected shutdown message