Getting to Grips With SSH – Part 4
By Ollie Armstrong Thursday, 1st July 2010
Welcome to the fourth blog in the series of posts teaching you basic SSH commands.
In this part, we will be building on what you learnt last time to improve your directory navigating, and also going over some more advanced switches.
Once again you will need to connect to your vCluster, and once again I will refer you to the tutorial on connecting to your vCluster. If you haven't read the third part yet, then you can find it in Getting to grips with SSH part 3.
Right, with all that stuff out of the way, lets get started!
Showing Current Directory Path - pwd
I went over this one incredibly quickly in the last part just so I could use it in an example to demonstrate something. Now lets go into what it really does. I assume you know what a directory path is, but for those that don't - it is basically a description of the folder you are currently in. In Windows, you can go into the My Documents folder, and then into My Pictures, this can be represented by a path. This would look something like...C:/Documents and Settings/ollie/My Documents/My Pictures/... that is the directory path. It shows you exactly what folders you are in. In Mac OS X (or most unix/linux systems) the directory path would look a little like this:
~/Documents/Work/2009/for a '2009' folder in a 'Work' folder in the 'Documents' folder. Now we have that sorted, lets get on to the command. If you run the command...
pwd... as soon as you connect, you will get a response similar to this (but with a different vCluster name and username). If you cd to the 'www' directory, and type 'pwd' again you will get the same as before but with the '/www' directory added to the end! That's all there is to this command, the only problem is remembering it. Not an easy one, but hopefully it will stick!
Deleting Files - rm
This is a really easy one to remember, remove a file. Its also just as easy to use. It is as simple as typing 'rm' and then the name of the file you want to delete.rm index.htmlAs you can see from the picture, 'rm' deleted the file while leaving the other one there. Sweet! Its just a shame removing directories isn't quite as easy. If you try and do 'rm' on a directory it will come back at you saying it won't delete a directory. But don't fear, this is easily overcome! Remember the -a switch we used with 'ls' to show all files?
ls -aWell we are going to do a similar thing, but with a different command, and different switch. Same format though.
command -switch rm -rTry and work out what the switch is from that command... Got it yet? Well done, its the '-r' switch! I think this is an appropriate time to just quickly clarify something, all switches are relative to the command they belong to. So an '-a' switch would do a totally different thing on the 'ls' command as it does on the 'rm' command. Phew, that's that sorted. Now, the '-r' switch allows us to remove directories without it getting all stroppy about it.
Creating Files - touch
The final command we are going to be covering today is....touchThis command allows us to create blank files directly on the vCluster which, trust me, is so much quicker and easier than creating a file locally and FTP'ing it. This command is used exactly like the 'mkdir' command.
touch index.html touch style.cssJust notice the required extension of the file, otherwise it won't create the correct type of file. As you can see from the image, I already had an images folder, but created index.html and style.css. Easy eh? Remember these files are blank, but dont worry, in the next part I'll go over editing files in a secure shell.
Conclusion
So, today we have covered:- Showing the current directory path
- Removing files/directories
- Creating blank files
Posted in Guides, SSH |
No Comments »





