Monday, June 3, 2019

systemctl : Service Manager

In this post we will be discussing about systemctl service manager

the general syntax of the command takes the format as given below....
> sudo systemctl <status> <service-name.service>
the status from the above format can be different, I would like to mention some of them here
  • start
  • stop
  • enable
  • disable


  • and so on....
for eg... if you want to start mysql service in your linux box, you can use the following command to start the service.
> sudo systemctl start mysql

Similarly you can replace the status with the values furnished above....

The following is the command to stop the service
> sudo systemctl stop mysql
To enable the service, use the following command
> sudo systemctl enable mysql
To disable the service, the command takes the following format...
> sudo systemctl disable mysql
The mentioned above are some of the options included in SYSTEMCTL service manager tool....

If you would like to know the entire details of systemctl manager... you can use the command line....
> systemctl --help

Monday, May 20, 2019

Linux CRONTAB

Hi,

In this post we will discuss about Linux CRONTAB.

To put in short, the Crontab is a scheduler program or simply a program which executes an other program/command at a specified frequency.

Then general format of the Crontab would be as follows...
> crontab -e
the above command would open up crontab in a edit mode and the entries would take the general format as follows
* * * * * < program/command to be executed >
Let us discuss the asterisks as part of the command in detail...

From the left
MINUTE
The first asterisks(*) is a place holder for minutes i.e from 0 - 59

if the program/command to be executed at the start of 10 minute of every hour then the crontab entry would be like
10 * * * * < program/command to be executed >

HOUR
The second asterisks(*) is a place holder for hours i.e from 0 - 23

In case if you want your program to be executed at the start of every minute of the fifth hour then the entry would be
* 5 * * * < program/command to be executed >

DAY_OF_MONTH
The third asterisks(*) is a place holder for day of month i.e from 1 - 31

if you want your program to be executed only on first day of every month and on every minute then the crontab entry would be as follows...
* * 1 * * < program/command to be executed >

MONTH
The fourth asterisks(*) is a place holder for month, just like day of the week it is also represented with numbers

1 - January
2 - February
3 - March
4 - April
5 - May
6 - June
7 - July
8 - August
9 - September
10 - October
11 - November
12 - December

if you want your program to be executed only in sundays in january and at the start of every minute, then the crontab entry would be as follows.
* * * 1 0 < program/command to be executed >

DAY_OF_THE_WEEK
The fifth asterisks(*) is a place holder for day of the week i.e from Sunday - Saturday, normally the days of the week is represented as numbers, like ...

0 - Sunday
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday

So if you want your program to execute only on sunday then the entry in the crontab would be as follows
* * * * 0 < program/command to be executed >
the key thing to look at form the above command is, the program/command would be executed at the start of every minute on sunday alone.


.
.
.
.
.

if you want your program to run every minute on all days, all weeks, all months then the entry would be as follow...
* * * * * < program/command to be executed >

Wednesday, May 15, 2019

Resetting a local branch to its HEAD version in GIT

Hi,

In this blog we are going to see how to reset a local branch to its HEAD version.

This is going to be a very short post and hope you like it

The format of the command to RESET a branch is given below
> git reset --hard <branch-name>

Assuming you have branch named "feature/registration", then the above command would be something like the one given below...
> git reset --hard feature/registration
If the execution is successful then you would see a message as mentioned below...

HEAD is now at <version> <commit-message>

Thursday, March 28, 2019

Technical difference between HARD and SOFT links in linux

Hard and Soft links, hmm what are those?

Well we are going to see what are those and how they are technically different from one another, lets jump in

Most of the people who uses windows operating system should be familiar with the term ShortCuts, which is nothing but accessing a file indirectly... if you want me to put this in other terms, I would say referring the contents through other means.

Well in Linux and Unix like operating systems, this concept would remain same as far as Soft links are concerned well with Hard links the story is entirely different.

Let us justify ourselves through a small demonstration....

Create a file in your favourite location using the following command
> touch mainfile.txt
Let us see the statistics of the file mailfile.txt using the following command...
> stat mainfile.txt

From the above image, we take three important properties i.e Inode, Links and the type of the file which is nothing but regular empty file, for now let the file be empty and when we try dealing with Hard Links we put some contents in it.

Soft Link
Now let me create a soft link for the file mailfile.txt, the command given below would create a soft link for the file mainfile.txt
> ln -s mainfile.txt softlink-for-mainfile
the above command would create a new file named softlink-for-mainfile which would point to the file mainfile.txt and not the inode of the file mainfile.txt, technically the actual file i.e mainfile.txt and the link to it are two different files. the soft link to the actual file has no meaning in the absence of the main file.

Let us have the statistics of the two file

Statistics of mainfile.txt


Statistics of softlink-for-mainfile



If you look at the File property from both the stat it is very evident that the second file is a link to the first one. The File property is not the only which confirms that but the inode property too, please do have a look at it the values of inode are different.

Now I am going to move the main file to a different location in order to test the validity of the link that we created.

Try moving the file mainfile.txt using the following command...
> mv mainfile.txt ../


From the picture above, it is evident that the soft link has become invalid when the file is removed/moved or deleted from the original location. You can also confirm this by trying display the contents of the file using the cat command as given below...
> cat softlink-for-mainfile


As said now we can conclude that the soft link becomes invalid without the original file.

So as far as soft links are concerned, we could have the below inference...

1. Soft links cannot stand alone
2. Soft links becomes invalid if the source/original file is moved to different location
3. Soft link and the original file are not the same but they are two different files.

Hard Link
Let us now deal the second part of the story i.e the Hard links

Let us create a hard link of the file mainfile.txt using the command given below...
> ln mainfile.txt hardlink-for-mainfile
After the execution of the command, you would have a file named hardlink-for-mainfile at the location where you executed the command, this can be witnessed from the image below...


Now let us have the statistics of the both the files....

Statistics of mainfile.txt


Statistics of hardlink-for-mainfile



From the images above, you can infer the following details

1. Both the files pointing to the same inode
2. Both the files are regular empty file
3. The total number of links to the inode is 2, which is given against the property Links.

Regarding the links, if you try to have another hard link to the mainfile.txt... the links count would be increased to 3, let us see how is this

Try creating an other hard link to the file mainfile.txt
> ln mainfile.txt hardlink-for-mainfile-1
now if you look at the stat of the file mainfile.txt, the Links property of the inode would have increased by 1, to justify that have a look at the screen shot given below...



Now here comes the interesting part of the story, put some contents into the file mainfile.txt using the command as given below
> echo "hello world" > mainfile.txt
now let us have the stat of the file mainfile.txt


As you can see the file has been changed from "regular empty file" to "regular file". Now, what would be your expectation on the files hardlink-for-mainfile and hardlink-for-mainfile-1, let us see from the screen shots given below...

Statistics of the hard link hardlink-for-mainfile and hardlink-for-mainfile-1



If we look at the image above everything remains same except the name of the file... which conveys all the three files are pointing to the same inode than the different one.

This can even be concluded by deleting the original file, Now try deleting the original file i.e mainfile.txt using the below command and look at the statistics of the hard links we created.
> rm mainfile.txt




From the above image it is evident that, though the original file is deleted the hard links created would retain the inode that actually belongs to the original file.

So, we could conclude the morale of the story as follows...

1. soft link created on a file cannot stand alone without the original file
2. soft link has its own inode
2. hard links would retain the inode of the original file even though the original is deleted
3. hard links uses the same inode as that of the original file.

Hope you liked the story. Thanks.

Wednesday, March 27, 2019

Technical difference between "mv" and "cp" command in LINUX

In this post we are going to discuss about the difference i.e the technical difference between Move and Copy command in linux.

As we all know the copy command is used to make the replica of a file or a directory in linux, where as the Move command it moves the file or a directory to a another location that we mention as part of the command.

What we discussed above is a theoretical difference between these commands, but how technically they are different? well, to answer this question we have to have the statistics of a file soon after the execution of the above mentioned commands.

Let me put this in a simple way to understand.... assuming we have a file named test.txt in one of the locations in the file system as given in the image below...


before we move further, I would like to discuss the details mentioned in the image

  • First column of numbers is the inode number of the file/directory
  • Second column tells us the privileges available on a file/directory
  • Third column gives the number of links to the file/directory
  • Fourth column gives the user who owns the file
  • Fifth column gives the group of the user
  • Sixth column is the IO Block of the file
  • Seventh column gives the last modified date of the file/directory
  • Eight column gives the time at the file/directory is modified
  • Ninth column is the name of the file/directory


From the above details, the real candidate for consideration is the INODE number of the file/directory, this number is generated by the file system for the files/directories when they are created, but how this inode number tells the techinical difference between these two commands?

Rather talking, actions would give ample information to convince us so let us get on with it.

let me take the COPY command first...

Before we copy the file test.txt let us have the statistics of the file itself...



the image above and the previous one would have the same inode number against the file test.txt, you can check it comparing the images above

Now let us take the replica of the file test.txt i.e copying the file to another location in the file system and analyse the statistics of the file again...


As you can see the inode of the file test.txt which is available in the new location is entirely different from the previous one.

From this we can conclude that the file copied to a new location is not the same file as the one which is copied but it a replica of the old file.

Now let us try to move the file test.txt to a new location and infer the statistics...


From the above image if we look at the inode number of the file, it is same as that of the one available in the last location, from this stats we can conclude that the file which moved is the same old file and the command does not create a new file as that of the old one and deletes the old.

Hope this post helps in understanding a bit about inode, files and commands.

Post you comments and thanks.

Thursday, March 21, 2019

Want to get rid of "System program problem detected" in ubuntu

What is this post is all about?



Well those who are familiar with Ubuntu Linux operating system might have encountered this problem, this alert message normally appears at start up of the system. What is this error message and what is it trying to convey?

The answer is pretty simple, When ever we try to install something and during installation if there is some breakage in the package this alert message pops up every time you login to the system.

Some people really do not care about such pops up where as for some it is a serious issue...

Before we correct this pop up problem, let us understand why this happens.

As I said earlier this problem happens due to some broken packages available in the system, but how did I get those broken packages well there could be lot of reasons, some of them are mentioned below...

  • When the supporting packages are not available.
    • assuming you are trying to install jenkins package in your system, the package manager tries to find all its supporting packages online, in case the package manager find all it needs to install jenkins the installation process goes fine, if not it would end up as an error... this would results in broken packages..
  • When your internet is broken in the middle of the installation process.
    • During the process of installation of a package and when the package manager finds all the supporting packages it needs to install the actual package, the process continues as long as your internet connection is stable, if not you would encounter this from ubuntu.

What I mentioned above are some of the reasons... there could be other reasons contributing to this alert message as well.

Now the time has come to clear this alert message from the system, when ever such broken package or crash situation happens, ubuntu logs the situation in the folder /var/crash

Just like the entries in the image given below....


The simple solution to get rid of this problem is to delete all the entries you find in the folder by using the command below..

> rm /var/crash/*

What we have discussed here is a temporary solution, well I prefer to stick to the temporary solution as far as this error is concerned because if any such situation happens in future... it would help us to track the problem for further investigation.

Well that is it and hope you have found the solution here for your problem.

Thanks. 

Wednesday, March 20, 2019

Installing Jenkins 2.164.1 CI Server in Ubuntu-16.04 LTS

Hi, in this post we are going to see how to install Jenkins Continuous Integration Server in ubuntu.

The following are the required soft wares needed to have a successful installation

1. java-1.6 or greater
2. Jenkins war file

We are going to use the WAR package of jenkins to have the server up and running

Since most of us know how to install java, I am not going to talk about installing it, you can check online resources(plenty available) on how to install the same.

Let us download the Jenkins-2.164.1.war file from the location given below

http://mirrors.jenkins.io/war-stable/latest/jenkins.war

Make sure you have the downloaded package in a location you prefer.

Open a terminal and execute the command below to have your server up and running
> java -jar <location-of-jenkins.war>/jenkins.war

When the server is ready to serve... you should be able to see console as something below...




After executing the above command, Open a browser and on the address bar type the location as below...
http://localhost:8080/

Now your browser would have you at the page as given below...



Well this concludes the installation of Jenkins CI server... hope you like it

thanks.

Installing Python and Creating Virtual Environment for Pip for package installations in Ubuntu

Hi, In this post we are going to look at how to install Python and PIP and installing packages in virtual environments.. Without wasting...