Initial SSH Experience (Simple Operation of File) - Big Cat Will Be Cute

SSH initial experience (simple operation of files)

Author: Big cats can also be cute Classification: Classification: Personal log Published on: 2014-3-15 12:00 ė 5798 views six 2 comments
For the big cats who engage in blogging, various new host cats will also play. For example, last month I saw an article on a blog that supports ssh virtual hosts. Try to play decisively and summarize some commands for using ssh. This article may be updated in the future, depending on when Big Cat develops various new play methods. In fact, ssh is no less powerful than our common cp panel, but it has no graphical interface, which is especially painful for novices. For example, we usually obtain resources from remote servers. You can also understand it as an offline download of Thunderbolt, but on the host, it should be understood as offline upload.
For those friends who have ssh but don't know how to operate, let's introduce how to use the command
Here we use Xshell as the test tool

Cd path
This command is the same as the cmd command of Win. The cmd that has used Win generally knows how to use it (the specific function that can be realized is to jump to the directory)
 Click to enlarge the picture
As shown in the figure above, we have jumped to the php directory

Rm - rf folder name
This command is used to delete a folder. Please be careful, because ssh has no recycle bin function, which means that once you run this command, your folder and the contents of the folder will be deleted. In order to display this command more intuitively, first use WinSCP to create a folder named 1 and a txt file named 1 in the root directory of the server, Easily demonstrate deleting non empty folders

 Click to enlarge the picture


 Click to enlarge the picture


 Click to enlarge the picture


 Click to enlarge the picture


 Click to enlarge the picture

After running this command, you can compare the following figure with the above figure, and you will find that the folder named 1 has disappeared
 Click to enlarge the picture

Unzip file name.zip
From the file name, we all know that this is a compressed file. Yes, ssh supports the decompression of compressed files, so that your upload is no longer a pain. Of course, zip is only one of them. Of course, it also supports tar, gz, tar. gz. It's just a common zip file. Here, we only introduce zip, which is enough
First, we upload a 2.zip file to the server. Later, the file will extract a folder named 2 and a text file named 2.txt
 Click to enlarge the picture
After executing the command, as shown in the following figure, the 2.zip file on the server has been decompressed

 Click to enlarge the picture


 Click to enlarge the picture


 Click to enlarge the picture


Of course, there is decompression, there is compression, and the command of packaging and compression is a bit more troublesome.
Add (file 1, file 2, file 3 and specified path) zip - r filename. zip file 1, file 2, file 3/path to the zip file/
The above content may be a little more abstract, and Big Cat will demonstrate the operation method for everyone
implement
zip -r 3.zip 2
output
 Click to enlarge the picture
At this time, the remote server has helped us print the folder named 2 into a 3. zip file
 Click to enlarge the picture
Delete a file (folder) in the zip file (folder) zip - d filename. zip filename. extension (folder)
Execute zip - d 3.zip 2/2.txt
output
 Click to enlarge the picture
When downloading the compressed file locally, it is found that the 2.txt file in the compressed file has been deleted from the compressed package

Add a file (folder) to an existing zip file zip - m filename. zip folder. extension (folder)
Execute zip - m 3.zip 2/2.txt

output




Copy file: cp filename extension/path/
It is also very simple. For example, execute cp 2/1.txt 2/1 in the server subdirectory/

You can see that the 1.txt file in the folder has been copied to the subdirectory 1 of directory 2

 Click to enlarge the picture

Rename and move files:
Mv filename. extension (folder) new filename. new extension (folder)
Mv folder (filename. extension)/path/
The above two commands are basically similar, so we won't give examples one by one. According to the above examples, you can basically control ssh yourself
Create file: touch filename. extension

Create folder: mkdir folder name

Change file permissions: chmod digital filename. extension

Change folder permissions: chmod - cfv R number/path/

To view folders and files in the current directory: dir

Download the contents of the remote server to the server: wget http://domain name/folder/ FileName.Extension

Finally, I will tell you that the blank space in ssh is more painful. You must use "/" to escape, and quotation marks need not be added. In fact, ssh is not just for big cats to play. Advanced functions such as scheduled backup will be updated when available. After reading this tutorial, you can help novices quickly use ssh to operate your host

This article is from Big Cat Huimeng. Please indicate the source and the corresponding link when reprinting.

zero
After reading this article, your mood is:
 
nausea
anger
Strongly like
be moved
pass by
boring
Lei Gui
follow

comment

  1. MaxPower 2014-04-03 11:39  Opera Mini 7.8.35045   Android
    Linux ssh host, want to have...
    1. Big cats can also be cute 2014-04-05 04:28  Google Chrome 21.0.1180.89   Windows XP
      @MaxPower: If you want to own it, you can apply for one. The tested host is also free. You can also apply.

Comment

E-mail addresses will not be made public. Required items have been used * tagging