Basic SSH Commands That You Should Know About

Secure Shell Hosting or SSH commands aids you log in, navigate as well as transfer some files over a network in Linux terminal. Exchanging sensitive data by employing a secure virtual channel is the most enticing feature of SSH. This protocol develops a connection between remotely located computer from another computer. If you are having a Linux terminal, then it is mandatory to update yourselves with the basic SSH commands on our VPS Hosting.

Some of the prominent commands are listed below.

pwd command:

When you logged into the server, the foremost thing to keep your eye on is the present location you are at. To learn more about it, use the command “pwd”. Typing the command “pwd” and hitting enter would be an ideal option.

cd command:

Once you logged in, you are at a location. To navigate to another location type “cd/location”. It will pave a way to reach the location. If you are wondering what “cd” is, it stands for “change directory”.

When you type “cd.”, it helps you stay at same directory which you are staying at.

When you type “cd..”, it will help you shift one directory back. For example, you will jump from “/home/task/file to “/home/task when you type this command and hit entre.

When you type“cd-“, then it helps you to move to the previous location from where you are at.

The command “cd ~” will pull you to the home directory.

Employing this “cd/” command will pull you to root directory.

mkdir command:

This command helps you make a new directory in the current directory path and you can choose the name in which you are comfortable with. This command stands for make directory.

Is command:

Is stands for list command. It is used to display all the contents in a folder.

“Is -a” shows up the entire file in a directory

“Is -h” shows the files along with few details such as sizes.

“Is-r” the subdirectories of the directory are shown when you enter this command.

“Is -alh” gives more details about the file available in the folder. Some of the details it incorporates are user permissions, last update, date of creation, time and permission it possesses such as read, writer and update.

cp command:

This command helps you copy a file and it stands for the copy command.

“cp -r” copies entire content prevails on the folder.

Employing the command “cp filename.extension /dir/filename1.extension”, you can copy and rename a file. The file “filename.extension” is now copied to “filename1.extension present at /dir location”.

“cp -f” is used to force the copy process by deleting a destination file. This happens when two different files happen to be on the same name in the same destination.

“cp -i” is generally a warning message which comes before proceeding with copying process.

“cp -u” is used to update the target file in your desired destination folder when the files have different content.

“cp -n” lets you check whether the file already exists. If there is none, it won’t copy as well as won’t overwrite the file.

“cp -a” helps you archive the file.

mv command:

This command stands for a move and as the name suggests it moves a file from one place to another. It doesn’t copy the file, so there is no trace of a file in the source folder when this command is employed.

Employ this command “mv filename.extension /dir/filename1.extension”, to move and rename a file.

“mv filename/ ..” command helps you move your file from one folder back.

touch command:

This “touch” command helps you create a new file in your desired extension you want such as text, PHP, Html etc. You will be amazed if you come to know you can create a file without any extension.

rm command:

This command stands for remove and it aids you to delete a file from a server. Use this Syntax: rm filename.extension to remove it.

“rm * foldername” deletes entire files or content in a directory

“rmdir” deletes the entire directory or folder.

“rm -r foldername” paves a way to delete the folder along with the folder it had encompassed.

cat command:

It displays the content of a file on the screen and copies standard input to standard output. The syntax “cat filename.extension” helps you scroll down when the content displayed isn’t comprised under your screen completely. In such away, you can go through all the information you wanted to know.

The cat command has the potential to concatenate two files. It can display the content of two files combined as one. Use this Syntax “cat file1.txt file2.txt > mergedfile.txt” to get such results.

The cat command also helps you create a new file. Use this Syntax “cat >filename.extension” to create a new file.

head command:

The head command displays the first ten line of content in the file. Use this syntax “head filename.extension” to read the first ten lines.

Employing this command, you can even see the first ten lines of multiple files separately. You have to give the name of the files in its syntax to read the first ten lines of each file separately.

Use this Syntax “head /dir/file1 /var/file2” for such demands.

The number of lines shown on the screen can be modified according to your needs.

For example: “head -n20 /temp/filename” syntax helps you display the first twenty lines of the content. Adjusting the number mentioned on the command, you can adjust the number of lines it displays.

tail command:

The head command gives you the first ten lines of the content but the tail commands help you find the last ten lines of the content. Use this syntax “tail filename.extension” to get the last ten lines of the content.

Just like the head command, you can give multiple filenames in the tail command to display the last ten lines of the content in a separate file. Use this syntax “tail /dir/file1 /dir/file2” to display the last ten lines of multiple files.

It is even possible in tail command to adjust the number of lines it displays.

For example: using the syntax “tail -n20 /temp/filename” displays the last twenty lines of your desired content. If you want to change the number of lines to display, just alter the number in the syntax.

zip command:

This zip command is used to compress and file packing the utility in UNIX. It compresses the file size and places one or more files into a single zip archive. Source this syntax “zip -r foldername” to compress file size.

If you want to delete the file in your zip archive, use this command “zip -d filename”.

To update the zip archive with a specialized list of files, then use this command “zip -u filename”.

To delete the original file once it is converted to a zip archive, then use this command “zip -m filename”

unzip command:

To decompress the file, use this unzip command. To decompress, use this syntax “unzip”

Using the unzip command, you can even decompress multiple files in a single attempt. Employing this command “unzip”.” helps you decompress multiple files at a single attempt.

Excluding files from decompressing is also possible. Follow this syntax, “unzip -x” to exclude the files you wish from decompressing from the archive.

tar command:

It is another command to compress and decompress folders. In this command, tar stands for tape archive. Follow this syntax, “folder”.tar -czvf folder1.tar.gz to compress the certain folder. When it comes to decompressing the folder, follow this syntax, “tar -xvf folder1.tar.gz”

chmod command:

To change the permission of the file or directory, this command is used. The command chmod stands for change mode. In general, the permissions are represented with numbers such as 0 to 7 or alphanumeric characters. The number 0 represents zero permission granted to the access the file, whereas 1 represents executing permission, 2 represents writing permission and 4 represents reading permission. Use this syntax “chmod 754 filename” to change the permission of the file.

When you use this chmod command, number 7,5 and 4 denotes the permission for user, group and others.

When 7 is combined with 4,2 and 1, a user gets three permissions for the file.

When 5 is combined with 4,0 and 1, then the user gets reading permission but there is no way they can write or execute permissions.

When 4 is combined with 4,0 and 0, then the user can read but writing or no execute permissions.

The command “chmod-r” gives you the space to change the permission of the folder. When you change the permission of the folder, it also applies for the files it encompasses as well.

grep command:

To commence your searching for a particular string inside a file or folder, then you need to rely on grep folder. The grep command aids you return the whole line posses the phrase when it fishes out an ideal match. To perform this task, follow this syntax, “grep “string” filename”.

When you are up to fishing out a string case-insensitively in the file, then use this command “grep -i “string” filename”. The option i in the command aids you achieve the target results.

To count the number of appearancesof a string in the desired file, employ this command, “grep -c “string” filename”. It makes your process much simple.

The command “grep -l “string” *” helps you display the filename incorporating certain patterns or strings.

Displaying the line number along with the result can also be possible. To carry out such task, use the command, “grep -n “string” filename”.

find command:

The command aids you search a file inside a folder. Employing this command, you can filter out the files that come under specific criteria. Some of the filters such as permissions, users, groups, the file are found out the find command and eases your process of fishing out the effectual permissions. To carry out the finding task, use this syntax, “find . -name filename.extension”. This command will find out the files with names in the current folder.

If you are up to finding a file under some directory, then use this command, “find /directory -name filename.extension”.

It is possible to filter out the file with its file type. Imagine you are searching for .doc, using the command, “find . type f -name filename.doc” you can easily find out the existence of the file.

vi command:

The vi command is the option to enter a text editor. The syntax for this command is a vi filename.

Using this command, it is possible to open the file. When there are no files found or nothing exist, then this command can be employed to create a new one under the same name.

When you have started the vi-editor mode using the above-mentioned command, pressing the escape key will cancel any commands. If you have changed your mind after giving the command, just press escape key and get rid of it.

If you have decided to exit the vi editor, then use this command, “:q”. To use this command, you mustn’t have undergone any changes to the file.

When you have decided to discard any changes, then you have to use the command “:q!”. It will bring back the file to normal state and exit.

history command:

It is one of the useful commands to learn about. This command helps you display the last used commands. Entering a number will limits the displayed results.

clear command:

The clear command is one of the simplest commands. It clears entire text from the terminal screen.

wget command:

This wget command is one of the most useful command as it lets you download files from internet. Using this syntax, “wget http://fileurl/filename.ext” you can download and store the file in your current directory.

The above mentioned are the few commands to learn as it is the basic SSH (PuTTY) commands. This command acts a helping hand under many circumstances.

Learn more :
Choose the right git branch strategy

The world of web design with the difference of HTML and HTML5

Start now for as low as $3,99 a month!

Open livechat