Any decent Linux-based web hosting service would allow customers to access the server via SSH. SSH is short for Secure Shell. Using SSH, you can access your web hosting server to perform administration as well as file manipulation.
To know if your web hosting provider allows customers to access their servers using SSH, you need to ask the contact person. You would also need an SSH client. If you’re using Windows, I recommend that you download PuTTy.
Logging On To Your Server
Fire up PuTTy and under the Host Name (or IP address) section, type in your domain name. If your web site is at yourserver.com then enter that hostname into the text box, like the example below.
If this is the first time you’re accessing your server using PuTTy, you will see a security alert warning similar to this:
If you’re sure that you’re logging on to the correct server, then you can click the Yes button confidently.
You should then see a black window asking your for your username. If you’re on a CPanel-based web hosting subscription, this would be your CPanel username.
After you’ve entered your username, you will then be prompted to enter your password. Again, if you’re on CPanel-based web host, this will be your CPanel password.
If you entered these details correctly, you’ll be greeted with a shell prompt that will look similar to this:
Congratulations! You’ve successfully logged on to the server.
Now, you might want to navigate to your web directory. On CPanel hosts, this would be at
/home/yourname/public_html/. So all you need to do is enter the following command:
The tilde character: ~; is a shortcut to your home directory. Therefore if your username is yourname, entering the command above would take you to
Grabbing Pictures From Other Web Sites
Before you proceed any further, you should always understand the licensing terms of images you want to grab. Failure to do so might land you in trouble if the owner decides to take legal action against you.
In this example, I’m going to grab a picture of a lion cub from my own Flickr account. How do I do this from the Linux command line? Just type in the following:
wget URL of picture you want to download
This command tells the server to use the wget software to grab the file from the URL you provided. It does not necessarily have to be pictures. But in this example, I’m going to grab the lion cub picture.
The first thing I need is the URL to the picture. Since I’m using Firefox, I can just right-click on the picture and click on the Copy Image Location menu item. It tells me that the URL to the picture is: http://farm1.static.flickr.com/188/436307942_5269540c81.jpg?v=0.
I’m going to ignore the
?v=0 part because that is not part of the actual image filename. So now, I can grab the picture using this command:
If you’re on a fast server, the downloading should be almost instantaneous. You should now have a copy of that picture on your server. You can test it by typing http://yourserver.com/436307942_5269540c81.jpg in your browser’s address bar, replacing yourserver.com with your own domain name.
If you see the lion cub picture, than give yourself a pat at the back! You’ve successfully downloaded a picture using
You might want to rename the file to something easier to remember. The command to do this is as follows:
mv old-file-name new-file-name
Let’s say we want to rename the downloaded file to lion-cub.jpg, then we should use this command:
mv 436307942_5269540c81.jpg lion-cub.jpg
Note that you must also supply the file extension (the
.jpg part) as well.
Resizing The Picture
If you’re on a decent Linux hosting package, it should come preinstalled with the ImageMagick image manipulation software suite. Using ImageMagick, you can manipulate images easily via the command line.
In this example, I’m going to resize the lion cub picture to have a width of 200 pixels instead of its original 500 pixels. I also want the height to be automatically calculated for me so that the picture won’t be stretched unnaturally.
The command to do this is very easy:
convert -resize width filename newfilename
So, in order to make my lion cub picture to have a width of 200 pixels, and save the smaller picture as lion-cub-small.jpg, I would run type in the following at the command line:
convert -resize 200 lion-cub.jpg lion-cub-small.jpg
Simple, right? Just by typing a few command you have done the following:
- Download a remote picture directly to your server
- Rename it to something easier to remember
- Resize it to become smaller and keeping the original
You can then embed the picture in your web site very easily.
Here is the image file renamed to
lion-cub.jpg that I grabbed from Flickr:
Here is the resized version of that picture;
Sure beats downloading the picture to your computer, resizing it using an imaging software, and uploading it to your server, right?
If you find this guide useful, please subscribe to my feeds to get updated instantaneously whenever I post something new. I regularly update HTNet with hints and tips just like the one you’ve just read.
What do you think of this guide? Was it helpful to you? I would love to hear your comments!