Hardware Tutorials

Tutorials on hardware, software, operating systems and more.

View all PHP scripts currently running

Need to get a list of all the PHP scripts currently running? Actually, this technique works for everything, you just need to change the argument you pass to grep, but for the purpose of this example, I’m going to say we’re looking for PHP scripts.

ps aux | grep php

This will then produce a list of all the scripts. The ps aux command gives us a list of every processing running on the system. We then pass this through to grep and search for what we want – in this case processing which contain “php”.

No Comments »

Installing MongoDB on CentOS 6

I would have written a guide on how I did this, but the blog post over on If Not True Then False covers it perfectly, so just go over there and follow their guide.

No Comments »

Saving files in memory

If you need super quick access to a file, for example a log file which isn’t going to be too big but it being used by a script which is time critical, then rather than writing it to disk, you can mount part of your file system in memory and write to it there.

This has the disadvantage that when you restart your system, you will lose the data. But for test scripts, logs or other temporary files that you don’t mind getting lost, it can really speed up performance.

Luckily, most systems come with a an area mounted in memory already – so you don’t even need to configure it!

cd /dev/shm

If said directory exists, you’ll have a memory mounted directory already and can start using it immediately.

No Comments »

Editing your hosts file

If you want to put custom entries in your computer’s DNS (for running addresses for a local server for example) you need to edit your system’s hosts file. On Unix systems this can be found at:

/etc/hosts

On Windows systems, you need to go to:

C:\Windows\system32\drivers\etc\hosts

To add a custom entry, first enter the IP address (if you’re running a local server you’ll want to set this as 127.0.0.1), then put a tab and then the host name.

No Comments »

Using TextEdit as a text editor

One utility Mac OS X seems to be lacking is a simple text editor such as Notepad for Windows. It comes with TextEdit but the problem is that this uses rich text format (RTF) which is very annoying when editing system files or code.

Thankfully, you can reconfigure it to use plain text.

Simply go to TextEdit on the menu bar and hit Preferences. The top option should allow you to toggle between Plain Text and Rich Text.

No Comments »