Introduction
In this tutorial we will discuss what SSH and 14 commands (commands) are most often used in SSH. By understanding this syntax, you will find it easier to use the Linux terminal and know how to use SSH on a PC.
is - Show directory contents (list the names of files).
cd - Change Directory.
mkdir - Create a new folder (directory).
touch - Create a new file.
rm - Remove a file.
cat - Show contents of a file.
pwd - Show current directory (full path to where you are right now).
touch - Create a new file.
rm - Remove a file.
cat - Show contents of a file.
pwd - Show current directory (full path to where you are right now).
cp - Copy file/folder.
mv - Move file/folder.
grep - Search for a specific phrase in file/lines.
find - Search files and directories.
vi/nano - Text editors.
history - Show last 50 used commands.
clear - Clear the terminal screen.
SSH stands for Secure Shell, a protocol used to connect to the system remotely.
The basic commands that you can use are:
ssh user@serverip
mv - Move file/folder.
grep - Search for a specific phrase in file/lines.
find - Search files and directories.
vi/nano - Text editors.
history - Show last 50 used commands.
clear - Clear 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 you start, 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.SSH stands for Secure Shell, a protocol used to connect to the system remotely.
The basic commands that you can use are:
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 Terminal! If you want to exit the remote server and return to your local computer, just type exit on the command line.
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!
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 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 folder names contain 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").
- 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 of these files. 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).
- cd - This command is used to "run" 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, there is a home directory that you want to enter. Enter the cd home command and you will move from your current location to the "home" directory. You can use ls again to display files & directories in the new directory. 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 / Another Directory. In this way, you will go directly to the directory called "Another Directory". Use the command cd ... (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).
- mkdir - This command is used to create a new directory (stands for "make directory"). This command will create a new directory with the name that you specify, for example, mkdir Folder New will create a new directory with the current Folder name in your current directory.
- touch - This command is used to create a new file with a certain extension. For example, touch FileBaru.txt will create a "txt" file called FileBarudi 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 File New.
- rm - This command is used to delete certain files / directories. For example, rm File New 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 in it.
- cat - This command is used to display the contents of a 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 that is combined into the file "mergedinfo.txt".
- cp - This command is used to copy files and folders. 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, 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: cp -f source destination - Force copy (copy) process by deleting destination files if needed. cp -i source destination - Will give you a warning message before overwriting the file. cp -u source destination - update option. Only copies if the source file is newer than the destination file. cp -n source destination - Will not copy if the file already exists (does not overwrite). cp -a source destination - This option will archive files.
- 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 rename the file name oldfile.txt to newfile.txt.
- grep - This command looks for values in files / folders. 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.
- 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". 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".
- 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 text editor is not the default editor like vi, you have to install it before you use it.
- 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.
- clear - This command is used to delete all text from your Terminal screen.
Komentar
Posting Komentar