Simple SSH Commands

What will you need?

Before you begin this guide, you need the following:

  • Terminal access

Step 1 – Access the remote server

It is recommended that you use a newly installed free virtual server to prevent you from accidentally performing an incorrect operation.

SSH, Secure Shell means. A protocol used to connect to a remote server/system.

Here is the simple command you should use:

ssh user @ ServerIP

This command  connects you to a server with an sunucuip The IP address and useruser name. Another and simpler way to connect ssh serverip would be to use it. With this method, the shell will think that you are trying to connect with the same user you are currently logged in to. 

When you enter this command, you will be prompted for a password. If you are connecting for the first time, you will also receive a warning message that you are connecting to an unrecognized server. yes Answer by typing on the command line.

That’s it, you’re connected! You can continue reading this guide to managing your files. If you want to leave the remote server and return to your local machine, you can exit write to the command line.

Step 2 – Some Simple SSH Commands

In this step, we’ll go through the main or frequently used shell commands you should learn!

IMPORTANT! This applies to all commands in the shell. When you type an argument next to the command, you must type it in quotation marks if the argument consists of more than one word.

Sample: cd ‘folder name’

If it cd folder name is written here , shell will treat it as two different arguments (“file” and “name”).

  1. ls – This command is used to list all files and directories. We -l recommend that you use this command with the option. ls -l All files will be listed more useful with more details/information about them. Another useful option -ais. This will show all the other files. Hidden files/ directories at the beginning. indicated by. For example, the .ssh  directory.
  2. cd – This command is used to “walk arasında between directories. ( cd “Change directory” stands for.) ls After you have listed all the files, you can select a directory to “walk”. For example, there is a directory named home that you want to enter. cd home and immediately change your current location to “home… By running the repeat command, you can see that the printed content on the screen has changed. If you want to enter a directory that is several levels deeper, you can also type its full address. Eg cd home/TestDirectory/AnotherDirectory. So you will be in the directory “AnotherDirectory”   immediately. cd .. Use the command to move up one level. In our example, a parent directory is “testDirectory”.
  3. mkdir – This command is used to create a new directory. (mkdir stands for “make directory. Basit) Simply creates a new folder in the current directory with the selected name. For example, the command will create a folder named “newFolder” inde in your current directory.
  4. touch – This command creates a file in the selected extension. For example, touch newFolder.txt it will create a new “txt” file named “newFile inde in your current directory. The plugin can be anything you prefer. You can even create a file without the plugin.
  5. rm – This command is used to delete a selected directory/file. For example, rm newFolder will delete the directory named “newFolder uz that we created earlier. If you want to delete a directory and all its directories, rm -r newFolder you must run the command. This command deletes the “new Folder” folder and all folders in it.
  6. cat – This command is used to display the contents of a file. For example, cat folder.txt it will display the contents of the file. Another example: The cat folder1.txt folder2.txt > Combined File.txt the command will merge the contents of the files “file1.txt” and “file2.txt IP and write it into“ compositeFile.txt ”.
  7. pwd – This command shows your current location on the file system. For example, the output can be “home / user / public_html”.
  8. cp – This command is used to copy files and folders. The syntax is:  You must type the file you want to copy instead of the cp [features] source target source, the directory/path/ file that you will copy to the destination.
    1. cp -f source target – This option forces the target file to be deleted if necessary.
    2. cp -i source target – Shows you a warning message before overwriting a file.
    3. cp -u source target – Update feature. Copies only when the source file is more up-to-date than the destination file.
    4. cp -n source target – Does not copy / overwrite if a file already exists?
    5. cp -a source target – This option archives files.
  9. mv – This cp works like a command, but moves the file rather than copying it. This command can also be used to change the name of a file. If mv oldName.txt newName.txt you run the command, bash will change the name of the file.
  10. grep – This command looks for the given array of files/folders. For example: grep ‘word’ file command looks for the word “word”  in a file named adı file adı. If the index is found, grep returns the entire row.
  11. find – This command looks for the criteria (name, size, type) specified in the files. For example, the find . -name “*.html” command lists the names of files with the end/extension son .html inde in your current directory. (The “* use character is used as a wildcard in the command.)
  12. vi/nano – This command is used to enter the text editor. For example, nano newfolder if the file does not exist, it will create a new file named the newfile and open it in the text editor; if the file exists, it will open in the text editor to edit the existing newfile file. The same vi applies to the command. This command opens another text editor.

    IMPORTANT! Unlike vi, nano is not the default text editor. So to use nano, you’ll probably need to install it first.  You can find a guide to installing Nano here .

  13. history – This command is used to show the list of recently used ssh commands. For example, it will display the last 20 commands entered in history 20 Terminal.

As a Result

We hope that this guide has been helpful enough about simple SSH commands and how to use them. For more information about the commands described in this guide and more,  we recommend that you check out this page.