SSH Linux commands have always been confusion for many people. Not many of us know how to use them and get our work done quite quickly. However, in this tutorial, I will explain the top 17 basics of Linux SSH Client Commands. You will learn each and everything related to Linux SSH client commands.
What is SSH in Linux?
SSH also called Secure Shell is a protocol which is used to log on to remote systems securely.
List of the Basic Linux SSH Client Commands
What will you Need?
Before you begin with the guide, basic Linux SSH Client Commands, you will need the following:
Access to the Terminal
For accessing of any of the Basic Linux SSH Client Commands, you will need to have access to the Terminal. Follow the steps below for a successful access to the terminal to use the Linux SSH Client Commands.
Step 1- Accessing the remote server
A virtual server is an essential component for any remote server. Furthermore, It does the managing of various operations of the remote server. Most noteworthy, it is highly recommended to have an excellent virtual server with a good quality build template. The reason is quite simple, if accidentally you delete any crucial things which were not meant to be deleted, you can reconstruct the server and start the process from scratch.
The basic command to use is:
ssh user@server ip
The above command will help you connect to the server which has a username user and an IP address server ip.
However, there is also another method which will be quite a more straightforward way to connect to a server and it is depicted as follows: ssh server ip.
By using this method, the server will think that you are connecting with the same user you are logged in with at the same moment.
Once you enter the above command, you will be asked for a password (if you are logging in for the first time). A warning message will also be prompted to you that your connection is not recognized. Thus, simply, type “yes” on the command line.
That’s it; you are now connected to the server. By doing the above steps, you will be able to manage the different Linux SSH Client Commands via Terminal.
If you want to get out of the terminal, go back to your respective local machine and type in “exit” in the command line.
Step 2- Learning different commands
In this step, we will go through all of the basic Linux SSH Client Commands to help you understand each command in a little bit detailing procedure.
This command lists all the files and directories. It is recommended to use this command with the -l option.
Using ls -l, all of the files and directories will be listed in a more convenient manner. Apart from that, all the details will be enlisted about those respective files and directories.
Another essential option which you can use is –a. This command will depict all the hidden files/directories in your system. Read here to know, How to run windows on Mac.
Example: ls –l (Displays all the files and directories).
The term cd stands for “change directory”. This command enables to walk between directories. This operation can be performed by ls command. After listing all of the directories, you can simply walk through with this command.
Example: cd home/Test1 directory/ Test 2 directory.
This command is generally used to make a directory. A new directory can be created with your chosen name with this command.
Example: mkdir NewFolder1 will create a new folder with the name “New Folder1”.
This command creates a new file with a self-chosen extension. In many of the cases, you can also create a new file without any extension.
Example 1: (with an extension): touch NewFile1.txt
Example 2 🙁 without an extension): touch NewFile1
This command removes a user chosen file or directory. By using this command, all of the chosen files and directories will be completely removed from your system.
Example 1: rm Newfile1 (It will remove the entire previous created file named as “Newfile1).
Example 2: rm –r Newfile1 (it will remove a directory as well as all of the directories inside it)
The rm command is one of the most important Linux SSH Client Commands in Linux system.
This command displays all of the contents of the file. Further, it can also merge any two files to form a complete one file.
Example 1: cat file1.txt (it will display the contents of this file on the screen)
Example 2: cat file1.txt file2.txt > mergeddata.txt (It will merge two files together and the content will be stored into mergeddata.txt)
This command displays your current location in the file system. It can be a handy command for positioning of any user’s location in any file system.
Example: pwd (The output will be like- “home/user1/public_html”)
This command is generally used for copying files and folders.
Syntax: cp [options] source dest.
Here, instead of source, you can write the file which needs to be copied and instead of dest, the destination path/folder/file will be written.
The command cp has some variants which can be described as follows:
- cp f- source dest – Removes the destination file by forcing the copy procedure.
- I- source dest- Displays a warning message before overwriting a file.
- u- source dest – it will only copy if the source file is newer than the destination file.
- n- source dest – it will not copy if the same file already exists.
- a- source dest – it is used to archive the files
This command generally moves the files instead of copying it. Furthermore, you can use it to rename any file.
Example 1: mv file newfile.
Example 2: mv olderfile.txt newerfile.txt bash (it will rename from older file to newer file).
It looks for the strings in any files/folders. However, If you want to find any word in a given sentence, using grep command will surely display that particular word.
Example: grep ‘doc’ file (displays the word doc from given searched file).
Furthermore, We use this command to search a folder for a given file/files which meets certain criteria. The criteria can be in terms of size, file type, name.
Example: find. –name “.html” (it will display all the files in the directory which have an extension of “.html”.
It displays the text editor for personal use. Additionally, You can use this editor to modify or change various texts.
Example: nano newfile1 (Will either create a new file or edit an existing newfile1)
Hence, this command is one of the most useful commands in the Linux SSH Client Commands lineup.
It displays the last used commands.
Example: history 40 (it will show the last 40 entered commands which you entered in the terminal).
It generally clears all texts from the terminal screen.
Example: clear (It will clear everything from the terminal screen).
You can use the command tar to extract or create tar.gz archives.
Example 1: tar cvzf ArchiveName.tar.gz /path/to/directory (Creates a tar.gz archive of a folder.
Example 2: tar xvzf Filename.tar.gz (It will unpack the files).
This is one of the most useful commands in Linux SSH Client Commands. It helps to download files from the internet.
Example: wget http:// fileurl/filename.ext (It will fetch your desired file from the internet and will store it in the current directory/folder).
We use it to find the exact size of any file.
Example: du –h /file path (It will show the space occupied by a given file).
Conclusion- Linux SSH Client Commands
Consequently, I hope that you would have well understood the above basic Linux SSH Client Commands. Furthermore, you will surely master these Linux commands if you practice them in your daily regime on the terminal itself with self-determination and concentration. Additionally, learning of any Linux commands will surely go in vain if you do not practice them. Thus, it is essential that you commit to practising the above commands with sheer determination to be a master of those Linux commands. Read here to know, The Best Mac browsers of 2017.