Archive for the ‘Technical’ Category

Linux – User Information

February 19, 2013

The /etc/passwd file contains the user’s information. The
fields include the user name, x for password, user identifier, group identifier, gecos for comment, home directory, and shell. The colon is for separating the fields.

The /etc/shadow file contains the encrypted password.

The /etc/group file contains the group information. There are four fields; these are the group name, password, identifier, and a comma separated list of members.

Maintaining User Information from the Command-Line

useradd

To add a single user, to the system.

usermod

To modify the information, for an existing user.

userdel

To remove an existing user.

groupadd

To add a single group, to the system.

groupdel

To remove an existing group.

groupmod

To modify the information for an existing group.

Maintaining User Information using the Graphical User Interface (GUI)

Fedora, system-config-users.

RHEL, redhat-config-users.

openSuSE/SEL Linux, yast2 users.

Ubuntu, sudo users-admin.

Users and Access Permissions

The four types of permissions are read, write, execute, and none.

The three user types are owner, group, and everyone.

The chmod command is for altering file permission.
For example, chmod 777 filename, will give everyone, global access.

 chmod 777 <file-name> 

The stat command is similar to ls -la — gives file permission as octal

 
     stat -c "%a %n" *

The passwd command is for changing password.

The id command will offer user information.

Reference

  1. Soyinka, A. (2009). Linux Administration: A Beginner’s Guide. McGraw-Hill.

Windows Presentation Foundation (WPF) Command-Line Compile Using MSBuild

August 16, 2012

Follow the steps below to build a WPF application using MSBuild.

App.xaml

<Application x:Class=”WpfApplicationHelloWorld.App”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
StartupUri=”MainWindow.xaml”>
<Application.Resources>

</Application.Resources>
</Application>

App.xaml.cs

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace WpfApplicationHelloWorld
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
    }
}

MainWindow.xaml

<Window x:Class="WpfApplicationHelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid Background="IndianRed">
        <Label Height="28" Margin="77,28,81,0" Name="lblHello" 
               VerticalAlignment="Top" Opacity="0.5" 
               Background="SlateGray" Foreground="White">
               Label&lt/Label>
        <Button Height="23" Margin="77,66,126,0" Name="btnHello" 
                VerticalAlignment="Top" Click="btnHello_Click" 
                Opacity="0.5">Say Hello&lt/Button>
    &lt/Grid>
</Window>

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace WpfApplicationHelloWorld
{
    /// 
    /// Interaction logic for MainWindow.xaml
    /// 
    public partial class MainWindow : Window
    {
		private void btnHello_Click(object sender, RoutedEventArgs e)
		{
			lblHello.Content = "Hello WPF!";
		}
    }
}

WpfApplicationHelloWorld.csproj

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
<PropertyGroup>
	<AssemblyName>WPFApplicationHelloWorld</AssemblyName>
	<OutputType>winexe</OutputType>
</PropertyGroup>

<ItemGroup>
	<Reference Include="System" />
	<Reference Include="WindowsBase" />
	<Reference Include="PresentationCore" />
	<Reference Include="PresentationFramework" />
	<Reference Include="System.Data" />
	<Reference Include="System.Linq" />
</ItemGroup>

<ItemGroup>
	<ApplicationDefinition Include="App.xaml" />
	<Compile Include="App.xaml.cs" />
	<Page Include="MainWindow.xaml" />
	<Compile Include="MainWindow.xaml.cs" />
</ItemGroup>

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />

</Project> 

Issue the MSBuild command, at the command-line.

Windows Presentation Foundation (WPF) Command-Line Compile Using CSC

August 16, 2012

If you choose to use csc, the C# compiler, then you may only compile C# files, extensible application markup language (XAML) files are none inclusive.

MyWpfApplication.cs

using System;
using System.Windows;
using System.Windows.Controls;

  class MyWpfApplication : Application
  {
    [STAThread]
    static void Main()
    {
      MyWpfApplication app = new MyWpfApplication();
      app.Startup += AppStartUp;
      app.Exit += AppExit;
      app.Run();
    }

    static void AppExit(object sender, ExitEventArgs e)
    {
      MessageBox.Show("Application exiting.");
    }

    static void AppStartUp(object sender, StartupEventArgs e)
    {
      MainWindow wnd = new MainWindow("WPF Application.", 300, 300);
    }
  }

  class MainWindow : Window
  {
    Button btnExitApp = new Button();

    public MainWindow(string windowTitle, int height, int width)
    {
      btnExitApp.Click += new RoutedEventHandler(btnExitApp_Clicked);
      btnExitApp.Content = "Exit Application";
      btnExitApp.Height = 25;
      btnExitApp.Width = 100;
      this.AddChild(btnExitApp);

      this.Title = windowTitle;
      this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
      this.Height = height;
      this.Width = width;
      this.Show();
    }

    private void btnExitApp_Clicked(object sender, RoutedEventArgs e)
    {   
      Application.Current.Shutdown();
    }
  }

MyWpfApplicationBuild.bat

csc.exe /out:MyWpfApplication.exe /target:winexe MyWpfApplication.cs 

/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\presentationframework.dll" 
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\windowsbase.dll" 
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\presentationcore.dll"