Category Archives: Operating Systems

Topic 1 – Operating Systems

Why do I need to learn about operating systems?

Because you will develop your software using an operating system or for an operating system.

How many operating systems should I know?

As many as possible. We recommend that you learn how to work with Windows first. Then you learn about basic concepts of an operating system.

How do I learn about operating systems under a user’s view?

Please read this Andy Rathbone (2015). Windows 10 For Dummies. Wiley book.

How about other operating systems such as macOS, Linux or Unix?

If you have a Mac then you can read this Pogue David (2019). macOS Mojave: The Missing Manual. O'Reilly Media book.

If you have a PC with Ubuntu Linux or Unix then you can read this Mark G. Sobell (2015). A Practical Guide to Ubuntu Linux. Prentice Hall book.
After reading these books please read this Abraham Silberschatz et al. (2013). Operating System Concepts. Wiley book to grasp basic concepts of an operating system.

Once you finish reading these books please click Topic 2 - Introduction to Programming to continue.

How to Trim MP4 Files Without Re-Encoding

Motivation:

You have MP4 files with unwanted portions. You want to trim these portions.

Solution:

  1. Download XMedia Recode.
  2. Under the Format tab set
    Profile = Custom
    Format = MP4
    File Extension = mp4
  3. Click the Video tab and select Copy Mode.
  4. Click the Audio tab and select Copy Mode.
  5. Click the Filters/Preview tab and set Start Time and to (End Time).
  6. Click Add to queue button on the tool bar.
  7. Click Encode on the tool bar.

 

How to Put Your Books into Kindle or Apple Books

Motivation:

You have a book with .epub or .mobi format in your MacBook or PC.
You want to put it into your iPhone or iPAD so that you can read it on the go.

Solution:

1. Put the books into iCloud Drive.
2. Install Kindle or Apple Books on your iPhone or iPAD.
3. Login your Kindle account.
4. Open the Files app to go to iCloud Drive.
5. Open the book.
6. Tap the Share icon in the lower left hand corner.
7. Select Kindle or Open in iBooks.

How to install a fresh Windows 10 booted from UEFI secure boot using a bootable USB

Problem:

Most of Windows machines are delivered with a limited Windows version and unnecessary preinstalled software.

You want to format the hard drive and install a fresh Windows that can be booted from UEFI secure boot to improve machine performance and stability.

You have a 8Gb USB stick and an ISO file of Windows 10, version 2004.

Solution:

Step 1: Backup your machine and create an USB recovery by entering “Create a recovery drive” text to the search box on the task bar and follow the instructions.

Step 2: Create a bootable USB with Windows installation files.

Right click Windows logo, click Command Prompt (Admin).
Enter diskpart.exe, press Enter.
DISKPART> list disk
DISKPART> select disk 1 -- the USB disk should be selected, the number may be different in your machine.
DISKPART> clean
DISKPART> create partition primary size=1024
DISKPART> select partition 1
DISKPART> active
DISKPART> format quick fs=fat32
DISKPART> assign
DISKPART> create partition primary
DISKPART> select partition 2
DISKPART> format quick fs=ntfs
DISKPART> assign
DISKPART> exit
Double click on the ISO file of Windows 10, version 2004 to create a virtual drive.
xcopy f:\sources\boot.wim d:\sources\ /s /e 

where f: the virtual drive and d: the USB fat32 partition.
We copy only the f:\sources\boot.wim file to d:\sources\.
robocopy f:\ d:\ /IS /S /XD sources 

where f: the virtual drive and d: the USB fat32 partition.
We copy everything from f:\ to d:\ except the sources folder.
xcopy f:* e:\ /s /e 

where f: the virtual drive and e: the USB ntfs partition.

Step 3: Install Windows.

  1.  Plug the USB to a machine.
  2. For a Dell laptop, power on the machine, press F12 until a one-time boot up menu appears.
  3. For a Sony VAIO laptop, power off the machine, then press the Assist button to enter VAIOCare.
  4. Select the option to boot the machine from the USB (you may need to enable Boot from USB in BIOS).
  5. Follow the instructions to install Windows (set Windows partition size to 716916Mb for DellPrecision if you want to have 700Gb C drive or 262789Mb for DellXPS if you want to have a 255Gb C drive).
  6. You can delete all the partitions, including MRP (Microsoft Reserved Partition – this is just a reserved partition for Windows later use if needed), ESP (EFI System Partition – this is where UEFI firmware files are stored to boot Windows), WINRETOOLS (Windows Recovery Environment (WinRE) Tools – this is where files for repairing or recovering Windows are stored), and PBR image (this is where original the manufacture Windows installation file  are stored) because you already created an USB recovery in the Step 1.

Step 4: Configure Windows for Developer’s needs.

  1. Change Computer Name, turn off System Restore, enable Remote Desktop.
  2. Change Time Zone.
  3. Activate Windows.
  4. Turn on Network discovery and file sharing by clicking on Network icon on the left side of Explorer, install Dell Wireless 1820A 1830 WiFi Driver, turn off BitLocker (manage-bde -status, manage-bde -off C:).
  5. Configure auto logon (netplwiz), disable hibernation (powercfg.exe /h off), configure Power options (Hard disk, Sleep).
  6. Turn the following Windows features on: .NET 3.5, ASP.NET 4.8, Internet Information Services, Telnet Client.
  7. Install Hyper-V, create an external Virtual Switch for Internet access.
  8. Configure secure protocols using IIS Crypto GUI.
  9. Install Total Commander, Remote Desktop Connection Manager, PuTTY 0.7.3, WinSCP 5.17, Zoom.
  10. Install Firefox, MPC-HC.1.7.13.
  11. Install MS Office 2007 SP3 (Display >> Scale and layout: 125% for DellPrecision, 175% for DellXPS), MS Project 2016, MS Visio 2016, MS SQL Server 2008 R2, Visual Studio 2015, Adobe Acrobat Pro DC v15.8, Adobe Photoshop CC 2015, TortoiseSVN 1.13.1
  12. Install Python 3.6.8, TensorFlow, Keras
  13. Create VPN Connection.

Go to Control Panel >> Network and Sharing Center >> Change adapter settings >> Right click >> VPN Connection’s Properties >> Select Networking tab:
1. Disable Internet Protocol Version 6 (TCP/IPv6).
2. Select Internet Protocol Version 4 (TCP/IPv4) >> Properties >> Advanced… >> select IP Settings tab: Uncheck Use default gateway on remote network option.

 

How to fix “An internal error has occurred” issue of Remote Desktop Connection

Problem:

You get “An internal error has occurred” error message when trying to connect to a remote machine using Remote Desktop Connection.

Solution:

1. Type Local Security Policy to the Windows Search box.

2. Click Open link.

3. Expand Local Policies > Security Options on the left panel.

4.  Double click on System cryptography: Use FIPS compliant algorithms for encryption, hashing, and signing row on the right panel.

5. Select Enabled, click Apply and click OK.

How to add multiple IPs to an Amazon EC2 virtual machine

Motivation:

You have a Server 2008 R2 machine on Amazon EC2.

You want to secure multiple domains using different  SSL/TLS certificates.

Server 2008 R2 does not support Server Name Indication (SNI). Therefore you need to add multiple IPs to Server 2008 R2 machine to use different SSL/TLS certificates.

Solution:
  1. Create an EC2 virtual machine.
  2. Click on Network Interfaces tab.
  3. Click Create Network Interface button or select an existing network interface and select Actions > Attach.
  4. Select an existing network interface and select and click Manage IP Addresses to create private IPs for the network interface.
  5. Click Elastic IPs tab and allocate elastic IPs for your need.
  6. Select an elastic IP and click on Actions > Associate Address to associate a private IP of the network interface with an elastic IP.
  7. Login Windows.
  8. View the network configuration using below command, note the Default Gateway and DNS Servers information.
ipconfig /all

9. Open Control Panel\All Control Panel Items\Network and Sharing Center.

10. Click Change adapter settings link, click a Local Area Network Connection Network.

11. Manually enter one IP address, Default Gateway and DNS Servers information.

12. Click Advance… button to open Advanced TCP/IP Settings screen, and add the private IPs in the 4th step to the machine.

13. Restart the machine.

If you get any issue then try limit the number of private IPs of a network interface to 4 (including the default private IP).

How to move a WordPress instance from one server to another Linux server

Motivation:

You want to move a WordPress instance from one server to another to consolidate your websites to reduce cost.

Solution:

Install and use below Duplicator plugin to achieve your goal.

https://wordpress.org/plugins/duplicator/

User guide: https://snapcreek.com/duplicator/docs/quick-start/

If everything goes well for you then congratulation!

Otherwise, please review below possible problems and corresponding solutions.


Problem 1:

You don’t have a website on the new server.

Solution 1:

1. Create a new virtual host in the /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot "/var/www/www.example.com"
</VirtualHost>

2. Set 775 permission for /var/www/www.example.com

3. Restart httpd service

sudo systemctl restart httpd

Problem 2:

You are using Amazon Linux 2 server.

You are logged in as ec2-user.

You use WinSCP to upload files and edit configuration files.

You cannot modify /etc/httpd/conf/httpd.conf and /etc/php.ini.

Solution 2:

1 View permission settings for the file

ls -ld /etc/httpd/conf/httpd.conf

The result indicates that the file owner is root user and root group, not ec2-user.

2. View groups of a user

groups ec2-user

The result indicates that the ec2-user does not belong to root group.

3. Add a user to root group

sudo usermod -a -G root ec2-user

4. Grant Read-Write permission against a file to root group

sudo chmod g+rwx /etc/httpd/conf/httpd.conf
sudo chmod g+rwx /etc/php.ini

5. Logout and login to the server again.


Problem 3:

You are using Amazon Linux 2 server. The ZipArchive feature is missing.

Solution 3:

1. Execute below commands:

sudo amazon-linux-extras install php7.2
sudo yum install php-pear php-devel gcc libzip-devel zlib-devel
sudo pecl install zip-1.13.5 # we must specify a slightly older version due due to compatibility

2. Add “extension=zip.so” to /etc/php.ini

3. Restart the server

sudo reboot

Problem 4:

You don’t have a WordPress database on the new Linux server.

Solution 4:

Execute below MySQL commands:

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE `wp_database`;
GRANT ALL PRIVILEGES ON `wp_database`.* TO "username"@"localhost";
FLUSH PRIVILEGES;

Problem 5:

An database error occurs while restoring a website.

Solution 5:

1. Execute below commands to remove the website:

sudo chown -R ec2-user:apache /var/www/example.com
sudo chmod 2775 /var/www/example.com && find /var/www/example.com -type d -exec sudo chmod 2775 {} \;
find /var/www/example.com -type f -exec sudo chmod 0664 {} \;
rm -r /var/www/example.com

2. Upload the Duplicator files again, and restore the website again.


Problem 6:

No write access against /var/www/example.com is available for Duplicator.

Solution 6:

1. Execute below commands:

sudo chown -R ec2-user:apache /var/www/example.com
sudo chmod 2775 /var/www/example.com && find /var/www/example.com -type d -exec sudo chmod 2775 {} \;
find /var/www/example.com -type f -exec sudo chmod 0664 {} \;

2. Run http://example.com/installer.php again.

How to connect and upload files to a remote machine using OpenVPN and SSH on macOS

Motivation:

You have a server inside a network. You are granted OpenVPN and SSH access to the server. You have a MacBook. You want to upload files to the server. You want to execute a process on the server (e.g. training a machine learning model).

Procedure:

  • Request a certificate and an Open VPN configuration file (an .ovpn file) from your network administrator.
  • Install Tunnelblick https://tunnelblick.net
  • Drag the Open VPN configuration file to the Tunnelblick Configurations tab.
  • Click the Connect button.
  • On macOS, open Terminal and execute below command
ssh root@172.29.64.144 -p 7081

where 172.29.64.144 is the machine IP and 7081 is the SSH port

How to completely uninstall Python on Mac OS?

Problem:

You have an issue with a Python version (e.g. the 3.7 version) and want to install another version (e.g. the 3.6 version). In order to install a fresh version you need to uninstall the current version first.

Solution:

Assume that the current version is 3.7. Replace 3.7 with another version that you installed.

Follow these 3 steps below.

1. Remove the third-party Python 3.7 framework

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7

2. Remove the Python 3.7 applications directory

sudo rm -rf "/Applications/Python 3.7"

3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. Ensure that the links exit using below command.

ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7'

and then run the following command to remove all the links:

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7' | awk '{print $9}' | tr -d @ | xargs rm

Source: http://stackoverflow.com

Installing a new version:

  1. Download a version from https://www.python.org/downloads/mac-osx/, double click the file and follow the instructions.
  2. Verify installation: python3 –version
  3. Install Homebrew from https://brew.sh
  4. Install virtualenv
  5. pip3 install virtualenv
    pip3 install virtualenvwrapper

5.  Create and activate a virtual environment

cd /Users/admin/Downloads/training_model/model 
python3 -m virtualenv /Users/admin/Downloads/training_model/model
source bin/activate

How to Fix the Dell Laptop “Hard Drive Not Installed” issue

Problem:

Suddenly, when turning your Dell laptop on you get the error message “Hard drive Not installed” and cannot boot into Windows.

Solution:
  1. Power your laptop and quickly press F2 key to enter BIOS.
  2. Expand System Configuration node.
  3. Click SATA Operation.
  4. Select AHCI option.
  5. Click Apply button.
  6. Click Exit button.
  7. If the problem still persists then restore BIOS settings to Default BIOS settings and try the procedure again.

 

Setting File Permissions for WordPress on IIS

Motivation:

  • You have a WordPress instance in Windows with IIS.
  • You upload a file. Its thumbnail is not shown in Media Library.
  • You change the file permission. Its thumbnail now is shown correctly in Media Library.
  • You upload another file and have to change the file permission manually again.
  • How can we make WordPress automatically set the correct permission for new uploaded files?

Procedure:

  1. Ensure that the the Identity of Application pool that the website is running under is ApplicationPoolIdentity.
  2. Execute below commands as Administrator
icacls "C:\inetpub\wwwroot\domain.com" /grant "IUSR":(OI)(CI)F /T
icacls "C:\inetpub\wwwroot\domain.com" /grant "IIS_IUSRS":(OI)(CI)F /T

3. Open IIS Manager, click on your website, click Authentication, click Anonymous Authentication (which should be the only one enabled), click Edit, select Application pool identity if it is not selected, click OK.

How to change a WordPress website’s domain name?
  • Open the wp-config.php file.
  • Add two lines to the file, right before /* That’s all, stop editing! Happy blogging. */:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
  • Bulk edit the posts content if needed.