How to Delete Tables and Rows in MySQL

9 Jul, 2010

Mysql logoAs I mentioned in a previous MySQL post, knowing how to quickly perform database tasks from the command line is a good idea if you are a Linux system administrator. Sometimes, it is the easier way to get things done, especially if you are helping another user and need root access to his or her database.

To delete a table, first login to MySQL:

mysql -u root -p

Enter your password and then switch to the database you want to edit by typing the following at the mysql> prompt:

mysql> use [db name];

Finally, drop the table:

mysql> drop table [table name];

Replace [table name] with the actual name of the table you want to remove.

To remove a row, type:

mysql> DELETE from [table name] where [field name] = 'whatever';

When you are finished, type “quit” to exit.

(0) Comment Categories : Software, Web servers
Tag: , , , , , ,

Completely Delete Files with Shred

24 Jun, 2010

Shredded paper with the words grace period
On a Linux dedicated server, the normal method for deleting files is to use the “rm” command. This removes the file from the current filesystem, but what many do not know is that those removed files are usually recoverable. As such, rm is more like putting something in the trash or recycle bin on a desktop.

The only way to effectively delete a file is to overwrite the space the file was using. You can accomplish that with the “shred” command. Just like shredding important physical documents, shred makes sure your files are good and gone, so please use with caution. Once it is gone, it is gone.

On a web server, you may want to make sure you delete sensitive information completely (a database of credit card numbers, for example). To do so, run the following command:

shred filename

You can also shred it a number of times just to be sure:

shred -n 7 filename

This will shred “filename” seven times. For more information about shred, type “man shred” from the command line.

Photo Source: Flickr

(1) Comment Categories : Security, Software
Tag: , , , , , ,

How to delete multiple files in various directories in Linux

12 Jan, 2010

Mac OS X crashing after deleting Windows Thumbs.db files

Question: When uploading files to my Linux server from my windows computer, I have accumulated WS_FTP.log files and thumbs.db files in multiple directories. Is there an easy way to delete all of them at once without navigating through each directory?

Answer: With Linux, of course there is. You can accomplish this with the “find” command, and you can apply the same technique to any files you need to remove on a mass scale. To remove thumbs.db files, enter the following from a SSH command line:

find /home/user -name Thumbs.db -ok rm {} \;

And if you do not want to be prompted for each deletion, add the “-f” flag:

find /home/user -name Thumbs.db -ok rm -f {} \;

To find any other file, just replace the “Thumbs.db” with the appropriate filename.

find /home/user -name WS_FTP.LOG -ok rm -f {} \;

Source: webhostingtalk.com
Flickr: Flickr

(0) Comment Categories : Web Hosting
Tag: , , , , , , ,

The Delete Command in Linux

2 Nov, 2009

rm command
The second important command to know when using a Linux or Unix server is the rm command. This is the primary way to delete files from a server. Please use it with caution, as it is meant to be permanent. To delete a file, simply navigate to the directory with the file and type: rm filename.

To remove a file when you are not in its directory, you must type the full path: rm /home/user/public_html/filename.

If you want to delete a directory, you must make the deletion recursive by typing: rm -r directory-name.

You may delete multiple files, simply by entering each one on the line: rm filename1 filename2 filename3.

To delete directories and files without any prompting, enter rm -r -f filename1 filename2 directory3.

To learn more about the rm command, type: man rm at the command prompt.

Photo Source: Flickr

(0) Comment Categories : VPS & Dedicated, Web Hosting
Tag: , , , , ,