files – Web hosting, Domain names, Dedicated servers Fri, 29 Jan 2016 11:05:52 +0000 en-US hourly 1 files – 32 32 Extra Large Log Files Wed, 14 Jul 2010 19:13:00 +0000 Linux syslog file
Question: One of my Linux system log files has suddenly become very large (several hundred megabytes). What should I do?

Answer: The first thing to find out is what exactly is happening in the log files. To see the latest log activity for your web server error log, for example, you would run:

tail -f /var/log/httpd/error.log

If the file is expanding, you should see errors popping up. When you are finished looking at it, press CTRL-C.

The next step is to fix whatever error you are receiving. If it is enough to fill up several megabytes or even a gigabyte of log space, it is a recurring error that should be fixed. For a web server, repeated failed connections could be some type of denial of service (DoS) attack. For a mail server, numerous open connections could mean that someone is using your server to send spam. The key is to find out exactly what the root cause is and then fix it. If you want to clear the log file, run:

> /var/log/httpd/error.og

Your logs will be back to normal size once your server is running normally again.

Completely Delete Files with Shred Thu, 24 Jun 2010 15:42:29 +0000 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

How to Make an Entire Directory Path Tue, 22 Jun 2010 20:30:38 +0000 File folder iconQuestion: How do I create an entire path of directories?

Answer: On a desktop computer, anytime you want to create a folder, you have to go through a series of clicks, type in the name, and press Enter. If you want to create a series of nested folders, you have to go through that process several times for each one. That is time consuming and not something you want to have to do on a server.

There are times when creating an entire path of directories may be very useful. For example, if you have a website photo gallery and want to setup the album directories, you will want to be able to quickly create those paths. You can do this easily from the command line and do not need to repeat steps.

On a Linux server, to create an entire path of directories, enter from the command line:

mkdir -p photos/2010/albums/zoo

On a Windows server, just reverse the slashes:

mkdir photos\2010\albums\zoo

This will automatically create the photos, 2010, albums, and zoo directories. With one quick command, you saved yourself four steps.

Removing Files on a Linux Server Mon, 21 Jun 2010 16:17:52 +0000 rm commands
An important part of file management is the removing of files that are no longer needed. Files, by their very nature, take up space, and something that is not needed should not take up space on a server, where space is money. The “rm” Linux command handles basic removal of files, but here are some additional settings you can use with “rm” to handle various types of removal tasks.

rm -l With the “-l” flag added after “rm”, the command will prompt you only when removing more than three files. You can use this as a precaution to keep from accidentally removing large amounts of data.

rm –one-file-system This instructs “rm” to remove only files that match the current file system, which is useful when removing several directories at once.

rm -r Recursive removal means that the top-level directory and the files and directories inside it will be removed together.

rm -v This displays information about the removal, rather than just returning to an empty command prompt.

rm -f To force removal without any prompting or warnings, use the “-f” flag, but please use it carefully.

How to Display Files Modified Today Wed, 02 Jun 2010 15:43:30 +0000 File folder iconThere are many ways to search Linux files and directories using grep, find, or locate. All of them find files that match certain search parameters, usually words or characters. On a Linux server, you can also find any files that were modified within the current day. This is useful for finding security exploits and generally tracking website usage.

Using the find command, you can look for all files modified in a specific directory within the current day. To do so, enter the following string:

find -maxdepth 1 -type f -mtime -1

The output will look something like this:


To find only the directories created on the current day, simply change the “f” to a “d”:

find -maxdepth 1 -type d -mtime -1

Using this information can help you track down possible problems. Certain files like ones listed above are supposed to be modified daily, but if you find files that should not be modified, that can be a clue to help you fix whatever ails your server.

Image Source: Wikimedia Commons

Binary vs ASCII FTP Upload Thu, 15 Apr 2010 17:20:05 +0000 Binary pillow
Many recent FTP program automatically detect your file type and upload them correctly without any problems; however, if your FTP software does not do this or if your file is unique and cannot be detected correctly, you will need to set either an ASCII or Binary upload method.

A binary file is a file that contains data, but that data is encoded in some type of binary form. This means that if you open up the file, you will not understand most of the contents, although some text metadata may be included. A computer, on the other hand, can read the file just fine. Examples include images, videos, and compiled software.

ASCII files are just the opposite. These files are human readable, even if they contain software code. They are in plain text format. Examples include html, txt, and php files. Your FTP program will have a selector that lets you choose which type of file it is or select automatic to have the program attempt to automatically determine the right type of uploading required.

Photo Source: Flickr

How to delete duplicate files in Linux Tue, 16 Feb 2010 19:45:00 +0000 terminal icon
Question: Two of my directories on my server have some the same files. How can I easily delete any duplicates while preserving the unique files?

Answer: There exists a Linux tool for just about everything, and this is no exception. You need a tool called fdupes, which searches the path you give it for duplicate files and uses several comparison techniques (sizes, MD5 signatures, byte-by-byte comparison) to find and eliminate duplicates.

First install fdupes. In RHEL/Fedora/CentOS, use the rpmforge repository enter:

# yum install fdupes

To find duplicates in the /etc directory, you would enter:

# fdupes /etc

To force fdupes to prompt you whether to preserve or delete files:

#fdupes -d /etc

As you can see, fdupes might be just what you need to clean up your server and possibly increase that precious disk space.

Source: nixCraft
Photo: Wikimedia Commons

The benefits of SFTP Thu, 14 Jan 2010 17:41:24 +0000 cyberduck
FTP is the primary method used by website owners to upload content to their servers or distribute large amounts of data. FTP is easy to use and generally efficient at doing its job, but no one would claim that it is completely secure. Generally speaking, files you upload to your website are public anyway, so you might not care if someone intercepts an FTP session’s contents.

When dealing with private information, however, it is a good idea to use a secure transfer method. It is also a better practice in general to use something secure so that your transactions and possibly client and user transactions are not available for the world to see. SFTP is a method of transferring data over an SSH channel.

There are SFTP clients available, and many FTP clients also support SFTP. They may even refer to it as SSH, since SFTP stands for SSH File Transfer Protocol. SFTP does require the user to have an SSH account, and some web hosting providers do not allow them, but if yours does, it is an excellent alternative to FTP.

Photo: Wikimedia

Linux file and directory structure Thu, 17 Dec 2009 15:45:57 +0000 GNU and Tux
An important part of knowing your Linux server is knowing where directories and files are. Most Linux distributions organize files in a similar manner, following specific standards. It is very different from the Windows file and directory structure, but once you know one Linux setup, you will pretty much know the basic layout of every Linux distribution.

/ The root directory, under which all other directories reside.

/boot Here Linux stores information about booting, including the kernel itself and the bootloader.

/etc Most system-wide configuration files are kept in this directory, particularly those you use for your web server.

/bin, /usr/bin, /sbin All of these are where Linux stores executable files. This is one area where it differs depending on the software and distribution.

/usr Most user applications are stored in various locations throughout /usr. Documentation, graphics, and others are also stored here, but only those installed by applications.

/lib, /usr/lib The shared system libraries are found in one of these directories.

/root This is the system administrator’s home directory, different from the root (/) directory.

/home Local users will have home directories within this one.

/var Variable data, such as log files, databases, and mail server queues is stored here.

/tmp Linux uses this directory to store system files.

/dev Devices are setup in this directory. Normally, on a remotely hosted server, you will not need to worry about this.

/mnt Mount points, particularly removable devices, are linked here when mounted.

/proc This is a virtual directory containing information about the kernel.

If you ever lose files or have something come up missing after a crash or file system check, Linux might have recovered it here.

In future posts, we will explore each of these directories to find out more about them and the subdirectories within them.

Photo Source: Flickr

Using the "ls" Command in Linux Tue, 17 Nov 2009 22:06:21 +0000 ls command in Linux
In Linux, few commands are more important when managing your file system than “ls”. On a server, it is very important to know how to view files and their properties. With “ls” you can view a simple list of files or any number of more complicated variations of the list.

Typing “ls” with no flags will give you multiple columns of files and directories in alphabetical order. Adding an “-a” flag will display hidden files (those with a “.” in front of the names). Add an “-l” flag, and you will see long format, with directory information, permissions, file size, and modification date.

Some servers are set to show colors by default. If yours is not, add the “–color” flag to show your directories and various files in different colors, which makes it easier to distinguish a directory from a file and an executable from a text file. Add an “-r” to display the results in reverse order. “-U” will not sort them at all and leave them in directory order. There are many other combinations and flags you can use with “ls”. For a complete guide, type “man ls” from the command line.