Follow

Basic SSH Commands

Below you can find some basic linux commands :

1) 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"


2) 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.

3) 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)

4) How do I create a folder?
>>To create a folder, use the command mkdir (make directory)
Write mkdir followed by the desired folder name.

5) 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.

6) Can I clean up my messy SSH window?
>>You can clean up your window screen by typing clear

7) Can I see what commands I run?
>> You can see what commands you issue by writing "history".
If you are looking for a specific command you run, you can run "history | grep one-part-of-command"

8) Can I see the contents of a file without opening it?
>> With the cat command to view the contents of the file without opening a text editor. Just type cat filename.

9) 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.

10) 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

11) 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).

12) 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)

13) How do I edit files via SSH?
>> You can edit files via SSH using vi, the text editor.
write eg vi index.html

14) 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.

15) 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.

16) 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.

 

 

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.