Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

How to adminstrate your files – SSH

Tuesday, January 19th, 2021 by Helge

laptop-phpHere is the second part of our series how to administrate your website files via your Servage control panel. Last time, we gave some information about how to work on your files via a  FTP program. In this blog, we like to give some information about how you can use SSH to administrate your files.

SSH stands for Secure Shell and is a way to log in to the server to be able to work directly on the server via text commands. Handled the right way, SSH can be very useful and can help you work very efficiently. Before you can start, you need:
  • SSH client
  • the SSH login details for your account

 

You can download free SSH clients via the internet. Plenty of user are using Putty. However, there are plenty of other tools which you can use as well. Click on THIS page to find how to set up your own SSH account for Servage webhosting.

 

Here are some examples of commands you can use to administrate your files via SSH.

The folder I am in?

If you do not know which folder you are in, or simply want to know so you can easily find out where you are with the command pwd (print working directory) that says where you are.

 How do I delete files and folders?

To delete files and folders you use the command rm (remove)
write rm followed by the folder or file.
Here, you can use switches such as -f which stands for force, -r which stands for recursive (removes even the subfolders and content)

 How do I create a folder?

To create a folder, use the command mkdir (make directory)
Write mkdir followed by the desired folder name.

 How do I create files via SSH?

To create a file via ssh, write touch followed by the file name.
For example. index.php touch creates a file called index.php.

How do you change rights via SSH? (Chmod)

To change permissions on files and folders via ssh, use the chmod, you can use switches such as -r to make the same changes to subfolders and files.

The command works like this:

chmod rights file/folder.

For example. ” Chmod 755 public_html / ” puts the rights of the folder public_html to 755
” chmod -R 755 public_html ” puts the rights of public_html folder and its contents to 755

By default, we use 755 folders and 644 files.

 How do I download files from the Internet?

With the command wget can download files from the Internet straight down to the folder you are in.

Let’s say you want to download the latest wordpress; You can then enter wget http://wordpress.org/latest.zip who download latest wordpress right into your space with us.

You can also choose to save the files to a different name with the -o switch, the command would read wget -O hejhej.zip http://wordpress.org/latest.zip and will save latest.zip as hejhej.zip

 How do I rename a file or a folder?

Like when you move files, use the command mv (move) then this can also rename files and folders.

To rename a file, enter mv file name new file name, and do the same with folders. (If you use an existing folder name as the folder will be moved there, it will not overwrite the existing folder).

 How can I see the contents of folders? (Ls)

To see the contents of your space, you use the command ls (list) to list the contents of a folder, and depending on the switches, it can also display the contents of the folder and all its subfolders
l = this switch gives us everything in a long list (list)
a = this switch shows all files.
h = this switch gives us more readable sizes (human-readable)
t = this switch sorts by last modified (time)
r = this switch turns on the result (reverse)
R = this switch also lists all the contents of subfolders (recursive)

 How do I edit files via SSH?

You can edit files via SSH using vi, the text editor.
write eg vi index.html

 How do I scroll through folders via SSH? >> You can scroll through the folders using the command cd (change directory).

Type cd followed by the folder you want to enter. to move one step backward, type cd .. (two points)

If you want to return to the beginning so it is enough to simply type cd.

 How do I copy files via SSH?

You can copy files via ssh using cp (copy)
You write the CP file / folder you want to copy, and where you want to copy it.

 How do I move files via SSH?

To move files via SSH from one folder to another, use the command mv (move) , you simply type mv file you want to move and where to move it.

 I can find specific information in a file? (Seized)

With the grep command, you can search for specific strings in a file.

Let’s say you have three files, you know that in one of these files, there is a line saying “hello” if you then enter grep hello * -R, it will search for the characters h, e and j direct result after each of all the files and folders where you are.
this means that two lines below will be matched:
“hello my dear friend”
and
“if you just say tjolahejhopp”

How to adminstrate your files – SSH, 4.7 out of 5 based on 3 ratings
Categories: Guides & Tutorials
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.