Posts tagged ‘Linux’

How to set Apache start at boot time on Linux

If you feel lazy to restart the httpd service everytime your machine boot up, just do following simple steps:

  1. Enter below command to show the runlevel information of the httpd service
    chkconfig –list | grep httpd
  2. You get something like this:
    httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  3. Then, set up httpd to start at boot time.
    chkconfig httpd on
  4. Now to can verify by reviewing the runlevel information of the httpd service
    chkconfig –list | grep httpd
  5. Output should be.
    httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  6. You’ve done !

If you just want to enable the servive for a certain runlevel (e.g. graphic mode or non graphic mode), you can use below command instead where 3 indicates the runlevel.

  • chkconfig –level 3 httpd

This method can be applied to enable/disable other services at boot time. So, to list available services on your machine, run the command:

  • chkconfig –list

Thanks http://www.linuxforums.org for this simple solution.

March 29, 2012 at 12:55 am Leave a comment

Linux shell scripting: /bin/sh : bad interpreter: No such file or directory

I usually get the below message when creating a Linux shell script with text editors like Notepad or Wordpad on Windows PC and executing it on Linux box:
 
“: /path/to/scriptfile:/bin/sh^M: bad interpreter: No such file or directory”
 
The top of the script is a line specifying the shell program by which the script is interpreted: 
 
#!/bin/sh
 
Double-check if there is any typo in the script file or the /bin/sh exists on the Linux machine. It sounds like everything is OK. Now, I am sure the error caused by the text editor used to create the script file. In fact, text editors of different platforms like Mac, PC, Linux can create text files with different formats and this is the reason of the error.  In our case, line ending characters by the text editor on Windows are different from the ones on Linux which cause the shell scripted not be interpreted in a right way. To fix the error, do following steps at Linux command line:
  • Open the script using vi program

vi /path/to/scriptfile

  • When file is opened, change the format of the script to the right one by entering

: set fileformat=unix

or just simply

: set ff=unix

  • Finally, save the script for the new format taking effect and exit the vi program by entering

: x

Now, the script is working fine without any error. An easy way this avoid this problem is creating scripts directly on Linux with vi program.
 
Please note that using text files of another operating system on Linux may result in similar problems. For example, some errors when compiling your source code files or a program can not read data text files. These problems can be solved using the solution in this post.
 

January 6, 2012 at 11:57 am 2 comments

How To Set Environment Variables in Windows ?

You want to run a program from command line (CMD program) of Windows and you hate to retype the long path to that program very time you use it? Like me, I am also lazy to do this job every time I compile and run a Java program. Luckily, there is an easy solution to help us same time on running programs. That is setting Environment Variables.

But what are “Environment Variables”? Oh! They are variables, simply (like any variables that you declare and use while you do programming…if you are a programmer). The only difference is that Environment Variables are defined by Operating System like Windows or Linux and you can edit them in the way you want. In this post, I show you how to change Environment Variables in Windows. For Unix / Linux/ Mac OS, please see my other post here. Below instructions are showed with the screenshots of Windows 7. It may be different on other Windows versions

1. From the desktop, right-click My Computer, and then click Properties.

 

2. Click the Advanced System Settings option (if you use Windows Vista or Windows 7, otherwise, go to next step)

3. Click the Advanced tab.

4. Click Environment variables.

5. In the User Variables section, choose a variable the you want to change (in this case I chose PATH) and then click Edit

6. Edit the value of variable in Variable Value box (e.g. I added the path of my program to the end of PATH string and separated it with other paths by semi-colon (;))

7. Click OK and you’ve done

PS: The System Variables are also Environment Variables but they apply to all computer users. If you change them, they will affect all other users. You must be an administrator to modify these system environment variables.

December 12, 2010 at 5:50 pm Leave a comment

Linux File System Layout

Below are file system layout that is commonly used by Linux distribution:

  • /bin, /usr/bin: directories with user level command binaries
  • /sbin, /usr/sbin: directories with administrator level command binaries
  • /lib, /usr/lib: directories with static and shared libraries
  • /usr/include: directory with include files
  • /etc: directory with configuration files
  • /var/log: directory with system log files
  • /usr/share/doc: directory with various documentation files

(Source: http://techbu.com)

Details of Filesystem Hierarchy Standards are available here

June 30, 2010 at 1:17 pm Leave a comment


Recent Posts

/openmp AMD app fixing dead pixel iphone C++ cmd program CPU C sharp dead pixels directory download ibm synthetic data generator Dynamic Dynamic Memory Allocation Edit Environment Variables in Windows Environment Variables error lnk2019: unresolved external symbol _getprocessmemoryinfo@12 referenced in function error lnk2019: unresolved external symbol _ getprocessmemoryinfo@12 referenced in function "void __cdecl printmemoryinfo(unsigned long example code Fixing Dead Pixels and Gray Lines on the iPhone Screen Fixing Dead Pixels on the iPhone Screen Fixing Gray Lines on the iPhone Screen Fix iPhone getprocessmemoryinfo GPU Gray Line iPhone Screen gray lines gray pixels green pixels GUI how to "new" a two-dimension array in C++ how to use ibm quest synthetic data generator ibm data generator ibm quest data generator ibm quest data generator exe ibm quest data mining project ibm quest market-basket synthetic data generator ibm quest market basket market-basket synthetic data generator ibm quest synthetic data generator ibm quest synthetic data generator linux ibm synthetic data generator ibm synthetic generator Intel iPhone Iphone 3G iPhone 3GS iPhone 4 iphone gray lines on startup iphone pixel damage iPhone Screen iPhone screen damage Linux market-basket synthetic data generator Memory Allocation Multicore multithread multi thread multi threaded multithreading mysql extract data into file new OpenCL Path processor quest data generator quest synthetic data generator R SAS Set Environment Variables Set Environment Variables in Windows souce code source code stuck pixels system file two dimension array Windows 7 Windows Vista