Getting started With Linux!

I had recently learnt about Linux and its terminal command from Crio.do and was totally surprised because almost all tasks can be done with the help of Linux terminal. Whether it is checking the file contents or analyzing big data to even posting a message on twitter ! all these can be done with the help of Linux terminal.
Some of the Linux terminal which I learnt and is absolutely necessary are:

Making a mimic of google drive with the help of Linux terminal and git cloud.

At first I thought this would be really difficult but then after learning about Linux terminal commands and git , this was not that difficult to build as it sounds, believe me Linux makes these kind of tasks a lot easier.
So the basic idea here was to make an automated process of backing up and synching files from your local computer file to you github/gitlab repository. There are just two steps to follow here
STEP 1 : Making a Linux shell scrip to detect if there any changes made in the file in the particular directory , if there is a change just have to push the changed files to gitcloud with the help of git commands.
STEP 2 : Making this script run automatically in the background every (say 10 minutes), with the help of crontab.
before going on how to actually make this , these are some of the most basic and useful git commands
git add
The git add
command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add
doesn't really affect the repository in any significant way—changes are not actually recorded.
git commit
The git commit command is one of the core primary functions of Git. Prior use of the git add command is required to select the changes that will be staged for the next commit. Then git commit is used to create a snapshot of the staged changes along a timeline of a Git projects history.
git push
The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It’s the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.
You can learn more about git here : git for beginners
Back to the challenge, for us to make this we should know what a script file is. So in simple terms a script file is a file containing a series of commands. The shell reads this file and carries out the commands. You can refer this link for more information about shell scripting.
STEP 1 : creating the script file

So what this script basically does is loops through the contents of a particular directory (for this case the directory is the local git repository) and checks the content of each file and stores it in a variable called sum 1 and then after some specific time (here 60 seconds ) it checks the content of the files once more and stores in another variable sum2, now if the sum 1 is not equal to sum 2 then that means the file content has changes , so the command goes to else block and pushes the modified file.
STEP 2 : putting this script file in the crontab
The Cron daemon is a built-in Linux utility that runs processes on your system at a scheduled time. Cron reads the crontab (cron tables) for predefined commands and scripts. By using a specific syntax, you can configure a cron job to schedule scripts or other commands to run automatically.
This is actual simple all you have to do is run this command on the Linux terminal $crontab -e and edit the file (I used the default nano editor) to add the duration of the process and the path of the script file.

here i have added my script.sh file in the crontab , the ‘*’ is nothing but the duration. (here it means that the script will run every minute).you can refer to this link for a better visualization of the cron time.
Working Demonstration
That’s it ! we have made an automatic backing up and synching of files which runs automatically (here every 1 minute , but you can always change the duration of running the script).
I would like to thank crio.do for giving us this opportunity, where you can learn by actually doing.
