Translate

Sunday, 28 July 2019

Solved- webmin has a libnet-ssleay-perl problem

Initially I was confused, I tried so many ways but I still get error.

1- sudo apt-get update
and I get-
Hit:1 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:5 http://in.archive.ubuntu.com/ubuntu bionic-proposed InRelease
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Fetched 19.3 kB in 3min 42s (87 B/s)
Reading package lists... Done
2- sudo apt-get upgrade
and I get This Error-
update-initramfs: Generating /boot/initrd.img-4.18.0-25-generic
I: The initramfs will attempt to resume from /dev/sda2
I: (UUID=7617de5b-de18-429b-839e-adb13a5646cd)
I: Set the RESUME variable to override this.
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb
this will download the package.
 sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl
but still I was getting Error anfter that I tried 
sudo apt-get install apt-show-versions

Then I get below error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  apt-show-versions
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 28.6 kB/312 kB of archives.
After this operation, 93.2 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 apt-show-versions all 0.22.7ubuntu1 [28.6 kB]
Fetched 28.6 kB in 0s (62.8 kB/s)            
Selecting previously unselected package apt-show-versions.
(Reading database ... 161378 files and directories currently installed.)
Preparing to unpack .../apt-show-versions_0.22.7ubuntu1_all.deb ...
Unpacking apt-show-versions (0.22.7ubuntu1) ...
Setting up apt-show-versions (0.22.7ubuntu1) ...
** initializing cache. This may take a while **
dpkg: error processing package libnet-ssleay-perl (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get -f install

After this try I get again below Error

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/284 kB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: error processing package libnet-ssleay-perl (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get autoremove libnet-ssleay-perl
This will remove 
libnet-ssleay-perl but still I get below error-

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libapt-pkg-perl is already the newest version (0.1.33build1).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
1 not fully installed or removed.
Need to get 0 B/284 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
dpkg: error processing package libnet-ssleay-perl (--configure):
 package is in a very bad inconsistent state; you should
 reinstall it before attempting configuration
Errors were encountered while processing:
 libnet-ssleay-perl
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get install --reinstall libnet-ssleay-perl 

And this solved my problem. after this I
sudo apt-get update
and 
sudo apt-get upgrade

and I found problem has been solved

sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04
  linux-image-generic-hwe-18.04
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

Thursday, 1 November 2018

Simple Data Structure Implementation


Data Structure Basic Concept and Program using C language

Include the header file 
#include <stdio.h>
#include <stdlib.h>

Define the Node Strucure
struct Node{
 int data;
 struct Node* next;
};

Function to add data on begining
void addBegning(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = *head;
 *head = newNode;
}

Function to add data at last position
void addLast(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* last = *head;
 newNode->data = newData;
 newNode->next = NULL;
 if(*head == NULL){
  *head = newNode;
  return;
 }
 while(last->next != NULL){
  last = last->next;
 }
 last->next = newNode;
 return;
}

Inserting data after some node
void insertAfter(struct Node* head, int newData){ 
 if(head == NULL) return;
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = head->next;
 head->next = newNode;

}

Deleting a element from data structure
void deleteElement(struct Node** head, int element){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* temp = *head, *prev;
 if(temp != NULL && temp->data == element){
  *head = temp->next;
  free(temp);
  return;
 }
 while(temp != NULL && temp->data != element){
  prev = temp;
  temp = temp->next;
 }
 if(temp == NULL){ printf("Element does not exist in list"); return;}
 prev->next = temp->next;
 free(temp);
}

Reverse the Linked List
static void reverseList(struct Node** head){
 struct Node* current = *head;
 struct Node* next = NULL;
 struct Node* prev = NULL;
        while(current != NULL){
              next = current->next;
                current->next = prev;
                prev = current;
                current = next;
        }
 *head = prev;
}

Print the data
void printData(struct Node* node){
 while(node != NULL){
  printf("%d\t", node->data);
  node = node->next;
 }
 printf("\n");
}

Main 
int main(){
 struct Node* head = NULL;
 addBegning(&head, 2);
 addBegning(&head, 50);
 addBegning(&head, 9);
 addLast(&head, 10);
 addLast(&head, 25);
 insertAfter(head->next->next, 30); //head-1, head->next-2, head->next->next-3
 printf("Before Deletion\n");
 printData(head);
 deleteElement(&head, 30);
 printf("After Deletion element 30\n");
 printData(head);
 printf("After Reverse Linked list\n");
 reverseList(&head);
 printData(head);
 return 0;
}

One File Program 
#include <stdio.h>
#include <stdlib.h>

struct Node{
 int data;
 struct Node* next;
};

void addBegning(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = *head;
 *head = newNode;
}
void addLast(struct Node** head, int newData){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* last = *head;
 newNode->data = newData;
 newNode->next = NULL;
 if(*head == NULL){
  *head = newNode;
  return;
 }
 while(last->next != NULL){
  last = last->next;
 }
 last->next = newNode;
 return;
}
void insertAfter(struct Node* head, int newData){ 
 if(head == NULL) return;
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 newNode->data = newData;
 newNode->next = head->next;
 head->next = newNode;

}
void deleteElement(struct Node** head, int element){
 struct Node* newNode = (struct Node*)malloc(sizeof(struct Node));
 struct Node* temp = *head, *prev;
 if(temp != NULL && temp->data == element){
  *head = temp->next;
  free(temp);
  return;
 }
 while(temp != NULL && temp->data != element){
  prev = temp;
  temp = temp->next;
 }
 if(temp == NULL){ printf("Element does not exist in list"); return;}
 prev->next = temp->next;
 free(temp);
}
static void reverseList(struct Node** head){
 struct Node* current = *head;
 struct Node* next = NULL;
 struct Node* prev = NULL;
        while(current != NULL){
              next = current->next;
                current->next = prev;
                prev = current;
                current = next;
        }
 *head = prev;
}
void printData(struct Node* node){
 while(node != NULL){
  printf("%d\t", node->data);
  node = node->next;
 }
 printf("\n");
}
int main(){
 struct Node* head = NULL;
 addBegning(&head, 2);
 addBegning(&head, 50);
 addBegning(&head, 9);
 addLast(&head, 10);
 addLast(&head, 25);
 insertAfter(head->next->next, 30); //head-1, head->next-2, head->next->next-3
 printf("Before Deletion\n");
 printData(head);
 deleteElement(&head, 30);
 printf("After Deletion element 30\n");
 printData(head);
 printf("After Reverse Linked list\n");
 reverseList(&head);
 printData(head);
 return 0;
}

Give Something to the world and it will never let you down.  
Onkar Dubey 




Service that allow to run a program on boot (Linux Platforn)



In this tutorial I will show you how you can run a program on boot (startup) using Linux platform this will work on all Linux distros
This service can run all type of executable file.
If you want to run you ".c" file, first compile it and put the compiled file name with the directory as written in Step-3 "ExecStart = "..........." and change the working directory directory in Step-3 WorkingDirectory= " ................" this directory is your executable file directory.

This is tested on Ubuntu 18.

Step 1- Go to system directory

$ cd /etc/systemd/system

Step 2- Open vi Edititor and write the service

$ vim myservice.service
Step 3- Paste the following code as instructed
--------------------------------------------------------------------------------------------------------------------------
[Unit]
# This is the name of service
Description=om service
[Service]
#User is as root, the program will run as root user
User=root
# The configuration file application.properties should be here:
#change this to your workspace
WorkingDirectory=/home/om/workplace
#path to executable. 
#put the executable file
ExecStart=/home/om/workplace/myprog
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
--------------------------------------------------------------------------------------------------------------------------

Step 4- Enable the service

$ sudo systemctl daemon-reload
$ sudo systemctl enable sample.service
$ sudo reboot
If You need any further query please send a message or comment.



Give Something to the world and it will never let you down.  
 
Onkar Dubey