Thursday, June 29, 2017

How to create datewise folder in Ubuntu / Linux

Below command will create folder based on the current system date.

>mkdir $(date +%d-%m-%y)


Samba Share not working with Ubuntu / Linux


Should run Samba from Terminal.

$ gksu system-config-samba

If returns error message with last line similar to this:

#SystemError: could not open configuration file '/etc/libuser.conf': No such file or directory

Create the missing file:

$ sudo touch /etc/libuser.conf

and run Samba again

$ gksu system-config-samba





The above reference is taken from another site and used here solely for my technical purpose.

How to exclude folders from automated zip in linux command line


This guide will show you how to exclude certain folders and its sub-folders from zip in linux.

If you want to zip a folder with few sub-folders under it and you would like to exclude some folders from it then how can you do it. Below is a scenario and steps.

For Exa: There is a folder

/home/John/Maindata

Now folder "Maindata" has another 5 sub-folders like:-

/home/John/Maindata
/home/John/Maindata/New1
/home/John/Maindata/New2
/home/John/Maindata/New3
/home/John/Maindata/New4
/home/John/Maindata/New5

Now if we would like to exclude sub-folder "New1" and "New3" from zip, then below are the steps.

Open text editor (Gedit / Leafpad)

Copy-Paste the below given commands in it and save with "Filename.sh"


__________________________________________________________

 #!/bin/bash
echo "processing......Please wait !!"       ##this is just to show a msg

zip -r Maindata.zip /home/John/Maindata -x *New1* *New3*

echo "Completed"

___________________________________________________________

Open terminal and write the below command

> chmod +x "filename.sh"   (press enter / return key)
>

This will make the file executable which can help for one-click / automated tasks.

Now run that file and it will create a zip file name - "Maindata.zip" which will have folders like this:-

Maindata.zip
         |
       New2
         |
       New4
         |
       New5

So this will exclude sub-folders - "New1" and "New3" from zip process.







How to auto zip folder(s) in linux from command line for scheduling tasks


This guide will show you how to zip folder(s) in linux with command line.


For Exa: If you have a folder in linux on a path say:-

/home/John/Maindata/Imp_data

and you want to zip "Imp_data" folder

Below given are the steps and commands to zip folder(s) in linux with command line.

Open text Editor (Gedit / Leadpad)

Write the below given commands (copy-paste the command and save it with file extension "filename.sh")

____________________________________________________

#!/bin/bash
echo "processing......Please wait !!"

zip -r Imp_data.zip "/home/John/Maindata/Imp_data"

echo "Completed"
_____________________________________________________

Then go to terminal and write the following command

> chmod +x "filename.sh"  (press enter)
>

This will make that file executable. So now you can run this file for automated zip process.

# Now you can run this file manually or use this for scheduled tasks.


This will create a zip file on the same location like:-

home/John/Maindata/Imp_data.zip

Monday, January 30, 2017

How to create a batch file to Exclude folders to zip from Windows command line


Below given are some easy steps to create a zip file of your files and folders on your computer and copy it to a different drive on your computer.

* Make sure you have either of the file compression software (WinZip / WinRar) installed on your machine.

For Exa: You have folders on your computer's C:\Drive say -

C:\Intel
C:\Logs
C:\Drivers\
C:\Drivers\Printer_Logs
C:\Drivers\Manual_Logs
C:\Drivers\Code_Logs
C:\Drivers\QA_Logs

Now you want to make zip file of "Drivers" folder and want to exclude Sub-folders "Manual_Logs" and "Code_Logs" from zip, below given are the steps to do so.

Goto>Start>Run>Notepad

Once the Notepad is open, type the below given contents:-
____________________________________________

@echo on
winrar a Games.rar C:\Games -x*\file3 -x*\file4
@echo off
_____________________________________________

Enjoy.....