Change unix password with Python

Posted by cikul | Posted in Python | Posted on 02-05-2016-05-2008

2

Do you ever have problem while execute /usr/bin/passwd from your python code? actually i have problem with changing unix password from my python code.

First i try using pipe to control output from /usr/bin/passwd, hopefully i can send text with write() function.
this is the code :

#!/usr/bin/python
import os
COMMAND = 'passwd'
PASSWD  = 'mypassword'

# open a pipe to passwd program and
# write the data to the pipe
p = os.popen("%s" % COMMAND, 'w')
p.write(PASSWD)
p.write('n')
p.write(PASSWD)
p.close()

But i failed to change the password.

The solution is use Pexpect
Read the rest of this entry »

Share and Enjoy

Fix CentOS Install Problem using USB

Posted by cikul | Posted in Linux | Posted on 01-05-2016-05-2008

0

When installing CentOS using USB stick, i experienced problem with repository install after partition

Unable to read package metadata. This may be due to missing repodata directory. Please ensure that your install tree has been correctly generated. 
Failure: repodata/743fec56b2af0ce8d6ec82c47a4efafc2a4d18cddfa9683f29611cb18d1a33de-primary.sqlite.bz2 from anaconda-CentOS-201311271240.i386: [Ermo 256] No more mirrors to try.

After Searching about the problem, i’ve found because installer cannot found the file which described in repomd file located in /repodata folder

To fix the problem, go to /repodata folder on your usb stick, and change the file under repodata matched to the parameter configured in repomd file, for example :

in repomd location :

location href=”repodata/b124f0ec5323cfee56b420906a3103f0daef656dde3f7ac8220120aa7504e57a-primary.xml.gz”

so you must find the file under /repodata folder which matched with the configuration, and change the extension in accordance with the parameter configured in repomd file.

 

Share and Enjoy

[Script] Auto Backup Mysql

Posted by cikul | Posted in Linux, SQL | Posted on 01-05-2016-05-2008

0

Now we will create script to backup mysql databases, this script will automatically list all databases and backup it to a folder defined in backup_parent_dir


#!/bin/bash
# Simple script to backup MySQL databases

# Parent backup directory
backup_parent_dir="/backup/mysql"

# MySQL settings
mysql_user="root"
mysql_password="xxxxxxxx"

# Read MySQL password from stdin if empty
if [ -z "${mysql_password}" ]; then
echo -n "Enter MySQL ${mysql_user} password: "
read -s mysql_password
echo
fi

# Check MySQL password
echo exit | mysql --user=${mysql_user} --password=${mysql_password} -B 2>/dev/null
if [ "$?" -gt 0 ]; then
echo "MySQL ${mysql_user} password incorrect"
exit 1
else
echo "MySQL ${mysql_user} password correct."
fi

# Create backup directory and set permissions
backup_date=`date +%Y_%m_%d_%H_%M`
backup_dir="${backup_parent_dir}/${backup_date}"
echo "Backup directory: ${backup_dir}"
mkdir -p "${backup_dir}"
chmod 700 "${backup_dir}"

# Get MySQL databases
mysql_databases=`echo 'show databases' | mysql --user=${mysql_user} --password=${mysql_password} -B | sed /^Database$/d`

# Backup and compress each database
for database in $mysql_databases
do
if [ "${database}" == "information_schema" ] || [ "${database}" == "performance_schema" ]; then
additional_mysqldump_params="--skip-lock-tables"
else
additional_mysqldump_params=""
fi
echo "Creating backup of \"${database}\" database"
mysqldump ${additional_mysqldump_params} --user=${mysql_user} --password=${mysql_password} ${database} | gzip > "${backup_dir}/${database}.gz"
chmod 600 "${backup_dir}/${database}.gz"
done

Share and Enjoy

Change & Reset Mysql Password

Posted by cikul | Posted in Linux, SQL, Tips | Posted on 18-10-2015-05-2008

0

This tutorial explains how to change or reset your MySQL root password under Unix-Like Operating Systems (Linux, FreeBSD, OpenBSD, etc) over SSH. MySQL root account should be managed carefully.

As a system administrator, we must ensure that the password is safe and prevent from unauthorized access.

There are some method to change mysql password :

Type 1 : use mysqladmin

However, if you want to change mysql root/user password, mysql had tool to simplify the process using mysqladmin command, the syntax is :


$ mysqladmin -u root -p'oldpassword' password newpass
$ mysqladmin -u dbuser -p'oldpassword' password 'itsnewpassword';

Read the rest of this entry »

Share and Enjoy

[CentOS] Merubah Gambar Background GRUB saat booting

Posted by cikul | Posted in Linux | Posted on 01-03-2015-05-2008

0

Gambar pada tampilan awal GRUB biasanya mengikuti distro linux yang kita gunakan, seperti contoh untuk CentOS maka Tampilan awal GRUB akan menampilkan gambar background dari CentOS seperti gambar berikut

grubCentOS

Tampilan Splash Screen GRUB

sekarang bagaimana cara kita mengganti background image default tersebut?

Read the rest of this entry »

Share and Enjoy

Completely Uninstall Kloxo-MR

Posted by cikul | Posted in cpanel, Free Stuff, Internet, Linux | Posted on 13-11-2014-05-2008

2

Based on my experience, it’s easy to find tutorial how to install Kloxo-MR, but hard to find tutorial how to uninstall Kloxo-MR, lack of documentation for Kloxo-MR make the installation of Kloxomr difficult for some system administrators.

If you had problem during kloxo-mr installation, the easy way to troubleshoot is recreate your VPS container, but if you won’t do that, you can reinstalling kloxo-mr from scratch, but make sure the system has clean from previous install to avoid problem.

Read the rest of this entry »

Share and Enjoy

Get Windows Version from ISO files

Posted by cikul | Posted in Windows | Posted on 10-09-2014-05-2008

1

You want to install windows 7 pro 64 bit, and you had downloaded the ISO source from internet, but before install you’re not sure your ISO master is correct with your requirement (32 bit or maybe download Home edition).

Basically, any windows installation has WIM files within, Install.wim contains several sysprepped images of your Windows installation, and we can extract the information from install.wim to get the version of your installation.

Read the rest of this entry »

Share and Enjoy

[excel] Unprotect Excel Sheets without password

Posted by cikul | Posted in Windows | Posted on 02-09-2014-05-2008

0

Unprotect excel sheets can be done with VBA Macro.

To open VBA macro press ALT + F11, after Microsoft Visual Basic Open, press F5 to create new macro,

Insert this code :

Sub RemovePassword()
    Dim i As Integer, j As Integer, k As Integer
    Dim l As Integer, m As Integer, n As Integer
    Dim i1 As Integer, i2 As Integer, i3 As Integer
    Dim i4 As Integer, i5 As Integer, i6 As Integer
    On Error Resume Next
    For i = 65 To 66: For j = 65 To 66: For k = 65 To 66
    For l = 65 To 66: For m = 65 To 66: For i1 = 65 To 66
    For i2 = 65 To 66: For i3 = 65 To 66: For i4 = 65 To 66
    For i5 = 65 To 66: For i6 = 65 To 66: For n = 32 To 126
    ActiveSheet.Unprotect Chr(i) & Chr(j) & Chr(k) & _
        Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & Chr(i3) & _
        Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
    If ActiveSheet.ProtectContents = False Then
        MsgBox "You can use the password to unprotect : " & Chr(i) & Chr(j) & _
            Chr(k) & Chr(l) & Chr(m) & Chr(i1) & Chr(i2) & _
            Chr(i3) & Chr(i4) & Chr(i5) & Chr(i6) & Chr(n)
         Exit Sub
    End If
    Next: Next: Next: Next: Next: Next
    Next: Next: Next: Next: Next: Next
End Sub

To execute the macro press F5

The script will return output :

“You can use the password to unprotect : XFSTGAJHG”

The password provided can use to open sheets in same workbook which still protected.

Share and Enjoy

[Excel] Unhide Multiple Worksheet

Posted by cikul | Posted in Windows | Posted on 02-09-2014-05-2008

0

Excel allows us to hide multiple worksheet in one action, but not for unhide, we must unhide the sheets seperately, and it takes more time to do if we have many sheets that need to open.

The way to unhide all worksheets, we can use macro to do this job, this VBA macro will help you to unhide all worksheets in your excel documents.

To open VBA macro press ALT + F11, after Microsoft Visual Basic Open, press F5 to create new macro,

Sub UnhideSheets()
    Dim workSheet As Worksheet

    For Each workSheet In ActiveWorkbook.Worksheets
        workSheet.Visible = xlSheetVisible
    Next workSheet
End Sub

To execute the macro, press F5

Share and Enjoy

Selamat Ulang Tahun ke-2 Putri Kecilku

Posted by cikul | Posted in Keluarga, Life | Posted on 01-09-2014-05-2008

0

Alhamdulillah.. 1 September 2014, sudah genap 2 tahun Nareswari Tsuraya Mahardhika melengkapi kebahagiaan ayah dan ibumu.. Tumbuh semakin besar, semakin pintar dan tentunya menggemaskan.. :)

IMG_20140901_094148

Masih ingat 2 tahun yang lalu, engkau lahir dari rahim ibumu dengan tangisan yang sangat keras, seakan engkau ingin memberitahukan ke semua orang bahwa kau telah lahir di dunia dan merasa bangga bisa lahir dari rahim seorang ibu yang hebat, ibu yang rela mengorbankan jiwa, raga dan selalu memberikan kasih sayangnya.

20140629_130411

Dan masih teringat bagaimana senangnya kakak laki-laki-mu ketika tahu bahwa dia mendapatkan adik yang sehat dan lucu, begitu bangganya dia bakal memegang tanggung jawab untuk bisa menjaga adik perempuan tersayang-nya.

Terima Kasih Allah, engkau telah melengkapi kebahagiaan keluarga kami, berikanlah kami selalu rahmat, kesehatan dan petunjuk agar kami bisa membimbing anak-anak kami menjadi anak yang sholeh dan sholehah, dan bisa membawa keluarga kami menjadi keluarga yang sakinah, mawaddah, warahmah.

 

Share and Enjoy