Alright, so you have your VPS and you have logged into it via SSH with PuTTY. You are presented with a terminal screen and you don’t know what to do now.
So lets go over a few basic shell commands you will need to know to get around your server. The following commands will teach you how to move around to different directories, copy files, move files, delete files, and list files in the directory.
Navigation
cd test
Using that command would move you into a directory called “test”. For it to work you have to have a directory named that under you current location. You can also specify a full path to go to directories as well.
cd /home/rohan/public_html/
In that example it would take me to the “public_html” folder which happens to be my web root folder on one of my servers.
cd ~cd
Using either of those will take you to your home directory for the user you are logged in as.
cd ..
Using that will take you up one directory level.
File Management
ls
This command displays all files/directories in the current directory. You can use this command in other ways to get more information as well
ls -l
This displays more information about the file such as who owns the file, the size, and the date it was created. If you use that command and there are too many files to see on one page you can change the command to create a page view and press the “space” to view next page.
ls -l |less
Note the vertical bar | is also called an UNIX pipe you type it by using shift+\.
ls -la
Using this will also show all the hidden files in the directory.
cp (filename) (new filename)
In this example we copied a file and created a new file with the same content.
cp home.html backup/oldhome.html
Using the same thinking we can also copy it to a different directory.
mv home.html index.html
This would change the name of the file from home.html to index.html.
mv images/ media
You can use same method to rename a whole directory as well.
rm index.html
Using the “rm” command you can delete files
These are some basic shell commands that you will need to learn to get started with your server. These will help you move around your sever, copy, delete and rename files.