more git commands...!!!

Back

How to remove any directory locally and push the change.

$ git rm -r name_of_the_directory
$ git commit -m "message"
$ git push origin BranchName 



How to undo git add command

Sometimes, we index some file and then we want to undo the operation due to various reasons like the file has been deleted intentionally. 

So, for that, 

$ git reset -- fileName

Remember, -- is the most important thing


it will not work, if you will just do

$ git reset fileName








































Jenkins Installation




  • Download jenkins war file under LTS Release from here
  • To start jenkins, 
  • open command prompt
  • goto the directory where you have downloaded the jenkins.war file.
  • Run  
Java -jar jenkins.war


and you will see the below screen






Open your web browser and goto localhost:8080

You will see









Next >




























GETTING STARTED


  • Jenkins is one of the most popular systems currently in use. So, what Jenkins all about?
  • Jenkins is a Continuous Integration server.
  • Continuous Integration helps to run tests on a non-developer machine automatically whenever there is a change in code inside the repository.
  • So, quickly based on automatic testing, we can tell whether the build broke or passed. Due to fast feedback, we can analyse the console inside Jenkins and check where was the error.
  • If we run these tests occasionally, then there are chances of huge changes in code and so very tough to find the bug and revert back.
  • Based on successful testing, Jenkins deploys the new built, making the release very smooth and simple.




How to create symbolic links in Linux

Symbolic Links are basically a link to some application. They save your time to everytime go to that particular folder deep into the directory structure to start your application.

We can create a symbolic link by :-

ln -s location_of_your_link  your_term_for_link

Example

ln -s /usr/local/bin/eclipse eclipse

now when you type eclipse on terminal, it will go to that location_of_your_link and open it.

To confirm, the link has been created, try these

  1. Type eclipse and it will open up the application
  2. Use the command "ls -la", and you will see something like this 
lrwxrwxrwx.   1 tchander tchander         22 Nov 17  2015 eclipse -> /usr/local/bin/eclipse
 
arrow (->) means symbolic link

Enjoy Linux...







Contiguous Memory Allocation?

Contiguous Memory Allocation

Contiguous memory allocation is a classical memory allocation model that assigns a process, consecutive memory blocks (that is, memory blocks having consecutive addresses).





What is a socket in networking?


socket is one endpoint of a two-way communication link between two programs running on the network. 
socket is a combination of the port number and the IP address, so that the TCP/UDP layer can identify the application that data is destined to be sent to. 


Take an example of an apartment building ( World Famous Analogy)


  1. The street address of the building is the IP Address
  2. The specific apartment number in that building is the port number (port number tells the type of data transmission - TCP or UDP)
  3. The door of the apartment is the Socket (TCP + Socket)



So, the postman (TCP Layer) needs all the values
- Building Address (IP Address)
- Apartment Number (Port Number)
- Door (Socket)

so that the letter in postman's hand (data) can arrive at the correct destination (application).









What's a Memory Leak?


  • A memory leak is like a virtual oil leak in your computer. 
  • It will slowly drains the available memory, reducing the amount of free memory the system can use. 
  • Most memory leaks are caused by a program that unintentionally uses up increasing amounts of memory while it is running. 
  • This is typically a gradual process that gets worse as the program remains open. If the leak is bad enough, it can cause the program to crash or even make the whole computer freeze.



Reference - http://techterms.com/definition/memoryleak





How to do persistent mounting of a partition over a reboot?

Sometimes, we manually mount a folder but if we do a reboot, it doesn't stay there. 
So, How to mount a partition so that it remains persistent over reboot ?

mount --bind /source/folder destination/folder

Type the following in the /etc/fstab file

source/folder                destination/folder                 bind                 0 0


Then, if you do a reboot also, the mounted folder will stay as it is.

Creating File in CentOS Docker container



Let's create a file in the centos container.










So, you can see above

- I have a created a directory in my Centos Container (ae358738....) called Sample

- I have created a SampleText.txt file in it

- I exited the centos docker container

Now, to check this file again, we need to restart the same docker container
so, we use







[Press Enter]



And we are back to the same centos container and we can see our files back in it.









So, in this way, we can play between many Operating Systems keeping our whole work in each container safe also.





Exiting Ubuntu Docker Container


Now, to exit this UBUNTU docker container, simply type exit

now, to see the history of container you created, exited, on-going etc, type













To see only running containers,




Remember, if you open a ubuntu image 3 times, so, every time, there will be a different docker container.
And so, from the image, you can see, the containerID. They represent that I opened same ubuntu image multiple times, but, all were having a different docker container.







Docker commands (cont.)



To grab the image and download, docker has a pull command (sudo docker pull --help)





if well an image without tag, for instance




it will download multiple images of ubuntu as shown below












So, to avoid this downloading of multiple images, we use a tag

So, with a tag,





here, latest is acting a keyword which will bring down the latest version of ubuntu



To check the existing images in your local directory, type





To kill any running docker container,type





To delete any docker container,type







Docker


Docker is a virtualization technology like virtual box or vmware.

Allows multiple OS with multiple functionalities

The idea of docker is to virtualize all the apps on one Operating System. So, I can run 
multiple virtualization functionalities on a single OS and having those functionalities isolated from each other.

If you have an app which uses Java7 and there is an app which uses Java 8 , then through Docker both of them can run on a single OS side by side simultaneously, without installing both the JDK's on your machine keeping both of them completely isolated from each other .


Virtualization means having a disk image that represents the system we are running on. So, the docker registry contain tons of such images which we can containerise and use to run anywhere. The docker company and communities maintain this registry.


Remember, docker always require admin access, so use "sudo"






How to write to a file in shell script?


Linux uses >> operator to write to a file.

For instance:
If you want to calculate the size of your log directory and want to write it somewhere, then

du -s  /var/log>> filename

Isn't this simply awesome,


Multiple commands
( date +'%Y %m %d %H : %M'; du -s /var/log) >> LogsDirectorySize.txt;

In above sample, we are writing date plus size both. Yes, so simply use semi colon ; to write multiple things.








Enjoy Linux...!!!