October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

October 2025
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

How to get the Disk informationhttp://rmohan.com/wp-admin/post-new.phps in linux

# hdparm -I /dev/sda —— information about the IDE/ATA disk (Linux) / disk performance
# fdisk /dev/sda6 —— Display and manipulate the partition table
# smartctl -a /dev/sda1 — Display the disk SMART info
# diskinfo -v /dev/ad2 —- information about disk (sector/size) FreeBSD
# dmidecode ——- dmidecode is a tool for dumping a computer’s DMI(some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components.

To find the mounted file system in our system

# mount | column -t

Linux Kerberos Configuration Guide

SERVER auth.example.com
* yum install krb5-server krb5-workstation pam_krb5
* conf files
– /etc/krb5.conf
– /var/kerberos/krb5kdc/kdc.conf
– /var/kerberos/krb5kdc/kadm5.acl
– /etc/pam.d/system-auth

* kdb5_util create -r EXAMPLE.COM -s
* kadmin.local -q “addprinc admin/admin”
* kadmin.local -q \
“ktadd -k /var/kerberos/krb5kdc/kadm5.keytab kadmin/admin kadmin/changepw”
* kadmin.local -q “addprinc testuser”
* kadmin.local -q “addprinc -randkey host/auth.example.com”
* kadmin.local -q “ktadd -k /etc/krb5.keytab host/auth.example.com”
* chkconfig kadmin on
* chkconfig krb5kdc on
* service kadmin start
* service krb5kdc start
* replication
– http://web.mit.edu/kerberos/www/krb5-1.2/krb5-1.2.5/doc/install.html#SEC48

* LDAP keytab if needed
– kadmin.local -q “addprinc -randkey ldap/auth.example.com”
– kadmin.local -q “ktadd -k /etc/openldap/ldap.keytab ldap/auth.example.com”
* HTTP keytab if needed (case sensitive)
– kadmin.local -q “addprinc -randkey HTTP/auth.example.com”
– kadmin.local -q “ktadd -k /etc/httpd/httpd.keytab HTTP/auth.example.com”
* Firefox with Kerberos:
– From about:config set to .example.com
– network.negotiate-auth.delegation-uris
– network.negotiate-auth.trusted-uris
– run kinit and restart firefox

CLIENT test.example.com
* yum install krb5-workstation pam_krb5
* conf files
– /etc/krb5.conf
– /etc/pam.d/system-auth

* host keytab if needed for ssh
– kinit admin/admin
– kadmin -q “addprinc -randkey host/test.example.com”
– kadmin -q “ktadd -k /etc/krb5.keytab host/test.example.com”

CROSS REALM
* On both KDCs for SUB.EXAMPLE.COM to trust EXAMPLE.COM (one-way trust):
– kinit admin/admin
– kadmin -q “addprinc krbtgt/SUB.EXAMPLE.COM@EXAMPLE.COM”
* echo user@EXAMPLE.COM >> ~user/.k5login on each SUB.EXAMPLE.COM realm host
* use pam_access.so in /etc/pam.d/system-auth to limit access as needed
* add EXAMPLE.COM into [realms] and [domain_realm] in krb5.conf
in SUB.EXAMPLE.COM as needed

Encrypt/Decrypt string with openssl

Sometimes it can be helpfull to encrypt/decrypt strings on Linux.

Of course we can install tools like crypt but is not always available after default installation.

Good thing is that we also have openssl which is nearly always installed on a linux server.

How to encrypt a string with openssl :

$ echo “juicy” | openssl aes-256-cbc -a -salt

enter aes-256-cbc encryption password:

Verifying – enter aes-256-cbc encryption password:

U2FsdGVkX1+0ouL4Ewo0SDicF69rjllKwpKWtGfm9wI=

So how do we decrypt this string ?

$ echo “U2FsdGVkX1+0ouL4Ewo0SDicF69rjllKwpKWtGfm9wI=” | openssl aes-256-cbc -a -d -salt

enter aes-256-cbc decryption password:

juicy

Shutdown or Reboot Sun Solaris

Solaris is usually used as a server operating system. Because of this, you want to make sure that you shut the system down as gracefully as possible to ensure there isn’t any data loss.

For every application that is installed on your server, you should make sure that you have the correct scripts in /etc/rc(x).d to gracefully shut down the service.

Shutdown
You have more than one command option that you can use. The best command is this, executed as root:

shutdown -y -i5 -g0

This will immediately shut the system down. You can also use the older command that still works:

sync;sync;init 5

You can even use:

poweroff

Reboot
If you are trying to reboot the system as opposed to turning it off, you could use:

-y -i6 -g0

Or:

sync;sync;init 6

Or even:

reboot

Manage with Remote Desktop Services

This topic includes sample Windows PowerShell cmdlets that you can use to automate some of the procedures described. For more information, see Using Cmdlets.

1.1. Manage updates automatically with Windows Update

To verify the current Windows Update setting, at a command prompt, run the following command:

Cscript scregedit.wsf /AU /v

To enable automatic updates, run the following commands:

Net stop wsuaserv

cscript scregedit.wst /AU 4

net start wsuaserv

To disable automatic updates, run the following commands:

Net stop wsuaserv

cscript scregedit.wsf /AU 1

net start wsuaserv

If the server is a member of a domain, you can also configure Windows Update using Group Policy. For more information, see http://go.microsoft.com/fwlink/?LinkId=192470. However, when you use this method, only option 4 (“Auto download and schedule the install”) is relevant to Server Core installations because of the lack of a graphical interface. For more control over which updates are installed and when, you can use a script which provides a command-line equivalent of most of the Windows Update graphical interface. For information about the script, see http://go.microsoft.com/fwlink/?LinkId=192471.

To force Windows Update to immediately detect and install any available updates, run the following command:

wuauclt /detectnow

Depending on the updates that are installed, you might need to restart the computer, although the system will not notify you of this. To determine if the installation process has completed, use Task Manager to verify that the Wuauclt or Trusted Installer processes are not actively running. You can also use the methods in the “Viewing installed updates” section to check the list of installed updates.
1.2. Manage updates with WSUS

If the Server Core server is a member of a domain, you can configure it to use a WSUS server with Group Policy. For more information, see http://go.microsoft.com/fwlink/?LinkId=192472.

If the server is not a member of a domain, edit the Registry to configure it to use a WSUS server. For more information, see http://go.microsoft.com/fwlink/?LinkId=192473.

Whenever you configure WSUS settings, be sure to select options that are valid for Server Core installations. For example, since there is no graphical interface, there is no way to receive WSUS notifications. For more control over which updates are installed and when, you can use a script which provides a command-line equivalent of most of the Windows Update graphical interface. For information about the script, see http://go.microsoft.com/fwlink/?LinkId=192471.
1.3. Manage updates manually

To install an update manually, download the update and make it available to the Server Core computer, and then run the following command:

Wusa .msu /quiet
noteNote
Depending on the updates that are installed, you may need to restart the computer, although the system will not notify you of this.

To uninstall an update manually, download the update and make it available to the Server Core computer, and then run the following command:

Wusa /uninstall .msu /quiet
noteNote
Depending on the updates that are installed, you may need to restart the computer, although the system will not notify you of this.

To view installed updates, run either of these commands:

systeminfo

wmic qfe list

You can use Remote Desktop to manage a server in Server Core mode from remote computers by using Remote Desktop Services.
To manage a Server Core server using Remote Desktop

On the Server Core server, run:

cscript C:\Windows\System32\Scregedit.wsf /ar 0

This enables the Remote Desktop for Administration mode to accept connections.

On another computer, click Start, click Run, type mstsc, and then click OK.

In Computer, enter the name of the server that is in Server Core mode, and click Connect.

Log on using an administrator account.

When the command prompt appears, you can manage the computer using the Windows command-line tools.

When you have finished remotely managing the Server Core computer, type logoff in the command prompt to end your Remote Desktop session

1.4 Manage with Remote Desktop Services

You can use Remote Desktop to manage a server in Server Core mode from remote computers by using Remote Desktop Services.
To manage a Server Core server using Remote Desktop

On the Server Core server, run:

cscript C:\Windows\System32\Scregedit.wsf /ar 0

This enables the Remote Desktop for Administration mode to accept connections.

On another computer, click Start, click Run, type mstsc, and then click OK.

In Computer, enter the name of the server that is in Server Core mode, and click Connect.

Log on using an administrator account.

When the command prompt appears, you can manage the computer using the Windows command-line tools.

When you have finished remotely managing the Server Core computer, type logoff in the command prompt to end your Remote Desktop session

noteNote
If you are running the Remote Desktop Services client on a previous version of Windows, you must turn off the higher security level that is set by default in Windows Server 2012. To do this, after step 1, type the following command at the command prompt:cscript C:\Windows\System32\Scregedit.wsf /cs 0

1.5 Switch to Server with a GUI mode

There may be situations in which you need to use the graphical user interfaces available in Server with a GUI mode. You can switch the system to Server with a GUI mode by following the steps below, although a restart is required. For more information about the differences between Server Core mode and Server with a GUI mode, as well as information about the Minimal Server Interface and Features on demand, see Windows Server Installation Options.
To convert from Server Core mode to Server with a GUI mode when the server was initially installed in Server with a GUI mode

Run Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

To convert from Server Core mode to Server with a GUI mode when the server was initially installed in Server Core mode

Determine the index number for a Server with a GUI image (for example, SERVERDATACENTER, not SERVERDATACENTERCORE) using this cmdlet: Get-WindowsImage -ImagePath \install.wim

Run Install-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell –Restart –Source wim:\install.wim:

Alternatively, if you want to use Windows Update as the source instead of a WIM file, use this Windows PowerShell cmdlet:

Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

After you have accomplished the management tasks, you can switch the server back to Server Core mode whenever it is convenient (a restart is required) with the Windows PowerShell cmdlet Uninstall-WindowsFeature Server-Gui-Mgmt-Infra -restart
1.6 Add hardware and manage drivers locally
To add hardware to a server in Server Core mode

Follow the instructions provided by the hardware vendor for installing new hardware:
If the driver for the hardware is included in Windows Server 2012, Plug and Play will start and install the driver.

If the driver for the hardware is not included, proceed with the steps 2 and 3.

Copy the driver files to a temporary folder on the server running a Server Core installation.

At a command prompt, open the folder where the driver files are located, and then run the following command:

pnputil –i –a

Where:

driverinf is the file name of the .inf file for the driver.

If prompted, restart the computer.

To obtain a list of drivers that are installed

At a command prompt, run

sc query type= driver

noteNote
You must include the space after the equal sign for the command to complete successfully.

To disable a device driver

At a command prompt, run

sc delete

Where:

service_name is the name of the service that you obtain by running sc query type= driver

Switch to Server with a GUI mode

There may be situations in which you need to use the graphical user interfaces available in Server with a GUI mode. You can switch the system to Server with a GUI mode by following the steps below, although a restart is required. For more information about the differences between Server Core mode and Server with a GUI mode, as well as information about the Minimal Server Interface and Features on demand, see Windows Server Installation Options.
To convert from Server Core mode to Server with a GUI mode when the server was initially installed in Server with a GUI mode

Run Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

To convert from Server Core mode to Server with a GUI mode when the server was initially installed in Server Core mode

Determine the index number for a Server with a GUI image (for example, SERVERDATACENTER, not SERVERDATACENTERCORE) using this cmdlet: Get-WindowsImage -ImagePath \install.wim

Run Install-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell –Restart –Source wim:\install.wim:

Alternatively, if you want to use Windows Update as the source instead of a WIM file, use this Windows PowerShell cmdlet:

Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart

To configure Windows Firewall to allow MMC snap-in(s) to connect 2012

To allow all MMC snap-ins to connect, run

Enable-NetFirewallRule -DisplayGroup “Remote Administration”

To allow only specific MMC snap-ins to connect, run:

Enable-NetFirewallRule -DisplayGroup “

Where:

Rulegroup is one of the values from the table below, depending on which snap-in you want to connect.

Proxy server with Squid, Dansguardian on CentOS and CBQ

The advantages of using a proxy server within a company, or even a small network are endless, ranging from bandwidth savings, using the cache to a decent content filter.
In this tutorial I will show how to configure a proxy using CentOS.
Resources used

Hardware
In our specific case, I was fortunate to have a fine machine Parruda to implement the proxy, one Xeon Quad with 4Gb Ram and SAS disks. Recalling that the server has to have at least two network interfaces.
System
We use CentOS 5.7 64bit. Reached our needs very well.

Squid
We use Squid to control users and cache.
Dansguardian
What is our dansguardian content filter, the great advantage of it’s own filters by heuristics, which blocks sites based on words within pages.
Iptables
Use iptables to control the IPs of servers that do not pass through squid / dansguardian
CBQ
We bandwidth control using the CBQ, existing on CentOS.
Installation
Installing the System
Download here the latest version of CentOS, always remember to look for a server in Brazil, oo close as possible, there are more chances of having a higher speed. Give preference to the DVD too.
Configure network interfaces, one pointing to the external network (in our case eth0) and one for the internal (eth1). Edit the resolv.conf for your DNS server. If the server is resolving names normally, we will proceed to the next step.
Installing Squid
No mystery here, squid already in the repository for CentOS:
yum install squid
Installing Dansguardian
The Dansguardian is not the repository of CentOS, portanta have to compile it on hand.
Before installing dansguardian, treat some dependencies:
yum install pkgconfig gcc gcc – c + + libstdc + + – devel zlib – devel pcre – make devel wget bzip2 – devel
You may need to include the environment variable pkgconfig:
export PKG_CONFIG_PATH = / usr / lib / pkgconfig
Download the latest version here , unzip it on your server and compile:
tar xzfv dansguardian – 2:10 . 1.1 . tar . gz
cd dansguardian – 2:10 . 1.1
./configure
make
make install
Configuring Squid
Below is my Squid configuration (/etc/squid/squid.conf). Already prepared for basic authentication of squid directed to file (/etc/squid/passwd). And with the cache settings (/var/squid/cache).
# NAME
visible_hostname name rmohan.com

PORT #
http_port 3128 transparent

# CACHE MEMORY
cache_mem 1024 MB
maximum_object_size_in_memory 20 KB
memory_replacement_policy heap GDSF

DISCK CACHE #
cache_dir ufs /var/squid/cache 5000 16 256
cache_replacement_policy heap LFUDA
minimum_object_size 15 KB
maximum_object_size 5 MB
cache_swap_low 90
cache_swap_high 95

# LOG
access_log none
cache_log /var/log/squid/cache.log

AUTH #
auth_param basic program / ??usr / lib64 / squid / ncsa_auth / etc / squid / passwd
auth_param basic children 8
auth_param basic realm Enter your Usu will river and Password
auth_param basic credentialsttl 15 minute

# ACLs
acl all src 0.0 . 0.0 / 0.0 . 0.0
acl manager proto cache_object
acl localhost src 127.0 . 0.1 / 255,255 . 255,255
acl dst to_localhost 127.0 . 0.0 / 8
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025 – 65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # http multiling
acl CONNECT method CONNECT
acl-time team SMTWHFA 0 : 00 – 24 : 00
REQUIRED acl authenticated proxy_auth

# HTTP_ACCESES
http_access allow authenticated hours
http_access allow manager localhost
http_access deny manager
http_access deny ! Safe_ports
http_access deny CONNECT ! SSL_ports
# And finally deny all other access to this proxy
http_access allow localhost
http_access deny all
icp_access allow all

# OTHERS
hierarchy_stoplist cgi – bin ?
access_log /var/log/squid/access . squid log
acl QUERY urlpath_regex cgi – bin \?
cache deny QUERY
refresh_pattern ^ ftp : in 1440 20 % 10080
refresh_pattern ^ gopher : 1440 0 % 1440
refresh_pattern . 0 20 % 4320
acl apache rep_header Server ^ Apache
broken_vary_encoding allow apache
coredump_dir / var / spool / squid
To start the squid first run the command squid-z , so that it creates cache files, in other times simply call the command squid .
Configuring Dansguardian
First we will update the list of blocked sites, visit this site ( URLBlacklist.com ) and download the newest version. Unzip into / usr / local / etc / dansguardian / lists / blacklists.
Let’s edit the configuration file Dansguardian (/ usr / local / etc / dansguardian / dansguardian.conf)
REPORT #
reportinglevel = 3

# LANGUAGE
languagedir = ‘/ usr / local / share / dansguardian / languages’
language = ‘ptbrazilian’

# Logs
loglevel = 3
logexceptionhits = 2
logfileformat = 3

LogLocation = ‘/ usr / local / var / log / dansguardian / access.log’

# Network Settings
filterip =
filterport = 8080
proxyip = 127.0 . 0.1
proxyPort = 3128

nonstandarddelimiter = on

# LOCKED IMAGES
usecustombannedimage = on
custombannedimagefile = ‘/ usr/local/share/dansguardian/transparent1x1.gif’

# Filter groups options
filtergroups = 1
filtergroupslist = ‘/ usr / local / etc / dansguardian / lists / filtergroupslist’

# Authentication files

# WORDS – WEIGHT
showweightedfound = on
weightedphrasemode = 2

# Positive (clean) result caching for URLs
urlcachenumber = 1000

# Age Before They are stale and Should be ignored in seconds
urlcacheage = 900

# Clean cache for content (AV) scan results
scancleancache = on

# Smart, Raw and Meta / Title phrase content filtering options
phrasefiltermode = 2

# Lower casing options / 0 = force lower case (default)
preservecase = 0

# Hex decoding options
hexdecodecontent = off

# Force Quick Search rather than DFA search algorithm
forcequicksearch = off

# Reverse lookups for banned site and URLs
reverseaddresslookups = off

# Reverse lookups for banned and exception IP lists.
reverseclientiplookups = off

# Perform reverse lookups on client IPs for successful requests.
logclienthostnames = off

# Build bannedsitelist bannedurllist and cache files.
createlistcachefiles = on

# POST protection (web upload and forms)
maxuploadsize = – 1

# Max content filter size
maxcontentfiltersize = 256

# Max content ram cache scan size
maxcontentramcachescansize = 2000

# Max content file cache scan size
maxcontentfilecachescansize = 20000

# File cache dir
filecachedir = ‘/ tmp’

# Delete file cache after user completes download
deletedownloadedtempfiles = on

# Initial Trickle delay
initialtrickledelay = 20

# Trickle delay
trickledelay = 10

# Download

# Content scanner timeout
contentscannertimeout = 60

# Content scan exceptions
contentscanexceptions = off

# Auth

# Re-check URLs Replaced
recheckreplacedurls = off

# Misc settings
forwardedfor = off
usexforwardedfor = off
logconnectionhandlingerrors = on

# Fork pool options
logchildprocesshandling = off
maxchildren = 120
minchildren = 8
minsparechildren = 4
preforkchildren = 6
maxsparechildren = 32
maxagechildren = 500

# Sets the maximum number client IP addresses allowed to connect at once.
maxips = 0

# IPC filename
ipcfilename = ‘/ tmp / .dguardianipc’

# URL list IPC filename
urlipcfilename = ‘/ tmp / .dguardianurlipc’

# IP list IPC filename
ipipcfilename = ‘/ tmp / .dguardianipipc’

# PID filename
nodaemon = off

# Disable logging process
nologger = off

# Enable logging of “ADs” category blocks
logadblocks = on

# Enable logging of client User-Agent
loguseragent = off

# Soft restart
softrestart = off
Two items that are interesting in this configuration are the access log file (/ usr / local / var / log / dansguardian / access.log) and editable HTML page locked (/ usr / local / share / dansguardian / languages) that can be customized.
To start simply call the command dansguardian dansguardian , and to recharge the rules: dansguardian-r.
Iptables
For iptables created a scrip to load the settings, because the rules this should be loaded when the servodor starts.
In this script:
– Oblige all incoming connections going to port 8080 (dansguardian);
– Libero IP network to ‘leak’ so do not fall in dansguardian and squid, ideal for network servers;
– Blocking Ips;
– Blocking against Ping of Death and DoS;
Save this file with the name iptables-load , for example and call the sh iptables-load
#! / Bin / bash

# Remaining iptables
/ etc / init . d / iptables restart

# FUNCTIONS
libera_ip () {
iptables – t nat – I PREROUTING – s $ 1 – j ACCEPT
iptables – t nat – I POSTROUTING – s $ 1 – eth0 – j MASQUERADE
iptables – I FORWARD – s $ 1 – j ACCEPT
}

bloqueia_ip () {
iptables – A INPUT – s $ 1 – j DROP
}

# # # # # # # # # # # # # # # # #

BLOCK IPs #
# bloqueia_ip “192.168.0.199”

# BEARS MODULOS IPTABLES
echo 1 & gt ; / proc / sys / net / ipv4 / ip_forward
modprobe iptable_nat

# BLOCKS AGAINST DEATH AND PING DoS
iptables – A INPUT – p icmp – icmp – type echo – request – m limit – limit 1 / s – j ACCEPT
iptables – A INPUT – p icmp – icmp – type echo – reply – m limit – limit 1 / s – j DROP

# OPEN CONNECTION TO A LOCAL AREA NETWORK AT THE DOOR 8080
iptables – A INPUT – i eth1 – p tcp – dport 8080 – j ACCEPT

# RELEASE FOR NAVIGATION WITHOUT PROXY SERVERS
libera_ip “192.168.0.1” # SERV1
libera_ip “192.168.0.2” # Serv2

# Ends
echo “Iptables Ready”
CBQ
With CBQ do bandwidth control network, first go to the / etc / sysconfig / cbq. For each rule you create a file down and another up. EX: cbq 0002.geral-in- and -cbq 0002.geral out.
For each rule starts numbering from 0002, and continue, noting that this numbering is in hexadecimal.
See my examples:
cbq-0002.geral-in
DEVICE = eth1 , 1000Mbit , 100Mbit
RATE = 2Mb
WEIGHT = 200Kbit
PRIO = 5
RULE = 192.168 . 0.0
Bounded = in
ISOLATED = in
0002.geral cbq-out
DEVICE = eth0 , 1000Mbit , 100Mbit
RATE = 100Kbit
WEIGHT = 10Kbit
PRIO = 5
RULE = 192.168 . 0.0 ,
Bounded = in
ISOLATED = in
Compile the CBQ with the command cbq compile and start with cbd start .
See this tutorial more information about the CBQ.
Starting all
Finally created a scrip to start all the necessary services, just to facilitate:
#! / Bin / bash

squid
echo “starting squid”

dansguardian
echo “Starting dansguardian”

sh / iptables – load
echo “iptables loading”

cbq compile
echo “compiling cbq”

cbq start
echo “starting cbq”

echo “READY”
Additional
To facilitate the administration of the server, I recommend installing webmin (a web interface facing server administration, now with the Squid module installed, great for keeping the users) and sarg with the webalizer. Reports To log dansguardian .
Finishing
I hope this article is helpful, of course does not answer all questions, and each installation will have their particular problems, but hopefully it will be a base for administrators. Leave your comments with questions and suggestions.
Thanks for visiting and sharing this post!

Logon User SID Details

Whoami / ? -> To get the Help

whoami /All > mydetails.txt -> It will get all the details of the user Eg: User SID and etc

Change Server 2008 Product Key

Remove the Existing Product Key from Server

slmgr.vbs -ckms

Enter the New Product key in to Server 2008

slmgr.vbs -ipk xxxx-xxxx-xxxx-xxxx

Note: Replace the xxxx by given code

If the product code is correct this should return a dialog box indicating success, otherwise it fails. Once you have specified the correct product code it’s time to register by issuing command:

slmgr.vbs -ato

A successful activation will return a success dialog box and a failure will indicate as such.