Linux Programmer | RHCE | RHCSA

Search This Blog

Tuesday 29 November 2016

Make your keyboard “special keys” (Alt+Gr, Up,Down,..) working when using XRDP

- xkbevd

$sudo apt-get install xbindkeys

$xbindkeys --defaults > /home/username/.xbindkeysrc

now "xbindkeys -k" command for choosing key press combination
$xbindkeys -k

( press the key combination for e.g. Ctrl+Alt+Space)

- copy the key combination
m:0x14 + c:28

paste into  /home/username/.xbindkeysrc

"/usr/bin/script.sh"  (path of the script you want to run on some key combination)
m:0x14 + c:28

run below command for starting xbind key start
$xbindkeys

to make it permenant add this command into .Xsession of into users home file

Wednesday 16 November 2016

use of dd command

dd if=/dev/sr0 of=myCD.iso bs=2048 
conv=noerror,sync
Creates an ISO disk image from a CD-ROM; in some cases the created ISO image may not be the same as the one that was used to burn the CD-ROM.
dd if=system.img of=/dev/sdc bs=4096  
conv=noerror
Restores a hard disk drive (or an SD card, for example) from a previously created image.
dd if=/dev/sda2 of=/dev/sdb2 bs=4096  
conv=noerror
Clones one partition to another.
dd if=/dev/ad0 of=/dev/ad1 bs=1M  
conv=noerror
Clones a hard disk drive "ad0" to "ad1".

Monday 14 November 2016

bash: file not Found error

bash: file not found error occured even file is exists 

solution:

32-bit executable file is not execute in linux 64-bit systems

so you have to install i386 32-bit architecture 

try this :

1. open terminal  ( ctrl + alt+ T)

2. sudo dpkg --add-architecture i386

 sudo apt-get update

 sudo apt-get install libc6:i386

 sudo apt-get install libncurses5:i386
 
 sudo apt-get install libstdc++6:i386



Saturday 12 November 2016

Fix Broken initrd.img in linux

error : file /boot/initrd.img-3.10.12-generic' not found

if error found during booting system
follow the steps below

1.Boot your machine with a Live Media

2. open terminal and get partition 

fdisk -l

3. mount Filesystem
sudo mount /dev/sda1 /mnt
 
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys

4.Chroot /mnt and creating a Backup of the initrd image

sudo chroot /mnt

ls /boot/initrd*

or ls /lib/modules

mv /boot/initrd.img-3.11.0.12-generic /boot/old-initrd.img-3.11.0.12-generic-old

5. Building initrd.img

mkinitrd /boot/initrd.img-3.11.0.12-generic 3.11.0.12-generic-old

update-initramfs -c -k 3.11.0.12-generic

 

6. Finalizing Grub loader and unmounting

grub2-mkconfig -o /boot/grub2/grub.cfg

update-grub

 sudo unmount /mnt/proc

sudo unmount /mnt/sys

sudo unmount /mnt/dev

sudo unmount /mnt

init 6

Friday 11 November 2016

java applications are not working in Firefox linux ?

if applications based on java is not working in firefox 

follow steps below (only for linux 32 bit systems)

1. Download bin file from the link below:

https://drive.google.com/open?id=0BwPBGrPmbppATjVtVUNYOEN4Mnc

2. chmod 0777 jdk-6u45-linux-i586.bin

3. ./jdk-6u45-linux-i586.bin

4. mv jdk1.6.0_45 /opt/

5. cd /usr/lib/firefox-addons/plugins

6. ln -s /opt/jdk1.6.0_45/jre/lib/i386/libnpjp2.so .

7. close firefox and restart firefox

to checkj add on is added or not

open firefox -> options -> add-ons -> Plugins
check javaTM(plugin is installed or not ? upgrade it if you want to upgrade )

if you are not able to make This plugin Always activate then Follow the steps below

How to set old versions of plugins to 'Always Activate'?

 
1. open firefox
2. open about:config (have to enter 2-3 times to open it)
3.this will list configurations of firefox
4. Look for 'extensions.blocklist.enabled' and set it to false
5. This will remove the 'is known to be vulnerable message and enable the previously greyed out 'ask to activate' & 'Always active' options.

You can then set the plug in to always enable by setting the relevant value for 'plugin.state.<plugin_name>:

0 - Never Active
1 - Ask to Active
2 - Always Active

I saw 'plugin.state.java' & 'plugin.state.ndeployjava' when looking during my testing.

Tuesday 8 November 2016

Add/Remove Main Menu From List in Lubuntu

Script :

File For menu is Located At: /etc/xdg/lubuntu/menus/lxde-applications.menu
(Chnange The Path of menu file in script)

menu="$1"

check=`grep -i "<Name>$menu<\/Name>" /tmp/lxde-applications.menu`
if [ -n "$check" ];
then
line0=`cat /tmp/lxde-applications.menu | grep -n "<Name>$menu<\/Name>" | cut -d$
line1=$((line0-1))
line2=`cat /tmp/lxde-applications.menu | grep -B 1 -A 25 -n "<Name>$menu<\/Name$
bline=$((line2+1))
sed -n "${line1},${line2}p" /tmp/lxde-applications.menu  >/tmp/"$menu"
app="<!--$menu-->"
sed -i ''$line1'i\'$app'\' /tmp/lxde-applications.menu

echo "$line1==>$line0==>$bline"
sed -i ''$line0','$bline'd' /tmp/lxde-applications.menu

else
        echo "Menu Not Exists"
fi

To Run Script:
./script_name.sh {menu-name}

To Add Deleted Menu :
sudo sed -i '/<!---DesktopSettings--->/r /tmp/DesktopSettings' lxde-applications.menu

sudo sed -i '/<!--DesktopSettings-->/d' /tmp/lxde-applications.menu

Friday 4 November 2016

Add Password Policy in LDAP

Step-1 : Enable ppolicy overlay
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/ppolicy.ldif

Step-2 Create file ppmodule.ldif load the pp module
dn: cn=module{0},cn=config
changetype: modify
add: olcModuleLoad
olcModuleLoad: ppolicy

Step-3 load the module ppmodule.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f ppmodule.ldif

Step-4 Prepare for Overlay Create file ppolicyoverlay.ldif
dn: olcOverlay={0}ppolicy,olcDatabase={1}hdb,cn=config
objectClass: olcOverlayConfig
objectClass: olcPPolicyConfig
olcOverlay: {0}ppolicy


Step-5 Add ppolicyoverlay.ldif using ldapadd commandb  
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f ppolicyoverlay.ldif

Note : this 5 steps are done only once before applying password policy, no need to repeat this everytime while creating password policy


Step-8 Create passwordpolicy.ldif for MyOrganization
dn: cn=MyOrgPPolicy,ou=Policies,dc=ldap,dc=com
cn: MyOrgPPolicy
objectClass: pwdPolicy
objectClass: device
objectClass: top
pwdAttribute: userPassword
pwdMaxAge: 3024000
pwdExpireWarning: 1814400
pwdInHistory: 4
pwdCheckQuality: 1
pwdMinLength: 9
pwdMaxFailure: 4
pwdLockout: TRUE
pwdLockoutDuration: 600
pwdGraceAuthNLimit: 0
pwdFailureCountInterval: 0
pwdMustChange: TRUE
pwdAllowUserChange: TRUE
pwdSafeModify: FALSE

Step-9 Add passwordpolicy.ldif in LDAP
ldapadd -D cn=admin,dc=ldap,dc=com -w password -f passwordpolicy.ldif


[ Your Policy named Default Policy is Applied , Remember You have To create OU named Policies defore adding this policy ]

-----------------------Apply policy to Users ---------------------

dn: cn=purval,ou=Users,dc=ldap,dc=com changetype: modify add: pwdPolicySubentry pwdPolicySubentry: cn=MyorgPolicy,ou=Policies,dc=ldap,dc=com

---------------------- Remove Policy from User ----------------------------

dn: uid=purval,ou=People,dc=ldap,dc=com changetype: modify delete: pwdPolicySubentry







Configure LDAP Server

Create Ldap Server in Tiguin14.04:

1.Change Host name
  • nano /etc/hostname
server.ldap.com
2. Reboot system
  • Init 6
3. apt-get install slapd ldap-utils
  • Enter administrator password:

4. nano /etc/ldap/ldap.conf
  • Remove hash brefore BASE ans URI line ,and add foillowing
BASE dc=ldap,dc=com
URI ldap://localhost:389

5. dpkg-reconfigure slapd
You will be asked a series of questions about how you'd like to configure the software.
  • Omit OpenLDAP server configuration? No
  • DNS domain name?
    • ldap.com
  • Organization name?
    • ldap.com
  • Administrator password?
    • 123
    • 123
  • Database backend to use? HDB
  • Remove the database when slapd is purged? No
  • Move old database? Yes
  • Allow LDAPv2 protocol? No
6. ldapsearch -x

7. apt-get install phpldapadmin

8. nano /etc/phpldapadmin/config.php

  • line  no. 286 “My Ldap server”     you can add anything here
  • Line no 293      Enter ip address of your machine e.g. 192.168.1.226
  • Line no. 300             dc=ldap,dc=com
  • Line no. 326            dc=ldap
  • Line no. 161 true

9. /etc/init.d/apache2 restart

10. Open browser
-login with password which is given during ldap installation
Click on login -> type password -> login

Click on
dc=ldap,dc-com(1) -> create new entry here -> create organizational unit -> e.g sales -> commit

Click on
ou=sales -> create child entry -> Generic : Posix Group -> e.g. sales-group -> commit

Click on
ou=sales-group -> create child entry -> Generic: User Account ->
Fill the following Text boxes
Common name , GID number, Home Directory, login shell, last name, password
-> ok -> commit

[ NOTE : We can change the path of users home Directory on Client system by just defining it into the Home Directory text Box.]






================= LDAP Commands ======================
- list all the users under some group 

ldapsearch -x -b $dn -s sub "objectclass=posixGroup" | sed -n '/cn: $grp_name/,/dn:/p' | grep "^memberUid:" | awk '{print$2}' 

- List all created Users in LDAP
ldapsearch -x -b dc=ldap,dc=com -s sub "objectclass=posixAccount" | grep -i "^uid: " | awk '{print$2}' 


Modify LDAP group name usig LDIF file : /tmp/.modify.ldif
dn: cn=php,ou=Groups,dc=ldap,dc=com
changetype: modrdn
newrdn: cn=purval
deleteoldrdn: 1


ldapmodify -x -D "cn=admin,dc=ldap,dc=com" -w 123 -f /tmp/.modify

- Search All Users Password history

ldapsearch -LLL -x -h localhost -Z -D cn=admin,dc=ldap,dc=com "(&(objectclass=Person))" pwdHistory -w {password}

dn: cn=purval,ou=Users,dc=ldap,dc=com
pwdHistory: 20170131064459Z#1.3.6.1.4.1.1466.115.121.1.40#6#123456
pwdHistory: 20170131093602Z#1.3.6.1.4.1.1466.115.121.1.40#6#123456
pwdHistory: 20170201053907Z#1.3.6.1.4.1.1466.115.121.1.40#6#123456
pwdHistory: 20170204074307Z#1.3.6.1.4.1.1466.115.121.1.40#6#123456

dn: cn=bhavesh,ou=Users,dc=ldap,dc=com

dn: cn=mehul,ou=Users,dc=ldap,dc=com

dn: cn=lokesh,ou=Users,dc=ldap,dc=com

dn: cn=khushbu,ou=Users,dc=ldap,dc=com

 

- if Print All the password History of purval user then,


ldapsearch -LLL -x -h localhost -Z -D cn=admin,dc=ldap,dc=com "(&(objectclass=Person))" pwdHistory -w 123 | sed -n '/cn=purval/,/dn:/p' 

- Print all Users Password change time
ldapsearch -LLL -x -h localhost -Z -D cn=admin,dc=ldap,dc=com "(&(objectclass=Person))" modifyTimestamp -w {password}  

========Convert LDAP timezone to UTC to IST ==============

- default LDAP server timezone is Asia/Zulu
time is displayed in UTC standard format e.g. 20170206055543Z

- To covert this time format in normal time

echo "20170402125623" | sed -re 's/^([0-9]{8})([0-9]{2})([0-9]{2})([0-9]{2})$/\1\\ \2:\3:\4/' | xargs date -u -d   >/tmp/.date
output is: Mon Feb 6 11:25:43 UTC 2017 

 dateis=`cat /tmp/.date`
(This date format is UTC format, convert it to IST) 

eval "date --date='TZ=\"Asia/Zulu\" $dateis'"
output :Mon Feb 6 11:25:43 IST 2017


 

SSH not working with password after upgrade ubuntu 22.04

Issue: In recent upgrade of ubuntu 22.04 we are not able to login server with SSH password. but when we try to login with key then it allow...