All posts by admin

How to Set File Permissions for ASP.NET Website on Windows

Problem:

  • You have ASP.NET website on Windows.
  • Your website application pool name is mysite.com.
  • Your website physical location is D:\inetpub\wwwroot\mysite.com.
  • Your website physical data location is D:\mysite_data.
  • Your website users cannot upload or modify website files.
  • Your website users cannot upload or modify website data files.

Solution:

1. Open cmd.exe as Administrator and execute the command below.

icacls "D:\inetpub\wwwroot\mysite.com" /grant "IIS AppPool\mysite.com":(OI)(CI)F /T
icacls "D:\mysite_data" /grant "IIS AppPool\mysite.com":(OI)(CI)F /T

This command give full permissions against D:\inetpub\wwwroot\mysite.com  and all sub-directories and files, and against D:\mysite_data  and all sub-directories and files to mysite.com user.

2. Alternatively you can execute the command below.

icacls "D:\inetpub\wwwroot\mysite.com" /grant IIS_IUSRS:F /t
icacls "D:\mysite_data" /grant IIS_IUSRS:F /t

This command give full permissions against D:\inetpub\wwwroot\mysite.com  and all sub-directories and files, and against D:\mysite_data  and all sub-directories and files to IIS_IUSRS group.

mysite.com user is part of the IIS_IUSRS group.

 

How to Restart a Windows Server in a Domain Remotely

Problem:

You need to restart a Windows server in a domain remotely because it seems to be stuck and you cannot remotely connect to it via RDP.

Solution:

1. Open cmd.exe and execute 2 commands below.

ping server_name
shutdown /r /m \\server_name /t 0/

2. You may get the error below.

server_name: A system shutdown is in progress.(1115)

3. Download and extract PSTools.

4. Open cmd.exe and execute 3 commands below.

cd C:\Users\admin\Downloads\PSTools
pskill \\server_name winlogon
pskill \\server_name TrustedInstaller

 

How to Be Creative in Software Engineering Research

Motivation:

You plan to do a software engineering research and want to make some minor authentic contributions.

Guidelines:

1. You may present a problem and corresponding existing solution using your own understanding.

A method to do this is to

  • Read papers and books about a concept (for example backpropagation or distributed transactions), then
  • Write down the concept and some related terminologies, then
  • Try explain the concept with examples using your speech, and
  • Record your presentation, then
  • Write down your transcript, then
  • Rephrase your transcript.

2. You may try to replicate an existing result. When doing this you may need to make minor changes due to specific technology or environment conditions. Then you can compare your result with the original result.

For example, you may compare your business workflows with existing business workflows to determine which solution may solve a specific problem faster or more reliable.

In case you do not make any minor changes, the replication process may also inspire you some technical ideas. You may get errors while replicating the result. Try to fix these errors and document your experience.

For example you may get errors when upgrading an existing system from Node.js 12 to Node.js 18, or when upgrading an existing deep learning model code from Python 3.9 to Python 3.11. Try to fix the errors, then document your inputs, errors and solution.

3. The core idea to be creative is to do something that you have not done before. You may use trial and error method but be sure that you have a hard unsolved problem first. Trying to search for partial solutions to a problem will inspire you some ideas which may be the starting point for your minor authentic contributions.

4. Each individual’s creativity will need to be developed over time rather than in accordance with any kind of set formula.

 

How to Set File Permissions for WordPress on Ubuntu

Motivation:

  • You have a WordPress instance on Ubuntu Nginx.
  • You want to ensure that only the Nginx process can access WordPress files.

Procedure:

  1. View current file owner and group:
ls -l /var/html

The root folder should be owned by www-data user. www-data is the user that web servers like Apache and Nginx on Ubuntu use by default for their normal operation.

2. Change file owner and group to www-data if necessary:

sudo chown -R www-data:www-data /var/html

3. Set minimum permissions for folders:

cd /var/html
sudo find . -type d -exec chmod 755 {} \; # directory permissions rwxr-xr-x

4. Set minimum permissions for files:

cd /var/html
sudo find . -type f -exec chmod 644 {} \; # file permissions rw-r--r--

5. Verify the changes:

ls -l /var/html

How to Back Up and Restore IIS App Pool and Site Settings

Motivation:

You want to back up and restore IIS app pool and site settings.

Solution:

1. Open Command Prompt (Admin) and execute commands below to export IIS app pool and site settings to XML files.

%windir%\system32\inetsrv\appcmd list apppool /config /xml > \\192.168.101.140\BCDR\WEBBC02\E\inetpub\apppools.xml
%windir%\system32\inetsrv\appcmd list site /config /xml > \\192.168.101.140\BCDR\WEBBC02\E\inetpub\sites.xml

2. Remove all existing IIS app pools and sites, then execute the command below to import IIS app pool and site settings from XML files.

%windir%\system32\inetsrv\appcmd list apppool /config /xml < \\192.168.101.140\BCDR\WEBBC02\E\inetpub\apppools.xml
%windir%\system32\inetsrv\appcmd list site /config /xml < \\192.168.101.140\BCDR\WEBBC02\E\inetpub\sites.xml

Forget vs. Forget About

Forget is a general word, forget about is more specific.

  • I forgot my keys.“: Person forgot their keys, as in it was left somewhere, and the person doesn’t have it.
  • I want to forget about my keys.“: Person would like to “un”know about its keys, or wants to bury the memories of it.
  • I forgot that face.“: Person doesn’t remember how someone’s face looked like.
  • I forgot about that face.“: Non-direct way of saying one doesn’t remember all the facial features – but not the entire face.

How to Fix Firefox No Sound Issue

Problem:

Your Firefox suddenly does not play any sounds.

You have tried uninstalling and reinstalling it but the problem still persists.

Quick Solution:

  1. Go to Windows Settings > Sound > Advanced Sound Options .
  2. Make sure Firefox is not muted or set to low volume.

Advanced Solution:

  1. Create a Firefox account and synchronize (make a backup of) your current settings.
  2. Uninstall Firefox using Windows Apps and features.
  3. Go to %APPDATA%\Mozilla and delete Firefox folder.
  4. Open regedit.exe, search for Firefox, and delete all the keys and values that can be found. This process will take some time. Just ignore any errors that may occur when some keys or values cannot be deleted.
  5. Restart your computer.
  6. Download Firefox offline installer.
  7. Install Firefox.
  8. Log in your Firefox account and restore your settings.

 

 

How to Determine all Ports Opened by a Program in Windows

Motivation:

You want to ensure that your server is not compromised by a program.

Solution:

1. Open cmd.exe and execute commands below. Note the program file name and one of its ports that you want to investigate further.

netstat -a -b

2. Execute the command below. Note the PID associated with the port that you are interested in.

netstat -ano -p tcp

3. Execute commands below. “1544” is the PID that you are interested in.

netstat -ano -p tcp |find "1544"

4. Open https://mxtoolbox.com/TCPLookup.aspx, and enter [your external IP:port], and click TCP Lookup button to check if a port is open from your server.

5. Go to your Firewall and block the port if it should not be open to the Internet.

How to Change SQL Server sa User’s Password

Problem:

You are a Windows Administrator and you can log in SQL server instance. However you cannot access databases.
You want to log in the SQL server instance under sa user but you forget the sa user’s password.
You cannot the sa user’s password using SQL Server Management Studio.

Solution:

1. Open cmd.exe and execute commands below. Replace MSSQL$SQLEXPRESS with your SQL service name and localhost\SQLEXPRESS with your SQL instance.

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS /m"SQLCMD"
sqlcmd -S localhost\SQLEXPRESS

2. Type and press Enter for each line below.

ALTER LOGIN [sa] WITH DEFAULT_DATABASE=[master]
GO
USE [master]
GO
ALTER LOGIN [sa] WITH PASSWORD=N'Password@1234'
GO
exit

3. Open cmd.exe and execute commands below.

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS

4. Open SQL Server Management Studio and log in the SQL server using the sa account.