I've owned and managed multiple websites for over a decade now.¬† I've noticed most of the servers I've used listed "Shell Access" as one of the features.¬† Up until a few days ago, I didn't even know what Shell access was and have never had a need for it.¬† Once the need arose to access my server using Shell, I realized just how powerful a tool it is.
Basically Shell gives you access to a command prompt on your server.¬† It looks and operates much like the MS-Dos windows many of us are familiar with.¬† There isn't a GUI.¬† Everything you do must be executed using standard SSH commands.
In the past, I've always accessed my server using a free FTP program like Filezilla.¬† Most FTP programs will allow you to upload files and change their permissions.¬† Usually, that is the extent of it.
My need arose to have SSH access when I lost ownership of some files on my server.¬† When I attempted to delete a directory on one of my server accounts, I kept getting an "access denied" error.¬† When I called my hosting company, I had lost ownership of the files.¬† The tech representative was nice enough to walk me through the process of regaining ownership using SSH should this problem occur again.
After playing around with SSH access for a few hours, I really regretted not using this tool sooner.¬† It is a real time saver.¬† So if you are interested in using SSH to access your server, here are some basics to get you started.
First of all, you need a SSH program.¬† The tech at my hosting company recommended I download a free Shell access program called Putty.
Once you download Putty, you'll need to select SSH as the connection type and enter the host name or IP address to your server.¬† The simply click open.
A black window will open that will have the words login as in the upper left screen.¬† This is where you will type your login name and press enter.
The next line that will appear will ask for your password.¬† Simply enter your password and press enter again.
Provided you entered the correct user name and password, you'll be given a command prompt.
If you type in ls followed by enter, you'll be given a list of the files and directories on the server.¬† (Lower Case LS, yes commands are case sensitive)¬† This works much like the dir command did in MS-Dos.
One thing I noticed on my server is the ls command didn't show the home folder.¬† The home folder is where all the accounts / domain names reside on my server.¬† So even though I didn't see the home directory using the ls command, I was able to access it using the command below.
"cd" is the command to change directories.¬† Please note, there is a space between cd and /.
After changing directories, I used the ls command again.¬† This time, I could see all the accounts on my server.
Now if I ever lost file ownership again, I could use the cd command to change into that directory and use the command I'm going to show below to take ownership of the file.¬† But after playing around, I found a much bigger use for SSH access.
I was in the process of loading a new shopping cart to my site.¬† The cart had over 4,000 files and took more than an hour to upload using standard FTP.¬† Then when the upload completed, it took another hour to change the file permissions of all 4,000 plus files.¬† I learned this process could be accomplished in less than 10 minutes using Shell.
First of all, I uploaded a single zip file to my server using FTP.¬† I'm not sure if there is a method for uploading using Shell.¬† Since the shopping cart was compressed into one file, I found it easier to just use FTP to upload it to my account.¬† It took less than 2 minutes.
Once the file was on my account, I accessed the account using SSH as I laid out above.¬† Once I used the change directory command to move inside of the directory that had the zip file, I was able to view it and verify I was in the correct spot by using the ls command.
Unzipping the files was a simple as using the command unzip followed by the file name you want to unzip.¬† This only works if you are inside the directory of the file you want to unzip.¬† In my case, the compressed file was cart.zip.¬† So my command looked like this.
(remember, everything is case sensitive)
In less than 15 seconds all the files had been unzipped and were in the correct spot.¬† The only thing left to do was to change the file permissions and ownership of the files.
In order for the cart to work correctly, I needed to change the permissions of every single file and directory to 777.¬† This was as simple as using this command where directory is the name of the directory that holds all the cart files.¬† The -R instructs the command to chmod every directory and file inside of that directory.
chmod -R 777 directory
In my specific case, the command looked like this
chmod -R 777 mywallet/
Last of all, the ownership and group settings of all the files were defaulted as root since they had been unzipped using SSH.¬† Move inside the directory you want to change and use this command.
chown -R ownername:groupname *
Once again, the -R instructs the command to change ownership and groups for every directory and file inside of that directory.¬† In my specific case, my group name and owner name were "mywallet".¬† I was able to determine this by uploading a file using FTP.¬† I noticed the files defaulted to mywallet as the owner and group when using this method.¬† So in my case, the command looked like this.
chown -R mywallet:mywallet *
If you enjoyed this post, make sure you subscribe to my RSS feed!