SSH Terminal
Introduction SSH Terminal

SSH Terminal - In this tutorial we will discuss SSH and 14 what we use most often in commands for SSH application operations. By understanding the syntax below, You will find it easier to use the Linux operating system terminal and know how to use the SSH application on the desktop.

SSH CommandExplanation
lsShow directory contents in list the names of files
cdChange Directory.
mkdirCreate a new folder (directory).
touchCreate a new file.
rmRemove a file.
catShow contents of a file.
pwdShow current directory
cpCopy file/folder.
mvMove file/folder.
grepSearch for a specific phrase in file/lines.
findSearch files and directories.
vi/nanoText editors.
historyShow last 50 used commands.
clearClear the terminal screen.

What you need

Things you must prepare before starting this guide:
-Have access to the Terminal
  • Step 1 - Access the remote server

    Before starting, you are advised to have a virtual server with a new state first, so that if you accidentally make a mistake and delete something accidentally, you can immediately restore it to its original state easily.

    The SSH system stands for Secure Shell, a local application protocol used to connect to remote systems. The following are the basic command commands that you can use in the SSH Terminal:

    ssh user @ serverip
    This command connects you to a server that has a serverip IP address and user username. Another way you can use it is to use ssh serverip, in this way the shell will understand that you are trying to contact the same user you used when logging in now.After you enter this command, you will be asked to fill in the password (if this is the first time you have connected, you will be shown a message that the server you have contacted has not been identified, type yes in the command line).Yes, that's the only way, now you are connected and can continue reading this guide on how to manage your files via SSH Terminal! If you want to exit the remote server and return to your local computer, just type exit on the command line.
  • Step 2 - Study the command

    In this step, we will try directly all the commands that you will learn!
    IMPORTANT This can be applied to all commands in the shell. When writing arguments for the command (syntax / command), for example, cd 'Folder One' (where the folder name contains 2 separate words), you must enter the name of the folder in quotation marks. The cd Folder One command (without quotes) will not work properly because the shell will think of the command as 2 arguments ("Folder" and "One").
  1. ls - This command is used to display all files and directories. We recommend that you use this command with the -l option, so that it will be ls -l, so that all files are displayed neatly and accompanied by detailed information about each file. Another option that can be used is -a, which also displays all files, accompanied by hidden files / directories (dot files with a dot in front of them, for example: the .ssh directory).
  2. cd - This command is used to "walk" between directories (cd is an example of "change directory"). After displaying all the files and directories with ls, you can choose the directory you want to run. For example, the home directory that you want to enter or we want to open. Typing the cd home command and you will move from your current location to the <home> directory is quite simple and easy. after that you can use again to display the files and directories in the new directory that we want to display.You can also type the full address into a directory if, for example, you want to go to a directory with a deeper level. You can use (for example) the command cd home/TestDirectory/AnotherDirectory In this way, you will go directly to the directory called "Another Directory". Use the cd command ... (there are spaces and 2 points after cd) to move up 1 level (in the example, we will move back to the "Test Directory" directory from the "Another Directories" directory).
  3. mkdir - A very common command used to create new directories in the SSH system terminal. This command will create a new directory with the name you specified earlier, for example a new folder named SFTP PORT, will create a new directory with the name SFTP PORT Folder in your current directory in the SSH Terminal system.
  4. touch - This command is used to create a new file with a certain extension. For example, touch NewFile.txt will create a "txt" file called New File in your current directory (the extension can be of any type you want, even you can create a file without any extensions at all), such as touch NewFile.
  5. rm - This command is used to delete certain files / directories. For example, rm NewFile will delete the New File file that we have created before. If you want to delete a directory and all the directories in it, use the New rm -r Folder, this will delete the "New Folder" folder and all the folders inside in SSH Terminal.
  6. cat - This command is used to display the contents of the file. For example, cat info.txt will bring up the contents of the file to your screen. Another example, cat info.txt info2.txt> mergedinfo.txt will combine 2 files into one ("info.txt" and "info2.txt") and write the contents of the file which is combined into the file "mergedinfo.txt".
  7. pwd - This command will display your current location in the system. For example, type pwd, the result is: "home / user / public_html".
  8. cp - This command is used to copy files and folders in SSH Terminal. The command is: cp [option] source destination. Basically, you can type directly the file that you want to copy in the source section. Whereas you can replace the destination with the destination address / folder / file. Now, if you write a destination that does not yet exist, SSH Terminal,for example, you have the original file filelama.txt and make filebaru.txt as the destination, then bash will immediately copy the file and copy it with a new name. In addition, here are some options that you can use with the cp command:
    • o cp -f source destination - Forcing the copy (copy) process by deleting the destination file if needed.
    • o cp -i source destination - Will give you a warning message before overwriting the file.
    • o cp -u source destination - update option. Only copies if the source file is newer than the destination file.
    • o cp -n source destination - Will not copy if the file already exists (does not overwrite).
    • o cp -a source destination - This option will archive files.
  9. mv - This command works in the same way as cp, but the difference is that mv will move your files, not copy them. This command can also be used to rename files (rename). If we take the same example from the cp command, (in our current directory, there is 1 file oldfile.txt) and we type this command: mv oldfile.txt newfile.txt then bash will immediately rename the oldfile.txt file name to newfile.txt.
  10. grep - This command looks for values ​​in the file / folder. For example: the grep 'bag' file will search for the word 'bag' in the file called "file". grep will bring up all the lines containing the word. For example, if there is a line containing the phrase 'There is a bird over Budi's head', then the line will be displayed because there is a phrase bag in the sentence in SSH Terminal.
  11. find - This command is used to find folders for files that are included in the specified criteria (name, size, file type). For example: find. -name "* .html".SSH Terminal,This request will display all the files in your current directory that have an extension / suffix ".html" (note the use of an asterisk "*" in the command we entered, it is called a wildcard whose function is to convey bash that no matter what name file before the extension ".html", the important thing is that the file has the extension ".html".
  12. vi/ nano - This command is used to enter into the text editor. For example, nano newfile will create a new file called "newfile" and directly enter the nano editor or edit the file "newfile" (if it already exists) with nano editor. The same thing applies to the vi command, which will activate another editor named vi. IMPORTANT the nano open text editor is the default editor, like vi, you have to install it first before you use it.
  13. history - This command is used to display commands that have been used previously. For example: history 20 will display as many as 20 commands that were previously entered in the Terminal.
  14. clear - This command is used to delete all text from your Terminal screen.

Conclusion

Hopefully this tutorial is quite clear to you and can make you really understand the basic SSH commands and how to use them. We recommend that you view this page for more detailed information about the commands described in this tutorial and more in SSH Terminal..!


Discussion: