Lessons in Linux

Once the modifications are working well, they can upload (push) the branch to the original repo on your computer where you can view the changes and merge them into the master branch. Once there’s an updated master branch on the original repo, others can then download (pull) a fresh copy of the master branch to get the new changes. Root Users Let’s experiment with this using another user (root) on the same computer – the only requirement is that the other user has read/write access to your repo folder. The following commands run by the root user (the other user) create a cloned copy of the myscripts repo (/home/jason.eckert/myscripts) within the root user’s home directory (/root) using the git clone command: [root@csc-studev01 myscripts]# pwd /root [root@csc-studev01 ~]# git clone /home/jason.eckert/myscripts/ Cloning into ‘myscripts’... done.

[root@csc-studev01 ~]# cd myscripts/ [root@csc-studev01 myscripts]# pwd /root/myscripts [root@csc-studev01 myscripts]# ls chownscript.sh filemaintain.sh newuserscript.sh seccheck.sh sysusage.sh [root@csc-studev01 myscripts]# _

If you were cloning this from another computer, you’d have to use git clone username@hostname:/ path instead. For example, to clone this repo on triosdevelopers.com to your local computer, you’d have to use the command git clone root@triosdevelopers.com:/home/jason.eckert/myscripts/ and supply the root user’s password when prompted.

Now, let’s make a branch called AddSIEM that we can use to test out adding security information and event management (SIEM) functionality to our seccheck.sh script and view our branch when finished:

[root@csc-studev01 myscripts]# git checkout -b AddSIEM Switched to a new branch ‘AddSIEM’ [root@csc-studev01 myscripts]# git branch * AddSIEM master [root@csc-studev01 myscripts]# _

Notice that the git branch command indicates that AddSIEM is our current branch (*). Now, let’s modify the script, view the modification, stage and commit it:

[root@csc-studev01 myscripts]# vi seccheck.sh [root@csc-studev01 myscripts]# git status On branch AddSIEM Changes not staged for commit: (use “git add ...” to update what will be committed) (use “git checkout -- ...” to discard changes in working directory)

modified: seccheck.sh

Made with FlippingBook Online document