Category Archives: OS

Linux for Windows Server Administrators

Linux for Windows Server Admins

Create and Add Users

Add the user by typing in useradd followed by the desired login name to create. An example would be useradd sburns. This will follow with a few questions to answer and finally create the user. You should now be able to login with PuTTY.  Once logged in as the nonprivileged user, the administrator can elevate their privileges to root.

Using su – will allow a user to switch between users, even root, as long as the user knows the relevant password. The command itself is shorthand for “switch user.” As root an administrator can change to any other user by using the command su simon (or su bill or whomever), assuming the password is known. The “-” switch is used to give all the environmental variables. Using su – without specifying a user will assume you want to switch to the root user. There is a file called /etc/sudoers that holds the configuration for su.

So now we are logged in, lets cover some rudimentary file system-related items. When logged in as a normal user, they would initially be placed in their home directory that was created when the user was created, as was shown before. Move about the system using the command cd, the same as Windows, but remember that Linux is case sensitive.

Using the Linux CLI

With Linux, the backslash becomes a forward slash. To return to your own home directory at any point, just type cd without any arguments. If you are also not sure where you are in the file structure, there is a command called pwd. This command will give the full path to your current location. This is a very useful command, especially if you have many windows open – and double check before using potentially dangerous commands!

Managing Drives with Linux

Linux has no concept of drive letter mappings. Instead drive letters map to what are known as mount points. A very rudimentary example is with CD ROM drives. In Windows, when a CD is inserted, it is mounted as a drive letter. For example, E: This differs in Linux because when you mount a CD, it essentially links the contents of a CD to a folder. Something to bear in mind is that as a rule Linux machines do not auto mount media.

An administrator would have to mount the CD and link it to a folder. Most modern Linux distributions come with a media folder for this purpose. To mount a CD, use the commandmount /dev/cdrom /media. Similarly, to dismount a disk, use the command umount /media. This mounting method is not only for CDs but also for USB sticks, hard disks, and most other media, albeit with some occasional options to specify file systems and such.

To see what is mounted currently, type the command mount. Standard mounts are stored in the file /etc/fstsab. You can modify this file to add additional mount points if you wanted to add additional storage systems at boot. Pro tips: First, make sure you have a backup (use the command cp /etc/fstab fstab.bak). Second, use the mount -a command to verify the fstab file is still valid before you reboot it and find that it isn’t!

Now it might be a good time to introduce you to how most Linux installations are organized from a file and directory perspective.

  • / – root, as in the top level of the disk
  • /home – where users home directories and personal data are located
  • /boot – contains important boot files. You will rarely need to go in here
  • /dev – contains pseudo devices that link directly to the hardware
  • /root – the roots home directory, and where a root can store its files
  • /etc – contains all the configuration files for pretty much everything: networking, services, and some applications
  • /mount – This folder is used to mount NFS mounts and removable media
  • /var – Contains many system components, logs, and miscellaneous
  • /proc – Holds information about running processes.
  • /bin – Contains program files
  • /sbin – Contains system administration binary files

Useful Linux CLI Commands

When working with files, there are some useful commands you can run to help you manage them, as Linux doesn’t tend to do file extensions. If you want to know what type of file you are looking at, you can use the command file file, and it will interrogate the file and provide all the information it can gather.

To view human readable files, you can use the cat command. To edit a file, use the nano editor (for example, nano filename).

If you need to find a file, you can use the locate command. For example, to locate redhat-release (This file holds the release information for the RedHat Build) use the command locate redhat-release.

Other useful commands we can use right now are df, which gives disk space statistics. Usingdf -h may prove a better option as it gives sizes in human readable form of megabytes, gigabytes, and such, rather than an unwieldy size in bytes.

If you want to change your password now, you can use the command passwd. Used without any switches, it will allow you to change the password of the user you are logged in as. If you are logged in as root, you can change other people’s passwords by using the passwdcommand, followed by the username. An example would be passwd stuart.

It is also possible to edit the user setup by use of the command usermod. This will allow you to manage and modify settings on a per-user basis; for example, changing the username or home directory.

via Linux for Windows Server Administrators.

 

 

How to enable Shadow Copy on a shared folder in Windows Server 2012 R2

What Is a Shadow Copy?

shadow copy of a disk volume or shared folder is a snapshot of changes made to files at a given point in time. Snapshots are taken at set intervals, allowing users to restore to a previous version of a file without having to ask IT to restore the file from a backup.

Configure Shadow Copies for a File Share in Windows Server 2012 R2

To configure shadow copies in Windows Server 2012 R2, log on to your file server with a local administrator account and follow the instructions:

  • Switch to the server desktop and open File Explorer by using the icon on the desktop taskbar or by pressing WINDOWS + E.
  • In File Explorer, right-click the volume where the share is located and select Properties from the menu.
  • In the Properties dialog, switch to the Shadow Copies tab.
  • Under Select a volume:, select the volume where you want to turn on shadow copies from the list, and then click Enableshadow1
  • In the Enable Shadow Copies dialog, click Yes to complete the procedure, noting the warning about file servers with high I/O loads.
  • In the Properties dialog, you will see that shadow copies are now enabled for the volume, and when the next snapshot is scheduled to be taken.

Optionally, you can click Create Now to have a snapshot created immediately. There are also options to delete and revert to a previous shadow copy.

  • Now click Settings in the Properties dialog.
  • In the Settings dialog, you can view information about where the shadow copies are located and change the reserved disk space available to the Volume Shadow Service (VSS).
  • The default schedule takes two snapshots daily: Monday to Friday. If you want to change these settings, click Schedule and add or remove scheduled tasks as required.
  • Click OK in the Settings dialog, and again in the Properties dialog to complete the configuration.

Restore Files Using Previous Versions

Windows 7 (and later) clients support restoring from file shares where shadow copies are enabled.

  • From a supported client, or locally from Windows Server, right-click the file you want to revert and select Properties from the menu.
  • In the Properties dialog, switch to the Previous Versions tab.
  • If there is a copy of the file available to restore, it will be displayed in the list, with the time and date of the copy.
  • Select a previous version of your file from the list. shadow2
  • Now you can decide to restore, open, or copy the file as appropriate and follow the instructions.
  • Close the Properties dialog when you’re done.

via How to enable Shadow Copy on a shared folder in Windows Server 2012 R2.

Linux Static IP Address Configuration

You need to update and/or edit the network configuration files.

In this example you will use the following Internet Protocol Version 4 (TCP/IPv4) Properties including IP, default gateway, and preferred DNS servers:

IP address: 192.168.1.10

Netmask: 255.255.255.0

Hostname: server1.cyberciti.biz

Domain name: cyberciti.biz

Gateway IP: 192.168.1.254

DNS Server IP # 1: 192.168.1.254

DNS Server IP # 2: 8.8.8.8

DNS Server IP # 3: 202.54.2.5

           

For static IP configuration you need to edit the following files using a text editor such as vi.

Edit /etc/sysconfig/network as follows, enter:

# cat /etc/sysconfig/network

 

Sample static ip configuration:

NETWORKING=yes

HOSTNAME=server1.cyberciti.biz

GATEWAY=192.168.1.254

 

Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

 

Sample static ip configuration:

# Intel Corporation 82573E Gigabit Ethernet Controller (Copper)

DEVICE=eth0

BOOTPROTO=static

DHCPCLASS=

HWADDR=00:30:48:56:A6:2E

IPADDR=192.168.1.10

NETMASK=255.255.255.0

ONBOOT=yes

 

Edit /etc/resolv.conf and setup DNS servers, enter:

# cat /etc/resolv.conf

 

Sample static IP configurations:

search cyberciti.biz

nameserver 192.168.1.254

nameserver 8.8.8.8

nameserver 202.54.2.5

 

Finally, you need to restart the networking service, enter:

# /etc/init.d/network restart

 

To verify new static ip configuration for eth0, enter:

# ifconfig eth0

# route -n

# ping 192.168.1.254

# ping google.com

 via Linux Static IP Address Configuration.

 

How to back up and restore the registry in Windows

Back up the registry

Windows 8.1 and Windows 8

Swipe in from the right edge of the screen, and then tap Search. Or, point to the upper-right corner of the screen, and then click Search.

In the search box, type regedit.exe, and then press Enter. If you are prompted for an administrator password or confirmation, type the password or provide confirmation.

In Registry Editor, locate and click the registry key or subkey that you want to back up.

Click File > Export.

In the Export Registry File dialog box, select the location where you want to save the backup copy to, and then type a name for the backup file in the File name field.

Click Save.

Windows 7 and Windows Vista

Click Start, type regedit.exe in the search box, and then press Enter. If you’re prompted for an administrator password or confirmation, type the password or provide confirmation.

In Registry Editor, locate and click the registry key or subkey that you want to back up.

Click File > Export.

In the Export Registry File dialog box, select the location where you want to save the backup copy to, and then type a name for the backup file in the File name field.

Click Save.

Windows XP

Follow these steps to create a system restore point:

Click Start, click Run, type %SystemRoot%\system32\restore\rstrui.exe, and then click OK.

On the Welcome to System Restore page, click Create a restore point, and then click Next.

On the Create a Restore Point page, type a name for the restore point and then click Create.

After the restore point is created, click Close.

Note If System Restore is turned off, you receive a message that asks whether you want to turn on System Restore now. Click Yes. Then, in the System Properties dialog box, click to clear the Turn off System Restore check box, click OK, and then repeat this step. For more information, see How to turn off and turn on System Restore in Windows XP.

Restore the registry

Windows 8.1 and Windows 8

Swipe in from the right edge of the screen, and then tap Search. Or, point to the upper-right corner of the screen, and then click Search.

In the search box, type regedit.exe, and then press Enter. If you are prompted for an administrator password or confirmation, type the password or provide confirmation.

In Registry Editor, click File > Import.

In the Import Registry File dialog box, select the location where you saved the backup copy to, click to select the backup file, and then click Open.

Windows 7 and Windows Vista

Click Start, type regedit.exe in the search box, and then press Enter. If you’re prompted for an administrator password or confirmation, type the password or provide confirmation.

In Registry Editor, click File > Import.

In the Import Registry File box, select the location where you saved the backup copy to, click to select the backup file, and then click Open.

Windows XP

Use System Restore to undo registry changes in Windows XP:

Click Start, click Run, type %SystemRoot%\System32\Restore\Rstrui.exe, and then click OK.

On the Welcome to System Restore page, click Restore my computer to an earlier time (if it is not already selected), and then click Next.

On the Select a Restore Point page, click the system checkpoint. In the On this list select the restore point area, click an entry that is named “Guided Help (Registry Backup),” and then click Next. If a System Restore message appears that lists configuration changes that System Restore will make, click OK.

On the Confirm Restore Point Selection page, click Next. System Restore restores the previous Windows XP configuration and then restarts the computer.

Log on to the computer. When the System Restore confirmation page appears, click OK.

via How to back up and restore the registry in Windows.

Set Windows Time Service

By default, Windows-based computers use the following hierarchy:

  • All client desktop computers nominate the authenticating domain controller as their in-bound time partner.
  • All member servers follow the same process that client desktop computers follow.
  • All domain controllers in a domain nominate the primary domain controller (PDC) operations master as their in-bound time partner.
  • All PDC operations masters follow the hierarchy of domains in the selection of their in-bound time partner.

We can set windows time service to sync with External Source.

External source can be NTP server in the word or a domain member.

To set windows time service to sync with NTP server in the word:

  • To set windows servers registry for non-domain server or PDC:

SC01 SC02 SC03 SC04 SC05

  • To set windows servers registry for domain member:

SC06 SC07 SC08 SC09 SC10

  • Useful commands:
  • w32tm /query /source – display the time source.
  • w32tm /config /update – causing the configuration changes to take effect.
  • net stop w32time – stop the time service.
  • net start w32time – start the time service.
  • w32tm /stripchart /computer: uk.pool.ntp.org – view offset chart VS specific source (in this case Vs uk.pool.ntp.org).

sources:

http://support.microsoft.com/kb/816042

http://support.microsoft.com/kb/223184

http://technet.microsoft.com/enus/library/cc773263(WS.10).aspx#w2k3tr_times_tools_dyax

http://technet.microsoft.com/en-us/library/cc773013(WS.10).aspx

GPT

GPT is Short for GUID Partition Table it defines the layout of the partition table on a hard drive. GPT is meant as a replacement to hard drives using a MBR partition table, which have a 2.20TB size limitation and extends upon UEFI. Using GPT a drive could support between 8 and 9.4 ZB depending on the sector size.

To verify that your disks are formatted as GPT
1. Open CMD
2. Run diskpart
3. Type list disk

GPT

WinSXS Folder

The WinSXS folder contains all Windows system components. When Windows installs updates, it drops the new Windows component in the WinSXS folder and keeps the old component in the WinSXS folder. This means that every Windows Update you install increases the size of your WinSXS folder. This allows you to uninstall operating system updates when necessary.
The WinSXS folder at C:\Windows\WinSXS is massive and continues to grow the longer you have Windows installed. This folder builds up unnecessary files over time, such as old versions of system components.
To Reduce the Size of the WinSXS Folder You may refer to the following steps to remove the file under the %windir%\winsxs\ManifestCache\ to release some disk space that the WinSXS folder takes.

1. Run the following commands from an elevated command prompt (Run cmd as admin):
2. Run “Compcln.exe”
3. Net stop trustedinstaller
4. Wait for it to stop and ensure it stops successfully. If you are unable to stop the service, you may need to
restart your machine.
5. Takeown /f %windir%\winsxs\ManifestCache\*
6. Icacls %windir%\winsxs\ManifestCache\* /GRANT administrators:F
7. Del /q %windir%\winsxs\ManifestCache\*
• There are different tools to do this for different Operating systems
• Windows Vista or Windows Server 2008 Service Pack 1: VSP1CLN.EXE
• Windows Vista or Windows Server 2008 Service Pack 2: Compcln.exe
• Windows 7 or Windows Server 2008 R2 Service Pack 1: DISM /online /Cleanup-Image /SpSuperseded or Disk
Cleanup Wizard (cleanmgr.exe)

Please see the folowing PowerShell script that perform these tasks and reduce the WinSXS folder size. The script has been tested on windows2008 servers.


###########################################################################
#
# AUTHOR: Guy Naftaly
#
# NAME: reduce-winsxs
#
# COMMENT: the script delete WinSXS ManifestCache Folder
#
# VERSION HISTORY: 1.0 23/01/2014 - Initial release
#
###########################################################################

$server = ‘server_name’

#Run “Compcln.exe”#

COMPCLN.EXE /quiet

#stop trustedinstaller service on $server#

Get-Service -Name trustedinstaller -ComputerName $server | Stop-Service -Verbose
Get-Service -Name trustedinstaller -ComputerName $server -Verbose

#Delete WinSXS ManifestCache Folder#

Takeown /f C:\Windows\winsxs\ManifestCache\*
Icacls %windir%\winsxs\ManifestCache\* /GRANT administrators:F
Remove-Item C:\Windows\winsxs\ManifestCache\*

#End#