Category Archives: Operating Systems

Operating Systems general commands and issue fixes cover in Linux , Windows, Solaris, Unix , HP-UX etc.

Start and Stop window Services from command prompt using NET commands

Start and Stop window Services from command prompt using NET commands

NET START: Name of all services present in the windows services which is running

D:\ImageCenter\Database\6dbcheck>net start
These Windows services are started:

Adobe Acrobat Update Service
Application Information
Application Management
COM+ Event System
OracleServiceXE
OracleXETNSListener

SC QUERY command give you only service name which you specify

D:\ImageCenter\Database\6dbcheck>sc query OracleServiceXE

SERVICE_NAME: OracleServiceXE
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

SC QUERY command give you all services details as follows

D:\ImageCenter\Database\6dbcheck>sc query
SERVICE_NAME: OracleServiceXE
DISPLAY_NAME: OracleServiceXE
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

SERVICE_NAME: OracleXETNSListener
DISPLAY_NAME: OracleXETNSListener
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0

NET STOP : Stop the service from windows command prompt

net stop OracleXETNSListener
C:\Windows\system32>net stop OracleXETNSListener
The OracleXETNSListener service is stopping.
The OracleXETNSListener service was stopped successfully.

net start OracleServiceXE
C:\Windows\system32>net stop OracleServiceXE
The OracleServiceXE service is stopping...................
The OracleServiceXE service was stopped successfully.

NET START : Start the service from windows command prompt

net start OracleXETNSListener
C:\Windows\system32>net start OracleXETNSListener
The OracleXETNSListener service is starting.
The OracleXETNSListener service was started successfully.

net start OracleServiceXE
C:\Windows\system32>net start OracleServiceXE
The OracleServiceXE service is starting...............
The OracleServiceXE service was started successfully.

Advertisements

Batch script for getting drives information in GB & percentage

Batch script for getting drives information in GB & percentage

Following script provide you the drive information in GB & percentage used in bat file script. Simple copy & paste it in bat file and execute it.

Run instruction as following:
1. Save this file as name diskinfo.bat
2. Open the command prompt window
3. Go to the location of script
4. Run this as:
diskinfo localhost
5. Output as shown in snapshot:

diskinfo

Script:

@ECHO OFF
IF "%~1"=="" goto help

@SETLOCAL ENABLEEXTENSIONS
@SETLOCAL ENABLEDELAYEDEXPANSION

@FOR /F "skip=1 tokens=1" %%x IN ('"WMIC /node:"%1" LOGICALDISK GET Name " ') DO (
REM @ECHO %%x

@FOR /F "tokens=1-3" %%n IN ('"WMIC /node:"%1" LOGICALDISK GET Name,Size,FreeSpace | find /i "%%x""') DO ( @SET FreeBytes=%%n & @SET TotalBytes=%%p

SET TotalGB=0
SET FreeGB=0

REM Parameter value used to convert in GB
set num1=1074

REM Parameter value used to convert in MB or KB
REM set num1 = 1049

REM @ECHO Total space: !TotalBytes!

SET /a TotalSpace=!TotalBytes:~0,-6! / !NUM1!
SET /a FreeSpace=!FreeBytes:~0,-7! / !NUM1!

SET TotalGB=!TotalSpace!
SET FreeGB=!FreeSpace!

SET PERNUM=100

SET /A TotalUsed=!TotalSpace! - !FreeSpace!
SET /A MULTIUSED=!TotalUsed!*!PERNUM!
SET /A PERCENTUSED=!MULTIUSED!/!TotalGB!

REM IF !TotalSpace! LSS 0 goto error

@echo.
@echo.
@echo Drive: %%x
@ECHO ===========================
@ECHO Total space: !TotalGB! GB
@ECHO Free space : !FreeGB! GB
@ECHO PERCENTUSED : !PERCENTUSED!
REM @SET TotalSpace=
REM @SET FreeSpace=
REM @SET TotalUsed=
REM goto end
)
)
goto end
:error
echo.
echo *** Invalid server or drive specified ***
echo.
goto help

:help
echo.
echo diskfree.cmd
echo.
echo Queries remote server for free disk space.
echo Specify a MACHINENAME and a drive letter to be queried
echo.
echo Example: diskfree.cmd MACHINENAME c:
echo.
goto end

:end

Map EBS Storage with Linux EC2 instance in AWS

Map EBS Storage with Linux EC2 instance in AWS

In this blog, we are going to configure the EBS Storage to the redhat linux EC2 instance in Amazon web services.

Following are the steps

1. Create an EC2 instance of Redhat linux from AWS Console.

2. Create addition volume of EBS storage from AWS Console.

3. Attach the EC2 instance with EBS volume from EBS tab by right click on EBS Storage which is created in step 2.
Note: Both EC2 instance and EBS volume should be in same availability zone.

4. Open the putty session with private key.

5. Now first step is to check the disk present as shown below before attached the new EBS volume in step 3

-- command executed before step 3 it show only one volume
[ec2-user@ip-172-31-7-21 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 10G 0 part /

6. After step 3 executed, command show the volume is attached

[ec2-user@ip-172-31-7-21 ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 10G 0 part /
xvdf 202:80 0 1G 0 disk

7. Switch to root user

sudo su -

8. Check the file system type which need to be formatted and already existed/used by Linux system

[root@ip-172-31-7-21 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 10G 0 part /
xvdf 202:80 0 1G 0 disk
[root@ip-172-31-7-21 ~]#
[root@ip-172-31-7-21 ~]# file -s /dev/xvda
/dev/xvda: x86 boot sector; partition 1: ID=0xee, active, starthead 0, startsector 1, 20971519 sectors, code offset 0x63
[root@ip-172-31-7-21 ~]#
[root@ip-172-31-7-21 ~]# file -s /dev/xvda1
/dev/xvda1: data
[root@ip-172-31-7-21 ~]# file -s /dev/xvda2
/dev/xvda2: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
[root@ip-172-31-7-21 ~]#

Note: It show that linux system is using XFS filesystem.

8. Make a file system XFS as shown below example:

[root@ip-172-31-7-21 data1]# mkfs.xfs /dev/xvdf
meta-data=/dev/xvdf isize=512 agcount=4, agsize=65536 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=262144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

Note: You can make other filesystem also like ext4 of one partition

[root@ip-172-31-7-21 ~]# mkfs -t ext4 /dev/xvdg
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

9. Mount the device to a new folder

mkdir /data1
mount /dev/xvdf /data1

10. Now check the lsblk command for output

[root@ip-172-31-7-21 data1]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 10G 0 disk
├─xvda1 202:1 0 1M 0 part
└─xvda2 202:2 0 10G 0 part /
xvdf 202:80 0 1G 0 disk /data1

11. You can check with df -Th command for file format:

[root@ip-172-31-7-21 data2]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/xvda2 xfs 10G 925M 9.1G 10% /
devtmpfs devtmpfs 474M 0 474M 0% /dev
tmpfs tmpfs 496M 0 496M 0% /dev/shm
tmpfs tmpfs 496M 13M 483M 3% /run
tmpfs tmpfs 496M 0 496M 0% /sys/fs/cgroup
tmpfs tmpfs 100M 0 100M 0% /run/user/1000
tmpfs tmpfs 100M 0 100M 0% /run/user/0
/dev/xvdf xfs 976M 2.6M 907M 1% /data1

12. For make change permanent add entry in /etc/fstab file.
vi /etc/fstab

# /etc/fstab
# Created by anaconda on Fri Mar 23 17:41:14 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=50a9826b-3a50-44d0-ad12-28f2056e9927 / xfs defaults 0 0
/dev/xvdf /data1 xfs defaults 0 0

13. Check the entry is good

mount -a
Example:
[root@ip-172-31-7-21 data2]# mount -a
[root@ip-172-31-7-21 data2]#

Note: If you type wrong name like /dev/svdf then you got following message
[root@ip-172-31-7-21 data2]# mount -a
mount: special device /dev/svdg does not exist

14. Now your drive is ready to use.

For Unmount the drive

[root@ip-172-31-7-21 data2]# umount /data1
[root@ip-172-31-7-21 data2]#

Taskkill Error Access denied

Taskkill Error Access denied

1. Open the Command prompt window with Administrator right.

First check Command prompt is open with administrator right with right click on it.
(RUN AS ADMINISTRATOR)

2. Check with the process user from which it’s running.

tasklist /V

-- Output in Excel Sheet
tasklist /V /FO CSV > E:\output.csv

Output Sample:
--------------
"oracle.exe","10124","Services","0","404,584 K","Unknown","NT AUTHORITY\SYSTEM","0:18:22","N/A"
"conhost.exe","7716","Services","0","500 K","Unknown","NT AUTHORITY\SYSTEM","0:00:00","N/A"

3. Try to kill it.

C:\Users\e3019447>taskkill /F /PID 10124
ERROR: The process with PID 10124 could not be terminated.
Reason: Access is denied.

C:\Windows\system32>TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /PID 10124
SUCCESS: The process with PID 10124 has been terminated.

OR

TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM oracle.exe

OR

wmic process where name='oracle.exe’ delete

Different Syntax provided by Microsoft to use the Commands:

TASKKILL Commands : TASKKILL /?

TASKKILL /IM notepad.exe
TASKKILL /PID 1230 /PID 1241 /PID 1253 /T
TASKKILL /F /IM cmd.exe /T
TASKKILL /F /FI "PID ge 1000" /FI "WINDOWTITLE ne untitle*"
TASKKILL /F /FI "USERNAME eq NT AUTHORITY\SYSTEM" /IM oracle.exe
TASKKILL /S system /U AMERIFIRST\tron /FI "USERNAME ne NT*" /IM oracle.exe
TASKKILL /S system /U username /P password /FI "IMAGENAME eq note*"

TASKLIST Commands: TASKLIST /?

TASKLIST /M notepad.exe
TASKLIST /V /FO CSV
TASKLIST /SVC /FO LIST
TASKLIST /M wbem*
TASKLIST /S system /FO LIST
TASKLIST /S system /U domain\username /FO CSV /NH
TASKLIST /S system /U username /P password /FO TABLE /NH
TASKLIST /FI "USERNAME ne NT AUTHORITY\SYSTEM" /FI "STATUS eq running"

Configure yum manually on Oracle Linux Platform from Media

Configure yum manually on Oracle Linux Platform from Media

I am using Oracle Virtual box in which i installed oracle Linux platform.

Following are steps to configure yum manually through Media or ISO image:

Step 1: Transfer the complete iso image of Linux to you local drive.
Note: I am using linux 7.4 so making naming conventions as 7.4 for all folder below. So change according to your need.

mkdir /ISOs
cp /media/USB_Sticks/Linux7-4.iso /ISOs

Step 2. Create Folder for the mounting the DVD image on it:

mkdir -p /var/OSimage/OL7.4_x86_64

mount -o loop,ro /ISOs/Linux7-4.iso /var/OSimage/OL7.4_x86_64

Yum1

Step 3: On Restart, we need to fire command again in step 2. Avoid it make an entry in /etc/fstab

vi /etc/fstab
-- Insert entry into file /etc/fstab
/ISOs/Linux7-4.iso /var/OSimage/OL7.4_x86_64 iso9660 loop,ro 0 0

Step 4: In /etc/yum.repos.d directory, edit the existing file present public-yum-ol74.repo and disable all entries by setting enabled=0.

vi public-yum-ol74.repo
-- Make all the enabled parameter to value 0

Step 5: Create the new entries in a new repository file

For example, /etc/yum.repos.d/OL74.repo

-- Create new file
vi /etc/yum.repos.d/OL74.repo

-- Insert following entries in file and take care of fist parameter [OL74] as naming of the file name.
[OL74]
name=Oracle Linux 7.4 x86_64
baseurl=file:///var/OSimage/OL7.4_x86_64
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
gpgcheck=1
enabled=1

Step 6: Clean up the yum cache from the system.

yum clean all

yum-clean-all

Step 7: Check yum to access the repository.

yum repolist

yum-repolist

Step 8: Verify yum is working properly.

yum list
yum install gcc

DWM process consuming CPU in windows

DWM Process consuming CPU in Windows Platform

Desktop Window Manager (dwm.exe) is a compositing window manager that renders all those pretty effects in Windows: transparent windows, live taskbar thumbnails, Flip3D, and even high resolution monitor support.

On Working on the Windows Server, I found that dwm.exe process is consuming lot of CPU and made the system in hanged State.

On checking the net regarding it. It show one service name Desktop Window Manger need to be disable but i tested on my machine first before doing on porduction Server in Windows 7, Desktop Window Manager is present in the Service list. On stop the service, it refresh the monitor display but does not have much effect in resolution.

But when tried on Windows 2012 Server, Service is not present

For Windows 7 disable steps as follows
1. Click the Start button to open the Start menu.
2. In the Windows Search box, type services and click the Services link.
3. In the Services window, search and double-click Desktop Windows Manager.
4. In the Desktop Windows Manager window, Right click to disable the service.
5. If you want this process never to start when Windows loads, change the Startup type option from Automatic to Disabled.

On Windows 2012, Service is not present you need to apply bug fix as follows:

https://support.microsoft.com/en-us/help/2852483/memory-leak-occurs-in-the-dwm-exe-process-on-a-remote-desktop-computer

Find the port used by process in windows

Find the port used by which process in windows

Faced one issue during configuring listener with netca utility. Its show me that port – 1521 is already in used. But when i checked the listener services is not running. Then i took backup of network folder and drop the listener on window platform. But again when try to reconfigure listener throw same error.

Then I checked with windows commands to find which application is using 1521.

1. From command prompt administrator windows run following command:

netca

Show all running process

Check only for 1521 port:

netstat -aon | find "1521"

E:\patch_backup\deinstall>netstat -aon | find "1521"
Proto Local Address Foreign Address State Process
TCP 0.0.0.0:1521 0.0.0.0:0 LISTENING 2612
TCP 127.0.0.1:1521 127.0.0.10:57934 ESTABLISHED 2612
TCP 127.0.0.1:1521 127.0.0.10:57935 ESTABLISHED 2612
TCP 127.0.0.1:1521 127.0.0.10:57938 ESTABLISHED 2612

Means:
a : List all connections and listening ports.
O : List the owning process ID
n : List addresses and port numbers.

2. Verify the listener is running from which process id

tasklist /m ora*

Image Name PID Modules
========================= ======== ============================================
TNSLSNR.EXE 2612 oransgr11.dll, oran11.dll, oranl11.dll,
orantcp11.dll, oracore11.dll, oranls11.dll,
oraunls11.dll, orauts.dll,


3. Kill the task if needed

taskkill /PID 2612 /F