Author Archive

During user login, a Linux box might show message of the day(motd), new email, or package updates information. This is particularly common in Ubuntu boxes. In some cases, you want to prevent all these messages from being displayed as it could be delaying your login for instance.

Solution – Create a file named .hushlogin in the user’s home directory.

A typical login to an Ubuntu box might look like this –

[daniel@kauai etc]$ ssh practice
daniel@practice's password: 
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-39-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Sat Jan 10 11:37:24 EST 2015

  System load:  0.0                Processes:           290
  Usage of /:   46.1% of 45.15GB   Users logged in:     1
  Memory usage: 13%                IP address for eth0: 192.168.10.206
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

168 packages can be updated.
63 updates are security updates.

You have new mail.
Last login: Sat Jan 10 11:37:26 2015 from linux.local

To suppress all this information, create a .hushlogin file in the users home directory and log out and login back –

daniel@linubuvma:~$ touch ~/.hushlogin

daniel@linubuvma:~$ exit
logout
Connection to practice closed.

[daniel@kauai etc]$ ssh practice
daniel@practice's password: 

daniel@linubuvma:~$ 

How to be financially independent.

For clarity I am going to define financial independence by what it is not first. There are different meanings of financial independence out there, for the sake of this post I will narrow down the scope. It is not objective definition but hopefully you get the gist of it once you finish reading this article. Financial independence does not mean full retirement where you spend the rest of your life travelling or relaxing in some pristine beaches. Neither does it mean just being out of debt or having a few months of emergency fund.

You might consider yourself to be financially independence once you get to the point where you no longer have to panic if you were to lose your job right now, or you don’t lose sleep about upcoming day to day expenses. You will reach it once you have your basic needs easily met from what your assets generate. It is possible that you might have to work, but you will no longer pick jobs on which one pays more, or keep on staying in a toxic work environment. You will have plenty of time to focus on your hobbies and personal development, and might actually end up doing creative work from your imagination, not because someone told you to do so under a deadline. With some of the tips given below, it is achievable and it is worth it.

Rule of thumb – Multiply your annual expenses by 25. If that number is closer to or better yet less than your net worth, then consider yourself financially independent. Or if 4% (7% market gain – 3% inflation) of your net worth is closer to (or less higher than) how much you need per year, you are financially independent.

1. Pay all your debt and stay out of it – financial independence and debt do not go together. There are exceptions of course, where the debt is considered as an investment such as going to medical school. No credit card debt, no mortgage for a house you can’t afford, no auto loans, no student debt for a worthless degree. Make sure to pay the ones with high interest rates, especially credit card debt. Pay it all and stay out of it! Good debt vs. bad debt.

2. Live below your means – this is no-brainer. If you are spending more than what you are bringing it, then say bye bye to financial independence. Frugal living is not death sentence.

3. Cut expenses – go check all your expenses and eliminate the ones you don’t need. Pay special attention to multiple small fee subscriptions or recurring ones. This is death by thousand cuts, they add up. Think of all the expenses that you can cut.

4. Stay healthy – Health care is expensive, I have read somewhere that sixty percent of personal bankruptcies are due to health care related expenses. Besides, you won’t enjoy your free time if you are not healthy. So take good care of your health – eat healthy food, exercise, sleep well and don’t stress out. Be healthy.

5. Have a marketable skill – one way to earn more money is to be skillful in an area which is in high demand. Finding a job will be easier and the pay would be better. This does not necessarily require college degree, there are many professions with plenty of self taught professionals. Continuously update your skills, all you need is access to the Internet and by this I don’t mean Facebook! Fastest growing occupations.

6. Take advantage of 401k, Roth IRA or traditional IRA – If your employer provides 401k, contribute to the maximum allowed. Similarly with Roth IRA, you can do this one on your own. Create an account with Vanguard or Fidelity, and start investing in low cost mutual funds, the risk is minimal. If you are adventurous you can invest in real estate, peer to peer lending etc. How to open an IRA.

7. Build passive sources of income – Put your money where it works for you, it should generate some dividend or interest. Don’t stash it in a zero interest saving account, eventually inflation alone will wipe it out. So be thoughtful of where you put your money. CD rates.

8. Have multiple income streams – Diversifying is good, make sure you don’t put all your eggs in one basket. If you have any free time – besides what you set aside for fun, family time, socializing etc. – you can use it to do freelancing, tutoring, selling stuff online and more. The passive sources of income mentioned above can fall into this category as well. Some tips on how to generate extra income.

9. Don’t give in to peer or social pressure – Stick to your plan even if your immediate circle of friends or family members have a different life style and pressure to make decisions that hinder your financial independence journely. This means no new car every two or three years, in fact buying a new car is a bad financial decision in most cases. Save for a car and pay cash for a slightly used car. Avoid keeping Up With The Joneses’, it might actually keep you broke.

10. Give – this might sound non sequitur, but remember the objective of financial independence is not the accumulation of money for the sake of money. Use money as a means to an end – in this case to personal freedom, free time, accomplishing your dreams – not hoarding money. Giving releases us from the power of money.Help the less fortunate folks. Volunteer.You are not an island. No one did it on their own, we all had someone in the past who steered us to the right direction be it a parent, relative, teacher, stranger etc. Be part of something by giving your money, time etc.

Note – these are rules of thumb and generalizations. If you have a justifiable reason and you surely know what you are doing, you can break some of these rules.

Some other sites to visit, I don’t fully agree with all the opinions on these sites, but I found them helpful in one way or another –
Mr. Money Mustache
Retire by 40
Can I retire yet.
Financial samurai
The Millionaire next door.

How to interact with web services.

Curl is the defacto CLI tool for interacting with web services and other non-HTTP services such as FTP or LDAP. Linux or Unix system administrators as well as developers love it for its ease of use and debugging capabilities. When you want to interact with web services from within scripts, curl is the number one choice.For downloading files from the web, wget is commonly used as well, but curl can way more.

Since enough has been written about curl, this post is about a tool which takes interaction with web services a lot more human friendly, with nicely formatted and colored output – httpie. It is written in Python.

Installation

apt-get  install httpie     #(Debian/Ubuntu)
yum install httpie          #(Redhat/CentOS)

Note – although the package name is httpie, the binary file is installed as http.

When troubleshooting web services, the first thing we check is usually http request and response headers –

daniel@lindell:/$ http -p hH  httpbin.org
GET / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: httpbin.org
User-Agent: HTTPie/0.9.2

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 12150
Content-Type: text/html; charset=utf-8
Date: Thu, 22 Dec 2016 01:32:13 GMT
Server: nginx

Where -H is for Request headers, -h is for response headers. Similarly, -B is for request body and -b is for response body.

We can also pass more complex HTTP headers, in this case “If-Modified-Since”, the web server will return 304 if the static content i am requesting has not been modified. Moving the date a few years back, it will respond with 200 status code.

daniel@lindell:/$ http -p hH http://linuxfreelancer.com/wp-content/themes/soulvision/images/texture.jpg "If-Modified-Since: Wed, 21 Dec 2016 20:51:14 GMT"
GET /wp-content/themes/soulvision/images/texture.jpg HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: linuxfreelancer.com
If-Modified-Since:  Wed, 21 Dec 2016 20:51:14 GMT
User-Agent: HTTPie/0.9.2

HTTP/1.1 304 Not Modified
Connection: Keep-Alive
Date: Thu, 22 Dec 2016 01:39:28 GMT
ETag: "34441c-f04-4858fcd6af900"
Keep-Alive: timeout=15, max=100
Server: Apache/2.2.14 (Ubuntu)

daniel@lindell:/$ http -p hH http://linuxfreelancer.com/wp-content/themes/soulvision/images/texture.jpg "If-Modified-Since: Wed, 21 Dec 2008 20:51:14 GMT"
GET /wp-content/themes/soulvision/images/texture.jpg HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: linuxfreelancer.com
If-Modified-Since:  Wed, 21 Dec 2008 20:51:14 GMT
User-Agent: HTTPie/0.9.2

HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: Keep-Alive
Content-Length: 3844
Content-Type: image/jpeg
Date: Thu, 22 Dec 2016 01:39:37 GMT
ETag: "34441c-f04-4858fcd6af900"
Keep-Alive: timeout=15, max=100
Last-Modified: Sat, 01 May 2010 22:23:00 GMT
Server: Apache/2.2.14 (Ubuntu)

httpie also makes passing JSON encoding as well as POST/PUT methods a lot easier. No need for formatting your payload as JSON, it defaults to JSON. Debugging is easier to with -v option, which shows the raw wire data –

daniel@lindell:/$ http -v PUT httpbin.org/put name=JoeDoe email=joedoe@gatech.edu
PUT /put HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 48
Content-Type: application/json
Host: httpbin.org
User-Agent: HTTPie/0.9.2

{
    "email": "joedoe@gatech.edu", 
    "name": "JoeDoe"
}

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 487
Content-Type: application/json
Date: Thu, 22 Dec 2016 01:44:20 GMT
Server: nginx

{
    "args": {}, 
    "data": "{\"name\": \"JoeDoe\", \"email\": \"joedoe@gatech.edu\"}", 
    "files": {}, 
    "form": {}, 
    "headers": {
        "Accept": "application/json", 
        "Accept-Encoding": "gzip, deflate", 
        "Content-Length": "48", 
        "Content-Type": "application/json", 
        "Host": "httpbin.org", 
        "User-Agent": "HTTPie/0.9.2"
    }, 
    "json": {
        "email": "joedoe@gatech.edu", 
        "name": "JoeDoe"
    }, 
    "origin": "192.1.1.2", 
    "url": "http://httpbin.org/put"
}

I have touched just the surface of httpie here, please feel free to get more detailed information on the github repo. It has built-in JSON support, form/file upload, HTTPS, proxies and authentication, custom headers, persistent sessions etc.

Article on wget and curl from previous post.

In these series of Docker tutorials, i will walk you through a hands on experimentation with Docker. The operating system I am working on is Ubuntu 16.04.

Docker is a containerization technology which allows deployment of applications in containers. Its advantage is speed, a docker container hosting an application would be up and running in a few milliseconds.

As opposed to Virtual machines, containers run on top of the host OS. They share the host kernel. Thus you can only run a Linux container on a Linux host or machine.

Docker Installationuse this link for instructions on how to install Docker.

Installation Limitation – Docker runs on 64-bit OS only and it supports Linux kernel version 3.10 and above. You can verify this using the commands below –

root@lindell:~# arch
x86_64
root@lindell:~# uname -r
4.4.0-47-generic

Docker – terminology

    Images – are the building blocks of Docker. Once created or built, they can be shared, updated and used to launch containers. No image, no containers.

    Containers – are images in action. Containers give images life, containers are image plus all the ecosystem the Operating system need to run the application.

    Registry – where images are stored. They can be public or private. DockerHub is a typical example of public registry.

    Data volumes – persistent storage used by containers.
    Dockerfile – file containing instructions to be read by Docker for building a Docker image.

    Node – physical or virtual machine running Docker engine.

Our first Docker container
After installing docker and making sure that the Docker engine is running, run the commands below to check the Docker images(‘docker images’) available or if any Docker containers are running(‘docker ps’). Both commands should not return any results if this is a first time installation.

root@lindell:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
root@lindell:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED
             STATUS              PORTS               NAMES

The next step is to get a Docker image from Docker Hub. For security reasons, we are going to use only official images –

root@lindell:~# docker search --filter=is-official=true ubuntu
NAME                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu               Ubuntu is a Debian-based Linux operating s...   5238      [OK]
ubuntu-upstart       Upstart is an event-based replacement for ...   69        [OK]
ubuntu-debootstrap   debootstrap --variant=minbase --components...   27        [OK]


root@lindell:~# docker run -ti ubuntu /bin/bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu

b3e1c725a85f: Pull complete
4daad8bdde31: Pull complete
63fe8c0068a8: Pull complete
4a70713c436f: Pull complete
bd842a2105a8: Pull complete
Digest: sha256:7a64bc9c8843b0a8c8b8a7e4715b7615e4e1b0d8ca3c7e7a76ec8250899c397a
Status: Downloaded newer image for ubuntu:latest

root@d1b13e2c3d3f:/# docker images
bash: docker: command not found

root@d1b13e2c3d3f:/# hostname -f
d1b13e2c3d3f

root@d1b13e2c3d3f:/# uname -r
4.4.0-47-generic

We just downloaded an official Ubuntu image and started an Ubuntu container by running /bin/bash inside the newly started container. The ‘-ti’ option runs bash interactively(-i) by allocating a pseudo-TTY(-t).

Note that – the kernel version on the container is the same as the host’s kernel version. During first run, Docker will try to find Ubuntu image in our local storage, if it can’t find it, it downloads it from Docker Hub. On next runs, starting the containers will be much faster.

If we check the images and processes running now –

root@lindell:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              104bec311bcd        5 days ago          129 MB
root@lindell:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
d1b13e2c3d3f        ubuntu              "/bin/bash"         About a minute ago   Up About a minute              

At this point, if we exit from the container, docker ps will no longer show the container as it has been terminated. We use ‘docker ps -a’ instead to view it and then use ‘docker start’ command to start the container –

root@d1b13e2c3d3f:/# exit
exit


root@lindell:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

root@lindell:~# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
d1b13e2c3d3f        ubuntu              "/bin/bash"         5 minutes ago       Exited (0) 5 seconds ago

root@lindell:~# docker start d1b13e2c3d3f
root@lindell:~# docker exec -ti d1b13 /bin/bash
root@d1b13e2c3d3f:/# uptime
 01:39:46 up  1:18,  0 users,  load average: 0.39, 0.39, 0.37
root@d1b13e2c3d3f:/# 
               

On Part 2 of quick introduction to Docker, we will walk through using Dockerfile to automate image creation. We will see how quickly we can go from development to deployment.

You might also find some of the questions I answered in Stackoverflow about Docker.

The future of Net Neutrality

FCC chairman Tom Wheeler will be resigning next month, and this is not a good news for the proponents of Net Neutrality. Tom Wheeler was the driving force behind the reclassification of broadband internet access as a telecom service. The open internet rules that the FCC approved were a great victory for the supporters of Net Neutrality. With the chairman’s departure, the fight will still continue. The opponents of Net Neutrality, primarily cable/telecom companies, did not like the reclassification of broadband Internet as a telecom service, as that will impose more government and public oversight of the Internet.

For many people, the idea of Net Neutrality is still not clear. In its simplest form, it is the principle that all packets or network traffic should be treated equally. If you pay a monthly fee of $50 to your cable company for a given bandwidth, the cable company should not interfere with your browsing. As far as the cable company is concerned, whether you visit to site A or B, or use your bandwidth to download some media, they should treat it equally. Of course, illegal sites can be blocked per the legality of content in a given country. Basically the pipe has to be agnostic of the type of traffic, source or destination of traffic etc.

That is how the Internet is right now in practice, but the telecom companies want to change it. In my view, it is how the Internet should be. An open Internet encourages innovation at the application/content layer, as any new entrants whether start ups or a kid in a basement can launch a successful product without negotiating with the cable companies. Without Net Neutrality, the cable companies can pick and chose the winners, as they will practically be the gate keepers of content. There is no limit to the amount of control they will have over the Internet, a future with no Net Neutrality is a future of multi-tiered and multi-priced Internet. What that mean is the price as well as quality of your Internet service might vary on any of the following reasons –

1. What site are you visiting? May be Comcast made a deal to priority google.com.
2. What is your source IP address? This identifies your location, AT&T might have a deal with a certain municipality or owner of an IP block.
3. From which country are your browsing? Cable company has a deal with a foreign government.
4. What type of media or content are you viewing? text/audio/video? Cable company want to block a competitor’s streaming video.
5. What time of the day or day of the week are you browsing? Cable company has a popular show that it streams through a recently acquired media company during a certain time of the day.
6. What browser are you using? Internet explorer, Firefox, Safari, Chrome? Browser maker software company has a deal with cable company.
etc.

Any publicly identifiable information that the cable companies can get from your browsing can be used for pricing purposes.

This is how I analogize Net Neutrality – imagine all the Interstate roads were owned by private companies, say companies X, Y and Z. Without any regulatory rules, the Interstate owners can negotiate with car manufacturers on what types of cars take the fastest or even safest lanes. If Ford pays company X more, the “road owner” would allow only Ford cars to take the HOV lanes, or reserve more lanes for Ford cars while limiting drivers of other car types to the slowest lanes. As a prospective car owner, you won’t just pick a car based on just mileage or driving habits, you have to do extra research to find out what kind of deals the car manufacturer has made with the road owners. Travelling long distance would be a nightmare, as the various segments of the Interstate would be owned by different companies, and companies X would charge you at a different rate than companies Y and Z. So by supporting Net Neutrality, we are agreeing to the principle that the type of car you drive should not matter, we should all abide by the same rules. This does not mean that someone who can afford a high quality car can drive faster than an older car, in the same manner that if you have a lower bandwidth package with your cable company, you might not be able to view high quality movies smoothly.

Per opensecrets.org, here is the list of the top spenders on lobbying for the year 2016, surely enough the telecom and cable companies or associations are in the top list.

 

US Chamber of Commerce $79,205,000
National Assn of Realtors $45,255,769
Blue Cross/Blue Shield $19,058,109
American Hospital Assn $15,454,734
American Medical Assn $15,290,000
Pharmaceutical Research & Manufacturers of America $14,717,500
Boeing Co $12,870,000
AT&T Inc $12,660,000
National Assn of Broadcasters $12,118,000
Alphabet Inc $11,850,000
Business Roundtable $11,530,000
Comcast Corp $10,510,000
Lockheed Martin $10,380,488
Dow Chemical $10,295,982
Southern Co $10,090,000
Northrop Grumman $9,420,000
National Cable & Telecommunications Assn $9,230,000
FedEx Corp $9,221,000
Exxon Mobil $8,840,000
Amazon.com $8,624,000

Support Net Neutrality at Freepress.net.

Check link below for a great resource which shows lobbying spend of 51 internet service providers (ISPs) dating back to 1998 –

How much does your ISP spend on lobbying?

Splunk offers a free version with a 500 MB per day indexing limit, which means you can only add 500 MB amount of new data for indexing per day. This might work for most home users, the only problem is the first time you install Splunk, you might configure it to injest your existing log files which most likely are above 500 MB if you consolidate your logs in a syslog server like I do. In this case, Splunk will stop indexing any data above 500 MB per day. During first time indexing, make sure your existing data or log files are below this limit. If for some reason, you ask Splunk to injest way more than 500 MB of data and you want to start fresh, run the following command to clean up the data –

 splunk  clean eventdata 

You can find the details on Splunk Free on this link.

Here is the series of commands I had to execute to clean up the event data –

[daniel@localhost]$ pwd 
/opt/splunk/bin
[daniel@localhost]$ sudo -H -u splunk ./splunk  clean eventdata
In order to clean, Splunkd must not be running.

[daniel@localhost bin]$ sudo -H -u splunk /opt/splunk/bin/splunk stop
Stopping splunkd...
Shutting down.  Please wait, as this may take a few minutes.
..                                                         [  OK  ]
Stopping splunk helpers...
                                                           [  OK  ]
Done.

[daniel@localhost bin]$ sudo -H -u splunk ./splunk  clean eventdata
This action will permanently erase all events from ALL indexes; it cannot be undone.
Are you sure you want to continue [y/n]? y
Cleaning database _audit.
Cleaning database _blocksignature.
Cleaning database _internal.
Cleaning database _introspection.
Cleaning database _thefishbucket.
Cleaning database history.
Cleaning database main.
Cleaning database summary.
Disabled database 'splunklogger': will not clean.

[daniel@localhost bin]$ sudo -H -u splunk /opt/splunk/bin/splunk start
Checking prerequisites...
	Checking http port [8000]: open
	Checking mgmt port [8089]: open
	Checking appserver port [127.0.0.1:8065]: open
	Checking kvstore port [8191]: open
	Checking configuration...  Done.
	Checking critical directories...	Done
	Checking indexes...
		Validated: _audit _blocksignature _internal _introspection _thefishbucket history main summary
	Done
	Checking filesystem compatibility...  Done
	Checking conf files for problems...
	Done
All preliminary checks passed.

Starting splunk server daemon (splunkd)...  
Done
                                                           [  OK  ]

Waiting for web server at https://127.0.0.1:8000 to be available.. Done


If you get stuck, we're here to help.  
Look for answers here: http://docs.splunk.com

The Splunk web interface is at https://localhost:8000