directories – Internetblog.org.uk https://www.internetblog.org.uk Web hosting, Domain names, Dedicated servers Fri, 29 Jan 2016 11:05:52 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.5 https://www.internetblog.org.uk/files/2016/01/cropped-favico-32x32.png directories – Internetblog.org.uk https://www.internetblog.org.uk 32 32 How to Make an Entire Directory Path https://www.internetblog.org.uk/post/1454/how-to-make-an-entire-directory-path/ Tue, 22 Jun 2010 20:30:38 +0000 http://www.internetblog.org.uk/post/1454/how-to-make-an-entire-directory-path/ 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.

]]>
How to Sync Two Websites on the Same Server https://www.internetblog.org.uk/post/1410/how-to-sync-two-websites-on-the-same-server/ Wed, 09 Jun 2010 17:19:03 +0000 http://www.internetblog.org.uk/post/1410/how-to-sync-two-websites-on-the-same-server/ network sharing iconQuestion: I have two separate websites that I want to have identical data on each site. How can I do this?

Answer: First of all, to sync files on two separate sites on the same server, you will need to have a user that has write permissions on both sites. If you are using a shared hosting account, and both sites are under your account, you probably already have this. For a VPS that has a unique user for each site, you will need to use the root user.

Next, you need to know the full path to the directories for both sites. For example, site one may be /home/user/www/html/siteone.com/html and site two may be /home/user/www/html/sitetwo.com/html. To sync both directories and keep them synced even when data changes, the best choice is rsync. Although rsync is normally used for remote syncing, it also works for local directories.

To sync the two directories, you would use this command:

rsync -avc /home/user/www/html/siteone.com/html/ /home/user/www/html/sitetwo.com/html/

If you want the sync to be performed periodically and automatically, you can create a script and then drop it into one of the cron directories, such as cron.daily. You can also setup a manual cron job in /etc/crontab. From now on, both sites will show identical information.

]]>
How to Display Files Modified Today https://www.internetblog.org.uk/post/1384/how-to-display-files-modified-today/ Wed, 02 Jun 2010 15:43:30 +0000 http://www.internetblog.org.uk/post/1384/how-to-display-files-modified-today/ 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:

./syslog
./lastlog
./user.log
./auth.log
./daemon.log
./mail.info
./syslog.1

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

]]>
Linux file and directory structure https://www.internetblog.org.uk/post/793/linux-file-and-directory-structure/ Thu, 17 Dec 2009 15:45:57 +0000 http://www.internetblog.org.uk/post/793/linux-file-and-directory-structure/ 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.

/lost+found
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

]]>
Password Protecting Your Directories https://www.internetblog.org.uk/post/664/password-protecting-your-directories/ Wed, 11 Nov 2009 14:51:33 +0000 http://www.internetblog.org.uk/post/664/password-protecting-your-directories/ password dialog
Question: How do I password protect a directory on my website?

Answer: Many web hosting control panels offer a “password protect” feature for your directories. If not, there is a moderately easy way to do it with an Apache .htaccess file.

First, create an .htaccess file that looks like this:

AuthUserFile /home/yourname/.htpasswd
AuthName “Password Protected”
AuthType Basic
require user yourname

Replace “yourname” with your desired username. Next, you will need to create the .htpasswd file in the location you specified. This requires you to have an encrypted password entry:

username:encryptedpassword

Use the following form to create one: Htpasswd Generator.

]]>