Tech Junkie Blog - Real World Tutorials, Happy Coding!

Latest Posts

Monday, January 14, 2019

Sometimes you don't want to do everything with the root account.  So there are some super users who you trust as administrators.  For those users you want them to be able to run the sudo command.  A sudo command allows a user to run commands with root privileges without logging in as root.
For example something like this sudo yum update unlike the su command which prompts you for the root password.  The sudo command prompts you for the password of the logged in user.

In order for the sudo to work we have to configure the /etc/sudoers file.  There is a special command for editing the sudoers file and it's the visudo command.  This command should be used at all times when editing the sudoers file instead of a text editor.



The sudoers file contains command aliases for different command sets.  For example the alias for networking is

Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

So let's say we created a group called networkadmin and want the group to be responsible for networking we can put the entree %networkadmin ALL = NETWORKING

By default the wheel group has all the access to the commands

%wheel ALL=(ALL) ALL

If we want to assign all the commands to an individual we can do the same thing

jason ALL = (ALL) ALL



What we can do is give jason access to all the commands because he is the tech lead, but only give the developers commands for SOFTWARE, and SERVICES

Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum
Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig

We could breakup the users into User_Alias which is a group that exists in the sudoers file, that we can mix and match users into these aliases.

For example let's we have  four developers dora, john, todd, jason.  Two of them are junior developers and the other two are senior developers.

We could create a user alias of JUNIORDEV and SENIORDEV, here is how it would look

User_Alias        JUNIORDEV = todd, john
User_Alias        SENIORDEV = jason, dora

Now we can assign the User_Alias to the Cmnd_Alias

JUNIORDEV    ALL=SOFTWARE

SENIORDEV    ALL=SOFTWARE,SERVICES


As you can see the junior developers only have access to the commands that are in the software command alias, while the senior developers have access to both the SOFTWARE and SERVICES























Similar Posts:



Thursday, January 10, 2019

One of the first thing you would do in web development is to link an external Cascading Stylesheet to an HTML document.  As a matter of fact bootstrap would not work if you didn't link the bootstrap.css file in your HTML document.  Linking an external document is easy enough you often see the link like this

    <link href="Content/bootstrap.css" media="all" rel="stylesheet" type="text/css"></link>
    <script src="Scripts/bootstrap.js"></script>

Now let's break it down link attributes, there are four possible attributes for the link tag.

They are the following:
  • rel (required) - Relations, relationship to this page.  For CSS stylesheets its "stylesheet"
  • type (optional) - is the type of the link, "text/css" is the type for CSS stylesheets
  • href (required) - is the location of the resource, it could a relative path or an actual URL like a CDN
  • media (optional) - with this attribute you can specify which media the stylesheet is meant for.  For example the media attribute can have the "projector" value.

Wednesday, January 9, 2019

Up until this point all we did was take care of the plumbing, MongoDB for the database, AngularJS as the application framework, expressJS for hosting, and Heroku as deployment infrastructure in the cloud. Whew! It feels like I am spitting out development hastags and buzzwords.  But, you know what they always say "it takes a village to build a SPA application".  Well they didn't say that, but they should! Who are they anyways?  The software engineer gods?  Or god forbid the mythical "full stack developers!!  Fear them the full stack developers!  But I don't know who they are, you ask.  Well they are just awesome! God says.  They are 10x!  Wow 10x, you said to yourself.  They must be good!  Hahaha  I just love the buzzwords.  It's entertaining.  I would never say I am a full stack developer.  I am just a developer who knows a lot of stuff.

In this post we are going to take a step back and start working on the actual application and take the plumbing out of the equation for a while.

As with any application at the center of it all is the question.  What does the application do?
Since our application is banking application, we will create objects that are in the banking domain.  This is called a domain driven design.  We are not going to follow the domain driven design (DDD) to a T, but we will follow the spirit of it.

First things first, we need a bank.  Follow the steps below to create the bank object.

  1. Open the "ACMEBank" application with your favorite IDE
  2. Add the file bank.js to the models folder 










Tuesday, January 8, 2019

In this post we are going to install Ninject which is a lightweight IOC container.  You can think of an IOC container as a magic toolbox that gives you the tools that you need when you need it.  Hence its called dependency injection, meaning it injects the dependencies that you need.  As with any IOC container there needs to be a mapping between the interfaces and the implementation.  That's where Ninject comes in.

First let's install Ninject with Nuget. here are the steps:

1. Open the Nuget Management Console and type in the following command

Install-Package Ninject -Version 3.2.2
Install-Package Ninject.Web.Common -Version 3.2.2
Install-Package Ninject.Mvc3 -Version  3.2.1

Don't worry about the package call Ninject.Mvc3 it works perfectly with MVC 5.


2.  Now we are going to set up Ninject by first creating an infrastructure folder.  This folder will contain all of the plumbing stuff that we would need for our application.  In the folder we are going to create an Ninject dependency resolver.  Its just what the name implies the dependency will resolve the dependencies that we need, or you call it the mappings and configurations for the dependencies.
So create a folder call "Infrastructure" and add a new file call, "DependencyMappings" inside the folder.




Monday, January 7, 2019

In the previous post we created a user called "John Wallace", in this post we are going to add John and Jason into the developers group.  In any system you want to group users into groups so that you can easily assign constraints and privileges to a group of user instead of doing it one at a time.

To create a group call developers type in the following command:


  1. su to get root access
  2. groupadd developers to add the group developers 





3.  Now we want to assign John and Jason to the developers group, with this command useradd john -G developers and repeat the command with jason

As you can see we used the usermod command instead of the useradd command because john, and jason already exists.

Friday, December 21, 2018

I think I've gotten rid of all the spams on my blog.  It was quite an effort.  I am not going to be mean about it.  I know the spammers are just trying to do their job.  But just keep in mind that the people who comes to my blog are people who wants to learn about coding.  Heck I come here just for self reference.  So you can still spam is you want.  But, I will delete your spam.  I just hope people will learn from this blog. It's not the bible, but I hope you are interested in coding because of it.

Friday, December 14, 2018

The best way to connect to a virtual machine in Azure if it's a Windows operating system is through a Remote Desktop Connection or RDP.  In this post I am going to show how to set the Azure portal virtual machine to accept RDP connection from your desktop.

Here are the steps to set up RDP:

1. Log into Azure portal portal.azure.com with your Microsoft Azure account
2. Click on the "Virtual Machines" link, and select the virtual machine that you want to connect to via RDP








3. Select "Networking"













Thursday, December 13, 2018

It is time consuming and a lot of work to set up your own data science virtual machine locally.  If you don't mind the cost, the alternative to is to setup a data science Virtual Machine in Azure and let Azure take care of the plumbing such as the hardware requirements and etc, because a data science Virtual Machine is a little beefier than an regular mainstream laptop.

Here are the steps to create a data science virtual machine in Microsoft Azure:


1. Log into http://portal.azure.com with your Microsoft Azure account
2. Click on "Virtual Machines"

Virtual Machines link in Microsoft Azure Portal
Click on "Virtual Machines" link




















Monday, October 8, 2018

In our previous post we type in the yum command yum update to update the entire CentOS server.  But the most common operation that you will perform with yum that you will perform is to install, update, and remove an individual package.

In this post we will install, update and remove the php package.

Here are the steps to install, update, and remove php

1. Open a terminal session
2. Type yum install php, type y when asked for a confirmation