Site Master Page Vs System Master Page or CustomMasterUrl vs MasterUrl in SharePoint

I saw people are struggling to update the correct master page because lack of understanding about which matser page renders the page.In SharePoint there is two master master pages which mainly control the look and feel of the site.

Site Master page

This master page is used by all publishing pages in a site, so when we are working with publishing pages update this master pages.This is available as a property of the object SPWeb , you could access like SPWeb.CustomMasterUrl

You could update it by following powershell script

$web = Get-SPWeb http://localhost
$web.CustomMasterUrl = "/_catalogs/masterpage/MysiteV4.master"
$web.Update()

System Master Page

This master page is used by all forms and view pages in this site. For example if you got home page of library (AllItems.aspx) this master page is used.This is available as a property of the object SPWeb , you could access like SPWeb.MasterUrl .

You could update it by following powershell script

$web = Get-SPWeb http://localhost/
$web.MasterUrl = "/_catalogs/masterpage/MysiteSystemV4.master"
$web.Update()