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.
cd ‘folder name’
cd folder nameis written here , shell will treat it as two different arguments (“file” and “name”).
ls– This command is used to list all files and directories. We
-lrecommend that you use this command with the option.
ls -lAll 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.
cd– This command is used to “walk arasında between directories. (
cd“Change directory” stands for.)
lsAfter 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 homeand 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”.
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.
touch– This command creates a file in the selected extension. For example,
touch newFolder.txtit 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.
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 newFolderyou must run the command. This command deletes the “new Folder” folder and all folders in it.
cat– This command is used to display the contents of a file. For example,
cat folder.txtit will display the contents of the file. Another example: The
cat folder1.txt folder2.txt > Combined File.txtthe command will merge the contents of the files “file1.txt” and “file2.txt IP and write it into“ compositeFile.txt ”.
pwd– This command shows your current location on the file system. For example, the output can be “home / user / public_html”.
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.
cp -f source target– This option forces the target file to be deleted if necessary.
cp -i source target– Shows you a warning message before overwriting a file.
cp -u source target– Update feature. Copies only when the source file is more up-to-date than the destination file.
cp -n source target– Does not copy / overwrite if a file already exists?
cp -a source target– This option archives files.
cpworks 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.txtyou run the command, bash will change the name of the file.
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.
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.)
vi/nano– This command is used to enter the text editor. For example,
nano newfolderif 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
viapplies 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 .
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
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.