How Do You Programmatically Search Hyperlinks on a Given Webpage?

Problem scenario
You have a web page that you access from the front-end (e.g., a web browser). You want to see if there is a hyperlink on the page that goes to a certain URL. You know the web page and the URL, but you are not sure if a hyperlink on the website has such a link. What should you do?

Solution
Use the curl command.

 » Read more..

How Do You Capture More Events in the Nginx Logs?

Problem scenario
You want more verbose log capturing in Nginx. What should you do?

Solution
1. Make a back up of nginx.conf. Then open it. It is often in /etc/nginx/nginx.conf. (Some versions of nginx have a file that does some of the same things called default.conf. This will be the file you will need if you have no nginx.conf file.)

2.

 » Read more..

What Should You Do when the Apache Mesos Web UI Keeps Refreshing and Sending a Pop-up “Failed to connect to …:5050”?

Problem scenario
You deployed Apache Mesos. The web UI is having problems. You see the error “Failed to connect to x.x.x.x:5050.” What should you do?

Solution

  1. Go to the back-end of the Apache Mesos server. Run this command: sudo systemctl stop mesos-master
  2. sudo find / -name mesos-master.sh
  3. Change directory into the parent of the “bin” directory that houses the mesos-master.sh as found above.

 » Read more..

How Do You Create a REST API Endpoint?

Problem scenario
You want a REST API endpoint. How do you create a URL that is a proof-of-concept to trigger a Python program?

Solution
Prerequisites
i. You have installed Python 3. If you are using CentOS/RHEL/Fedora, run this: sudo yum -y install python3
ii. You need a web server installed. If you do not have one,

 » Read more..

How Do You Delete Browser Data from Chrome when Your First Attempt Failed?

Problem scenario
In Chrome you deleted browsing data including cookies and autofill form data. You closed the browser and reopen it, but old URLs still show up. What should you do?

Solution
Go to History -Clear browsing data -and go to “Time Range” (the drop down menu). Choose “All time” and then go to “Clear data”.

 » Read more..

How Do You Get curl to Work when the Web Page is Working?

Problem scenario
You can download a file with Lynx and wget. But curl is not working. What should you do?

Solution
First, try to curl the web page without redirecting the output. If the curl command creates a file, it does not necessarily give you an accurate depiction. You may want to examine the file with a text editor. What you see without redirecting the output to a file (that is allowing the output to echo to the screen) may provide a clue.

 » Read more..

When Does the DNS Server Override the /etc/hosts File for FQDN or Domain Name Resolution?

Problem scenario
You notice that on some Linux servers the /etc/hosts file controls the resolution of hostnames and on other servers the DNS server overrides the /etc/hosts file. Which has precedence in DNS resolution, /etc/hosts or the DNS server on the network?

Answer
It depends. The /etc/nsswitch.conf file will decide. There is a “hosts” stanza. This setting will have the DNS server override the /etc/hosts file:

hosts:dns files

This setting will have the /etc/hosts file take precedence for name resolution:

hosts:files dns

To get the hostname,

 » Read more..

How Do You Get a PHP Program to Invoke a Python Program via Browsing a Website?

Problem scenario
You want Debian/Ubuntu Linux to support a website. You want a Python program to run every time a web page is downloaded. How do you get a PHP program to invoke a Python program on Debian/Ubuntu Linux?

Solution

Prerequisites
i. This assumes you have Apache2 and PHP installed. If you need assistance run this: sudo apt -y install apache2 php
ii.

 » Read more..

How Do You Create an Issue for a Repository in a GitHub Organization the API?

Problem scenario
You are running this command:

curl -u jdoe:$password -X PUT -d ‘{“title”: “Look at this bug”, “body”: “This is a serious problem here.”, “assignees”: [ “jdoe” ], “milestone”: 1, “labels”: [ “bug” ]}’ https://api.github.com/repos/$orgname/$reponame/issues

The message in the response you receive is “Not Found”. You found documentation that refers to an “owner” being in the URL. You see “POST /repos/:owner/:repo/issues” (with no reference to the organization).

 » Read more..

How Do You Create a GCP VM to Be a Web Server?

Problem scenario
You have a GCP server. You can run curl commands to its URL via localhost. But with a URL constructed with the server’s external IP address the curl command times out. You cannot reach the URL from your workstation. How do you get the GCP server to present the web service to other machines?

Solution
Modify the firewall rule by following these steps below.

 » Read more..