Get your local IP address like pro
In shell scripts if you need to get you local IP address corresponding to your hostname then you can use this command
hostname -i
In shell scripts if you need to get you local IP address corresponding to your hostname then you can use this command
hostname -i
Most of times I use virt-manager to manage VMs but sometimes, I have to manage VMs on other hosts over ssh when connected over VPN or while I am working remotely. GUI like virt-manager thus becomes slow, and hence I like to use cli commands and nothing is better than virsh. But here is simple script that I use sometimes to manage the VMs with CLI based menu. Hope you find it useful.
Continue readingI was trying to setup a simply webservice to reply to POST requests. Earlier this was being done in tomcat which seem a little overkill to me since I already had a webserver up and running. So, a quick c program to respond to request is all that I needed. And here is the result.
/*
* =====================================================================================
*
* Filename: Login.cpp
*
* Description:
*
* Version: 1.0
* Revision: none
* Compiler: gcc
*
* Author: Amit Agarwal (),
* Organization:
*
* == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == =
*/
#include <stdio .h>
#include <stdlib .h>
#include <string .h>
#define MAXLEN 1024
#ifdef DBG
#define DEBUG(a,b) fprintf(stderr, a, b);
#else
#define DEBUG(a,b)
#endif
#define HEAD "n"
#define TAIL ""
int main(void)
{
char input[MAXLEN];
char * data;
char*lenstr;
long len;
printf("%s%c%cnn",
"Content-Type:text/xml;charset=iso-8859-1", 13, 10);
// len = getenv("QUERY_STRING"); // This is for GET
lenstr = getenv("CONTENT_LENGTH");
DEBUG( "Length string is %sn", lenstr);
if(lenstr == NULL || sscanf(lenstr,"%ld",&len)!=1 || len > MAXLEN)
printf("Error in invocation - wrong FORM probably.");
DEBUG( "Length is %ldn", len);
{
int count=0;
while ( count < len )
input[count++] = getchar();
input[count]='?';
DEBUG ( "Read characters = %dn", count)
}
//fprintf(stderr, "VAlue is %sn", input);
///unencode(input + 5 , input + len, data);
data = input;
DEBUG("Data value is %sn", data);
printf(HEAD);
printf("Everything else goes heren");
printf(TAIL);
fprintf(stderr, "Sent resp: tid[%s], eaid[%s], tcode[%s]n", tid, eaid, tcode);
}
</string></stdlib></stdio>
Additionally, the makefile:
Continue readinggit has a very simple solution to see all the commits in a graphical form. If you need to understand all the commits history all you need is
git graphviz|dot -Tpng -o /tmp/a.png
This will generate a file called /tmp/a.png which will diplay the complete commit history.
firewalld by default does not allow packets that are dropped. In some cases, you need to find out if some packet is being dropped or not. For doing so you may want to enable logging of dropped packets with the following command:
sudo firewall-cmd --set-log-denied=all
This will enable logging all the packets and help you figure out if firewalld is dropping the packet.
Sometime back I noticed that whenever I run my favourite command, viz.
journalctl -xn -f -l
it was taking more time than usual. So, I thought to dig more into it and finally found that the following command:
sudo journalctl --disk-usage
showed that journalctl was using some huge space in tune of about 4GB. So, the solution was simple, vaccum the journal entries and the command to do so is :
sudo journalctl --vacuum-size 90M
Checking journalctl size after that confirms the size is reduced and after that indeed the above journal command takes no time 🙂
Continue readingIf you need to have a quick bash shell in sandbox with not network as well, then the most simple command I could find so far is:
sudo virt-sandbox -c lxc:/// /bin/bash
For this you will need to have libvirt-sandbox installed which you can do with the following command:
sudo yum install libvirt-sandbox