If you run a website, you may have experienced some down time. Occasionally, the web server can go down. It would be great if we can get an email when the server is down.
Linux
Ubuntu log out GUI from SSH
In Ubuntu, we can log out GUI from SSH: pkill -u username
Migrating Website to Amazon AWS EC2
This post shows how to migrate a php website from 1and1 shared hosting to Amazon AWS. I mainly cover the Linux command lines and various configurations since they are often the difficult part. I will cover the steps for creating instances of AWS because they can be done by following the guide provided by Amazon … Read more
How to install Latex on Ubuntu 14.04LTS
You may often get error messages like “missing subfigure.sty”, “missing url.sty”, or missing other .sty files. The problem is caused by missing packages. This post outlines the steps to correctly install latex on Ubuntu latest version 14.04LTS. It should also work for most previous other versions. 1. Install Latex on Ubuntu In the terminal, type … Read more
Java Runtime.exec() Linux Pipe
If you want to utilize Linux pipe advantages, you can do it in Java. You may want to do the following, which is wrong. String cmd = "ls" Process p = Runtime.getRuntime().exec(cmd);String cmd = "ls" Process p = Runtime.getRuntime().exec(cmd); The correct way of executing shell command is the following: String[] cmd = { "/bin/sh", "-c", … Read more
Linux shell script read file line by line
The following are different ways of reading a txt file line by line in linux shell. To fun the following scripts, you should create a “test.txt” file under the same directory with your script. Method 1 Use file names as parameter to the shell script. readFile.sh #!/bin/bash while read line do name=$line echo “Text read … Read more
Linux Command: Replace a String in Multiple Files
If you want to replace a string in multiple files in a folder, you can use the following command: cd /path/to/folder sed -i ‘s/foo/bar/g’ * In the command line above, all occurrences of “foo” will be replaced with “bar”.
5-Minutes Guide for Commonly Used Linux Commands
I’m not a serious Linux user, but sometimes I need to use Linux. In a long time, I frequently searched a limited number of Linux commands. So I think it is a good idea to list those frequently-used ones and remember them finally. This definitely improved my work effectiveness. Here is my list. 1. cp/scp … Read more
Enter password to unlock your login keyring Ubuntu 12.10
Here is a note for how to disable this password prompt under Ubuntu 12.10. The problem looks like this whenever you open browser first time after you start your computer. Error Message: “Enter password to unlock your login keyring” Ubuntu 12.10. Alt + F2 and then type in “seahorse” Click view → keystring Right-click login … Read more
Firefox is already running – linux .parentlock problem
While using a Ubuntu linux machine, this can happen for a lot of people. This is the solution. Error Message: “Firefox is already running but is not responding …” The problem: Many packages (like firefox) create lock files in your account to prevent database corruption with multiple copies of the application. Look in your account … Read more
Trace Source Code in Eclipse: Attaching source to a JAR file
The API document only list the description of class, interface, and methods. If you want to trace back to the original implementation code by clicking “F3” button in Eclipse, then source file need to be attached. The source file under window is here: C:Program FilesJavajdk1.6.0_24src.zip http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/org.eclipse.jdt.doc.user/tasks/tasks-115.htm
Linux Pipe for Communication Between Java and C++ program
Pipe is neat. A pipe is a way to connect the output of one program to the input of another program without any temporary file. This simple test contains a Java program and a C++ program. The output of Java program is used as input for “wc” command, and the output is then used by … Read more
Linux Shelling Programming Warm-up Example – $?
This shell program mainly demonstrate how to use $? to find out the exit status of command.
After a command executes, if you input to terminal: echo $?, you will get 0 or 1 to indicate the status of execution.
The following is a simple program with comments.