Tech Junkie Blog - Real World Tutorials, Happy Coding!: 2019

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



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.