Search Windows and Linux Networking

Friday, December 20, 2013

Step by Step : How to backup data using tar



Backup your data using tar

To backup or restore your data using tar always start backup/ restore from root (/) directory. To go to root (/) type the command

cd /

if you don't start backup from root (/) directory  then it will not restore data its original location. because when creating archive with tar. tar alway remove leading "/" from the member and that may be problem when restoring data at original location.

See the following example. I have started backup from home directory not from root (/) directory.

root@sandeepk:~# tar -cvpf /backup/exampleone.tar /home/sandeep/test
tar: Removing leading `/' from member names
/home/sandeep/test/
/home/sandeep/test/test3
/home/sandeep/test/test7
/home/sandeep/test/test2
/home/sandeep/test/test8
/home/sandeep/test/testmd/
/home/sandeep/test/testmd/test3
/home/sandeep/test/testmd/test7
/home/sandeep/test/testmd/test2
/home/sandeep/test/testmd/test8
/home/sandeep/test/testmd/test5
/home/sandeep/test/testmd/test6
/home/sandeep/test/testmd/test4
/home/sandeep/test/testmd/test9
/home/sandeep/test/testmd/test1
/home/sandeep/test/test5
/home/sandeep/test/test6
/home/sandeep/test/test4
/home/sandeep/test/test9
/home/sandeep/test/test1


Now test the data using following command

 root@sandeepk:~# tar -dvf /backup/exampleone.tar
home/sandeep/test/
tar: home/sandeep/test: Warning: Cannot stat: No such file or directory
home/sandeep/test/test3
tar: home/sandeep/test/test3: Warning: Cannot stat: No such file or directory


It will be give warning massage that No such file or directory. tar is checking data home/sandeep/test/ and not from /home/saneep/test

To resole the issue you should always start your backup from root directory (/)
 and now i will take another backup same data but from root directory

root@sandeepk:~# cd /
root@sandeepk:/#

root@sandeepk:/# tar -cvpf /backup/exampletwo.tar home/sandeep/test
home/sandeep/test/
home/sandeep/test/test3
home/sandeep/test/test7
home/sandeep/test/test2
home/sandeep/test/test8
home/sandeep/test/testmd/
home/sandeep/test/testmd/test3
home/sandeep/test/testmd/test7
home/sandeep/test/testmd/test2
home/sandeep/test/testmd/test8
home/sandeep/test/testmd/test5
home/sandeep/test/testmd/test6
home/sandeep/test/testmd/test4
home/sandeep/test/testmd/test9
home/sandeep/test/testmd/test1
home/sandeep/test/test5
home/sandeep/test/test6
home/sandeep/test/test4
home/sandeep/test/test9
home/sandeep/test/test1


Now verify data using following command

root@sandeepk:/# tar -dvf /backup/exampletwo.tar
home/sandeep/test/
home/sandeep/test/test3
home/sandeep/test/test7
home/sandeep/test/test2
home/sandeep/test/test8
home/sandeep/test/testmd/
home/sandeep/test/testmd/test3
home/sandeep/test/testmd/test7
home/sandeep/test/testmd/test2
home/sandeep/test/testmd/test8
home/sandeep/test/testmd/test5
home/sandeep/test/testmd/test6
home/sandeep/test/testmd/test4
home/sandeep/test/testmd/test9
home/sandeep/test/testmd/test1
home/sandeep/test/test5
home/sandeep/test/test6
home/sandeep/test/test4
home/sandeep/test/test9
home/sandeep/test/test1



Now delete the data from your system and try to restore it

root@sandeepk:/# rm -rf /home/sandeep/test
root@sandeepk:/# ls -l /home/sandeep/test
ls: cannot access /home/sandeep/test: No such file or directory
root@sandeepk:/# cd
root@sandeepk:~# tar -xvpf /backup/exampleone.tar
home/sandeep/test/
home/sandeep/test/test3
home/sandeep/test/test7
home/sandeep/test/test2
home/sandeep/test/test8
home/sandeep/test/testmd/
home/sandeep/test/testmd/test3
home/sandeep/test/testmd/test7
home/sandeep/test/testmd/test2
home/sandeep/test/testmd/test8
home/sandeep/test/testmd/test5
home/sandeep/test/testmd/test6
home/sandeep/test/testmd/test4
home/sandeep/test/testmd/test9
home/sandeep/test/testmd/test1
home/sandeep/test/test5
home/sandeep/test/test6
home/sandeep/test/test4
home/sandeep/test/test9
home/sandeep/test/test1


Now check if your data restored its original location or not  by using ls command.


root@sandeepk:~# ls -l /home/sandeep/test
ls: cannot access /home/sandeep/test: No such file or directory
root@sandeepk:~#


It not restore at it's original location if you run ls command you will see new home directory created and restore all data in that directory.

root@sandeepk:~# ls -l
total 12824
-rw-r--r-- 1 root root 13127680 Dec 18 15:07 archive
drwxr-xr-x 3 root root     4096 Dec 20 12:19 home



now extract from root (/) directory.


root@sandeepk:~# cd /
root@sandeepk:/# tar -xvpf /backup/exampletwo.tar
home/sandeep/test/
home/sandeep/test/test3
home/sandeep/test/test7
home/sandeep/test/test2
home/sandeep/test/test8
home/sandeep/test/testmd/
home/sandeep/test/testmd/test3
home/sandeep/test/testmd/test7
home/sandeep/test/testmd/test2
home/sandeep/test/testmd/test8
home/sandeep/test/testmd/test5
home/sandeep/test/testmd/test6
home/sandeep/test/testmd/test4
home/sandeep/test/testmd/test9
home/sandeep/test/testmd/test1
home/sandeep/test/test5
home/sandeep/test/test6
home/sandeep/test/test4
home/sandeep/test/test9
home/sandeep/test/test1

root@sandeepk:/#


root@sandeepk:/# ls -l /home/sandeep/test
total 4
-rw-r--r-- 1 root root    0 Dec 20 10:29 test1
-rw-r--r-- 1 root root    0 Dec 20 10:29 test2
-rw-r--r-- 1 root root    0 Dec 20 10:29 test3
-rw-r--r-- 1 root root    0 Dec 20 10:29 test4
-rw-r--r-- 1 root root    0 Dec 20 10:29 test5
-rw-r--r-- 1 root root    0 Dec 20 10:29 test6
-rw-r--r-- 1 root root    0 Dec 20 10:29 test7
-rw-r--r-- 1 root root    0 Dec 20 10:29 test8
-rw-r--r-- 1 root root    0 Dec 20 10:29 test9
drwxr-xr-x 2 root root 4096 Dec 20 10:30 testmd







Friday, November 15, 2013

How to Search All Disabled User In Active Directory.

How to Search all Disabled User In Active Directory and export in to the Excel File using VBScript.


OR

 How to Search all Active/Enabled User In Active Directory and export in to the Excel File using VBScript


There are some time when you needed or your manager ask to provide all Disabled user Or currently all Active User from Active Directory in excel file and there are more than 100 Accounts in your Active Directory and you have to give all information in limited time frame. then best option is to use VbScript that search all disabled or All Active/Enabled users in Active Directory.

Following is the VBScript that Search for all Disabled Users in entire domain.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 Option Explicit
Dim objRootDSE,strDNSDomain,adoConnection,strQuery,adoRecordset,Field
Dim CN,FirstName,LastName,initials,Descrip,EmailAddr
Dim strFileName, ObjExcel, intRow

'Search all Disabled users in Active Directory and export them in to Excel file.


wscript.echo "Searching all disabled users in Active Directory please wait...."

'Open Excel file to Write the Data

Set ObjExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.WorkBooks.Add()
intRow = 1
       ObjExcel.Cells(intRow,1).Value = "CN"
       ObjExcel.Cells(intRow,2).Value = "FirstName"
       ObjExcel.Cells(intRow,3).Value = "initials"
       ObjExcel.Cells(intRow,4).Value = "LastName"
       ObjExcel.Cells(intRow,5).Value = "EmailAddr "

' Bind to Domain or OU

Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "ADs Provider"
strQuery = "<LDAP://" & strDNSDomain & ">;(&(objectCategory=person)(objectClass=user));adspath;subtree"

'Define condition for search
Set adoRecordset = adoConnection.Execute(strQuery)

' Loop to search users through them...


Do While Not adoRecordset.EOF
     Set Field = GetObject(adoRecordset.Fields(0).Value)
     If Field.accountDisabled = TRUE Then
       'wscript.echo "Account " & Field.displayname & " is disabled"
       intRow = intRow + 1
       Cn = Field.CN
       FirstName = Field.GivenName
       LastName = Field.sn
       initials = Field.initials
       Descrip = Field.description
       EmailAddr = Field.mail

       'Wscript.echo "Users full Name is " & FirstName & " " & initials & " " & LastName & " and his Email ID is " & EmailAddr

       ' Write to Excel File
       ObjExcel.Cells(intRow,1).Value = CN
       ObjExcel.Cells(intRow,2).Value = FirstName
       ObjExcel.Cells(intRow,3).Value = initials
       ObjExcel.Cells(intRow,4).Value = LastName
       ObjExcel.Cells(intRow,5).Value = EmailAddr
     
      End If
 
adoRecordset.MoveNext

Loop
'If completed notify as it done.
wscript.echo "Done"

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++





You can also use this script to search all Active/Enabled user in entire domain by just modifying condition Field.accountDisabled = TRUE with Field.accountDisabled = FALSE

OR

You can also use this script to find all Active/Disalbed users by just modifying Bind base string (strQuery ) using Organization Unit. For example

strQuery = "<LDAP://OU=DisabledAccounts,DC=Example,DC=com>;(&(objectCategory=person)(objectClass=user));adspath;subtree"

I hope this will help you. :-)

Thursday, October 24, 2013

How to disabled IPv6 on Windows 2008 Server from registry

Step to permanently disabled IPv6 from Windows 2008 Server or windows 7.


If you do not required IPv6 on your windows 2008 Server system or windows 7 Desktop you can disabled it from registry.



To disabled IPv6 support go to:-

login in to the server/Desktop with user member of Administrator group and follow the step

 Start> run > and type regedit. Expand the path

Coputer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIV6\Parameters

Now Right Click the folder Parameters and Select New > DWORD(32-Bit) Value > Name the key as DisabledComponents
Now open the DisabledCompontents key and type ffffffff and click ok.<8 time " f " with lower case >

Final setting look like this:-



Now close the all application and restart your server/Desktop.


After reboot check IPv6 disappear from command result ipconfig /all

Monday, May 20, 2013

Installing & Configuring Active Directory on Windows Server 2012 Step By step


To install Active Directory on Windows Server 2012 we will need Static IP to system, DNS & FQDN for Domain.

Adding the Active Directory Domain Services Role

Log on to server with local administrator account & open Server Manager.
From the Server Manager window click on “Add roles and features”. 
Then “Before you begin screen” will open, click Next. 


Select “Role-based or feature-based installation” in the “Installation Type” screen below & click Next.

You will then see below screen from which you can select a destination server.  Windows server 2012 is having this new feature using which you can deploy roles and features to remote servers or to an offline virtual hard disk.  We are selecting the current server from the server pool. Select the server & click Next.


Then on Add Roles And Features Wizard select the “Active Directory Domain Services” and “DNS Server”



Then you will be prompted to add the features needed by Active Directory Domain Services (ADDS). Click “Add Features”.



Then on below screen select “DNS Server” & click Next.


Then on below screen you can select additional feature if you want & click Next.
(Group Policy Management feature will be automatically installed during the domain promotion).


Then on “Active Directory Domain Services” page below you will see some basic information about ADDS & DNS. Click Next.


Then on next page you will be able to see summary of the roles & features selected for installation. Click Install.


It will start installation process & upon completion will show installation succeeded message. Click Close.


Promoting Server To A Domain Controller

After installing AD DS roles & features you will be able to see AD DS in the left pane in Server Manager window with warning message stating “Configuration required for Active Directory Domain Services” Click on More.


Then All Server Task Details And Notifications window will open. Click on “Promote this server to a domain controller” under Action.


Then AD DS configuration wizard will open.
Select “Add a new forest” as this is the first domain controller.  Enter Root domain name & click Next.


On below screen specify Forest Functional Level & Domain Functional Level also provide Directory Services Restore Mode password. Click Next.


You will get warning regarding DNS delegation, which can be ignored. Click OK & then Next.


On next window, NetBIOS name will be automatically assigned. Click Next.


On next window you will be able to confirm or change the path of Database, Logs & SYSVOL folders. Click Next.


Then on Review Options page, review your selections & click Next.


Then it setup will check for prerequisite. After passing through prerequisite, click on Install.


At completion of setup, system will restart. After promoting the server to domain, your local administrator becomes domain administrator. So, login to the server using domain administrator user name and password. 

Thursday, February 28, 2013

How to convert or resize image file using ImageMagick

 convert or resize image using ImageMagick


ImageMagick is a free software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick is available for Linux , Mac and windows.

You can download ImageMagick from http://www.imagemagick.org


For Ubuntu user can install ImageMagick using

sudo apt-get install imagemagic

For CentOS user can install ImageMagick using

yum install ImageMagick ImageMagick-devel

suppose you have image.png file and you wanted to convert it in to jpg format. You can do this with command line with following command

convert  image.png image.jpg

if you have bunch of file suppose .png and  you wanted to convent it in jpg  format then put all .png file in one new directory and go to new directory path and execute following command to convert all png format file in to .jpg format

convert *.png new.jpg

and if you wanted all your jpg file in single one pdf file then you can use following command

convert *.png imagefile.pdf

and if you wanted to create single gif file of all your  jpg file you can do this using command

convert *.jpg newimage.gif
convert -delay 20 *.jpg  newimage2.gif

you can also convert your avi file in to gif  format using command

convert -quiet -delay 1 vidio.avi vidio.gif 


You can resize image by using resize option. for example

convert image.jpg -resize 50% half_image.jpg
 

you can do lot of task using command line with ImageMagick

Wednesday, February 20, 2013

How to type in Marathi in Windows 7

Step by Step how to type in Marathi in Windows 7



In windows 7 you can type and save your document in Marathi without installing any third party software. You can do this by adding Marathi support in your windows 7. Do the following step to install (enabled ) support for Marathi typing.

Go to Start and select control Panel. It will open new windows of Control Panel. 


In Control Panel select Region and Language option

 This will open new windows of Region and Language. Select Keyboards and Language tab in Region and Language windows.


  Then select Change Keyboards button in Region and Language windows.



This will open one child window of Text Services and Input Languages. In the windows of Text Services and Input Languages in General tab select Add button in Installed services option to install supported language in our case Marathi.

In the list select Marathi (India) and in keyboard select keyboard as Devanagari and/or Marathi and select OK button to add input language.


Then select Apply button then OK to close the windows and then close all the open windows. Now Marathi keyboard is enabled on your system. you can now type in Marathi by selecting language and kayboard layout from language bar at bottom on taskbar.


Now open any word file or notepad select MA from language bar and type in your own language (Marathi) :-)



 If you are not familiar with Marathi keyboard as me use on-screen keyboard.


 To open on-Screen windows just simply type on-screen keyboard in Startsearch program and file box and then select on-screen keyboard. this will open on-screen keyboard