Open Directory or file starting with a “-” (hyphen)


How to open a Directory or a file starting with a “-“, hyphen

Those of you who have not been in such a situation would never know how it feels when you are stuck opening/deleting a file or directory. The more you have been working on the shell, the more it sucks. When I tried all I could to get it work and still ended up with the same error all the time, I just sat on my chair, staring at the monitor for a while, wondering if this is somekind of bash’s loophole :P.

I was trying to grep through some pidgin facebook chats when I was stuck for a while trying to open a directory with the name starting with a hyphen(“-“). I tried all I could think of, but I always ended with the same error.

[shredder12]$ cd -directory
bash: cd: -d: invalid option
cd: usage: cd [-L|-P] [dir] [shredder12]$ cd \-directory

[shredder12]$ cd *directory

[shredder12]$ cd "-directory"

As you can see the trouble is that the alphabets after a “-“, hyphen, are being considered as the command attributes/options but they are not, so what we need here is:

a way to tell the command that its not an option or, make the command start with something other than a hyphen.

The first method is to use a double-dash “–” before the name. A double-dash means the end of options to that command.

[shredder12]$ cp -- -directory/

For the other way, we need to start the command with something other than a hyphen and still make sure that its the same file.

[shredder12]$ cp ./-directory

Nautilus Terminal

Nautilus Terminal is an integrated terminal for Nautilus
What is new in latest version 0.3

* Fixes the bug with “infinity” bash fork (lp:635846)
* Improve separation of property between nautilus’ windows
* New translations

Install Nautilus Terminal in ubuntu

Open the terminal and run the following commands

sudo add-apt-repository ppa:flozz/flozz
sudo apt-get update
sudo apt-get install nautilus-terminal
nautilus -q

nautilus -q will restart nautilus

Define memory in linux


If you are looking to upgrade the memory in your Linux PC, you are probably wondering how many open slots you have, what type of memory is already installed, and what you need to buy for an upgrade… without having to open your computer.

Since you shouldn’t have to open up the computer just to figure out what you have installed, here’s how to detect the type of memory your Linux PC has installed without having to open up the case.

Note: be sure to read our article on how to tell what type of memory your Windows PC has installed.

How to Show the Installed Memory

Open up a terminal window and type in the following command:

sudo dmidecode --type memory

At the beginning of the output you’ll see the maximum memory size allowed by your PC, which is important—you can’t put two 4GB memory modules into a machine that only allows a total of 4GB of RAM.

Once you’ve scrolled down a little further, you’ll see the rest of the memory details for each piece of RAM that’s installed. Here’s a sample from one of my Linux boxes, and I’ve highlighted the important bits in bold text.

Handle 0×0120, DMI type 17, 27 bytes
Memory Device
Array Handle: 0×011F
Error Information Handle: No Error
Total Width: 64 bits
Data Width: 64 bits
Size: 512 MB
Form Factor: DIMM
Set: None
Locator: DIMM0
Bank Locator: BANK 0
Type: DDR2
Type Detail: Synchronous
Speed: 667 MHz (1.5 ns)
Manufacturer: 0×7F7F7F0B00000000
Serial Number: 0xC773441A
Asset Tag: Unknown
Part Number: 0×4E543531325436345548384230464E2D3343

You’ll see that I’ve got DDR2-667 RAM installed on the system, so if I’m going to upgrade, I’ll need to find RAM that matches.

How to scan websites for viruses and malware

How to scan websites for viruses and malware

Viruses and malwares can break into your system from a number of sources and cause serious impact on your computer system. Hence, it is extremely essential to protect your computer such threats. Most of us are aware of the fact that e-mail attachments, torrents, P2P clients, etc are some of the most common sources through which viruses and malwares infiltrate into our system. But nowadays, even websites have become as infectious as any other source.

Fortunately, there are lots of online scanners that can quickly scan websites for any malicious content. If you are a webmaster wanting to scan your website or you just want to check a website for malicious content, below are few of the best tools that can help you to do so.

1. – is a really handy tool to scan any website for malicious content. Just enter the URL of the website you want to scan and then hit the “Scan Now” button. Within just a few seconds, you will get a report stating whether the site is clean or not.

2. AVG Online Web Page Scanner – AVG Online Web Page Scanner enables you to scan suspicious links for viruses and malware. It scans the web pages in real-time and checks if the web pages contain any hidden drive-by downloads.

3. Google Safe Browsing – This handy little tool from Google enables you to test any website for malicious content. It is based on the Google Safe Browsing API. To test any website all you got to do is enter the following in your address bar –

4. Online Link Scan – Online Link Scan is a fast, easy-to-use tool that enables you to scan any URL for viruses, malware as well as phishing. It uses the reports generated by PhisTank, AVG, Google Safe Browsing as well as SiteTruth to provide you an overall report of the target URL.

5. Norton Safe Web – Norton Safe Web is a new tool from Norton that analyzes web sites for online threats like viruses, malware, spyware and phishing. It scans the target URL and provides you detailed reports about the various threats on the site. It also creates a Norton rating based on the reports.

6. Dr.Web Online Check – Dr.Web Online check quickly scans websites for viruses and malwares and reports if the website is clean or not. All you gotta do is enter the URL and hit the “Scan” button. It quickly scans the website and creates a report stating whether the website is clean or not.

The 10 Golden Rules for Troubleshooting Linux


1. Man pages exist and should be used. Seriously, everything’s there, from application docs to syscall docs to syntax and formatting of log files.

2. Don’t reinvent the wheel. 99% of problems you’re experiencing or ever will experience, somebody’s already gone through it and figured it out. Google is your friend.

3. If you don’t know what something’s doing, or why it’s not working, strace it!

4. Logs exist for a reason. Read them.

5. Applications crash, servers don’t. If your server crashes, it’s either bad hardware or a kernel bug (fairly rare on popular distros).

6. Always make backups. Always.

7. Always mount NFS mounts with the ‘intr’ option. Having to reboot because of a network blip is uncool.

8. Learn to use `grep’, `sed’ and `awk’. Learning to manipulate text is surprisingly important for a text-based interface.

9. Load average does not mean CPU usage. 100% memory usage does not mean you don’t have any more available for new applications. You can run out of inodes before you run out of disk space.

10. TCP wrappers suck. If you’ve been hacking at an issue for over 3 hours, look to your TCP wrappers. /etc/hosts, /etc/hosts.allow and /etc/hosts.deny will hold the answer.

also check the forums related to your software, they can be invaluable.

Get email notification of root login

Have root logins emailed to you

1. Login to your server and su to root, unless you logged in as root already.

2. cd /root (unless your default login folder is already root)

3. pico .bashrc (or use your favorite editor)

4. Scroll to the end of the file then add the following:
echo ‘ALERT – Root Shell Access (YourserverName) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`”

Replace YourServerName with the handle for your actual server for example dwhs4 @

Replace you @ with your actual email address for example support @

5. Crtl + X then Y

Now logout of SSH, close the connection and log back in! You should receive an email address of the root login alert a few minutes afterwards.

setroubleshoot bug


There is a bug with the new option in Centos 5 called setroubleshoot.

The bug spins the program over and over causing high memory and sometimes CPU use. Unfortunately there is no permanent fix yet, but if you see something like this high in your daily process log:

/usr/bin/python -E /usr/sbin/setroubleshootd

To fix for now you simply have to restart the process:

/etc/init.d/setroubleshoot restart

or set up a cron to restart the service as needed.

Track email sent via PHP script – cPanel


Track what PHP script sent an email on your cPanel server

There is a patch available from which forces PHP scripts to store the script name and location in the mail headers when using the mail() function. The below instructions will give you the details needed to add this patch to your cPanel server:

1) Log into the server as root via ssh or the console.
Run PHP Code:
mkdir -p /var/cpanel/buildapache/scripts

Create a file called phppost using a text editor like vim and add the following lines:
PHP Code:

PHPVER=`find -type d -iname "php-*"|sed "s/.///g"`
patch -p0 < $PHPVER-mail-header.patch

Save and quit that file.
Run PHP Code:

and now the patch will be automatically applied.

When you receive spam complaints you will now be able to look at the headers of the message and view what script and site these came from. This is extremely useful because PHP runs as nobody unless phpsuexec is enabled and in a virtual environment it can be difficult trying to track down the broken script!

File system info

Earlier, a client asked a simple question…

how many subdirectories can you have in a directory?
how may files can you have in a directory?

I doing a little research, I came across some basic info to pass along regarding this;

The ext3 file system has a limit of about 32000 subdirs per dir. The maximum number of files per directory is theoretically unlimited (actually around 130 trillion), but performance becomes terrible with above 10 to 15 thousand files. The max number of total files on the file system is limited by the number of inodes you have.

For more information regarding this, please see the following informational links:

Just a little random info for you… 😉

Convert MySQL from MyISAM to InnoDB Using a Script


How to Convert MySQL from MyISAM to InnoDB Using a Script

Okay. So I need to convert MySQL database using the default MyISAM engine to the InnoDB engine. The command is simple:

ALTER TABLE table_name ENGINE = InnoDB;

However, this command needs to be done for EVERY table. Yes, it’s a pain in the rear… so here’s a way to do it by scripting.

Scripting a MySQL InnoDB Engine Conversion:

1) Backup your database. You should probably be doing this already. Now’s a good time to make sure that your backups ran.

2) Create the script. You’ll need the correct permissions to query the database. Here’s the command. Be sure to change as it fits.

mysql -p -e "show tables in ;" | tail --lines=+2 | xargs -i echo "ALTER TABLE {} ENGINE=INNODB;" > alter_table.sql

3) Run the script.

mysql --database= -p < alter_table.sql

Verify it by running this command in mysql:

mysql> show table status;

Discussion (If You’re Interested)

The script is simply a bunch of ALTER TABLE commands for each of your tables in the database of question.

The mysql -p -e “show tables in ” command gets a list of the tables. This list has a header that looks like “Tables_in_DATABASE”. The tail command drops that first header line. Now you have a clean list of tables. The "xargs -i echo" command creates the ALTER TABLE command, inserting the table name where the squiggly braces {} are placed. It’s now stored in alter_table.sql.

Step two simply runs the script that we stored in alter_table. Both mysql commands will prompt for a password, based on the -p flag.