Welcome back series dedicated VPS for WordPress basics for everyone. In part 2 you know how to log into SSH and then perhaps someone has been in there for the first time will feel confused and do not know what to do, if you have never used Linux through.
Ok, then any gain urging speed, you will soon become aware of it alone, but something must go slowly to a deeper understanding rather than flip through to the end you did not understand anything.
So in this article we are going to do something? Just like the new you only use your computer, we will go through the extremely simple operation, but it is important to work with files and folders on Linux VPS.
I. The command works with file
In this command, you will take over four major steps include:
- How to create file and write to the file contents
- How to rename files
- How to copy files
- Deleting files
TIPS : Use the commandls
to see all the files and folders in the current directory.
1.1) How to create file
Ok, now you are in the directory ~ on the VPS, which is the folder that you login username.
Now we will create the file using a text editor application table with the name of the command structure is as follows:
1
| of name- file -creation arm |
Suppose you want to create a file named thachpham.html would type the following command:
1
| vi thachpham.html |
After you finish typing and Enter, it will show the content editor area file you just created as shown below:
Now you can not enter data into the file in vi because it does not allow you to enter data directly, but must switch to Insert mode . To switch to Insert mode, you press i and it will display the word INSERT as shown below:
When it does, then you've INSERT letters can enter data into the file, try something a viewing public content. Are you prepared as you're typing on the conventional text editor.
After preparation is complete, if you want to save, then press the ESC key to exit the Insert mode and type: wq! Then enter to conduct exit and save the file.
Now it will take you back to the command line interface. To check if the file you just created exists or not, type the command
ls
and Enter, you will see the name of the file that you just created in the list of files and folders in the current directory that you are implementing .
The latter case you need to edit the file contents still use commands such as file creation time, because if you type in the command file does not exist, it will create, even if one already exists, you will fix it.
To read the contents of the file you just created, you use the command
cat
. In this instance you need to read the file, it will knock thachpham.html isthachpham.html cat
.
In addition to the command
cat
, you can also use other commands like:
1
2
3
| tail thachpham.html head thachpham.html |
2.2) Rename the file
To rename a file, we'll use the command
mv
. Actually command mv
means move it, ie move files and folders, but his current full-seen people use this command to rename the file.
To use the service command mv to rename the file, you would use the following syntax.
1
| mv name- file name--used file -new |
For example, you have to convert the file into phamngocthach.html thachpham.html would write command is:
1
| mv thachpham.html phamngocthach.html |
Then use the command
ls
to check the results.2.3) How to copy files
To copy a file, you use the command
cp
with the following structure:
1
| cp name- file name--used file -new |
In particular, when a copy of the file you will have a new file name and contents are identical. See for example:
You can also forward a copy of the file is copied to another folder with the same command, only added to the directory path:
1
| cp thachpham.html / path / folder / share thachpham- .html |
The concept of folders I will say more below.
2.4) How to move files
Same as using the command
cp
above. The structure is:
1
| mv name- file -transfer arm mail-item-to-save |
For example, I want to move the folder thachpham.html file / home, then type:
1
| mv thachpham.html / home |
2.5) How to delete file
Deleting files is also very simple, we will use the rm command structure:
1
| rm name- file -deletion rod |
For example:
rm phamthachpham.html
After typing this command, it will ask you if you want to actually delete the file or not, type yes and enter to agree.
In case you want to remove it without asking to add the parameter
f
in paragraph command is given.
1
| rm f phamngocthach.html |
III. Working with directories (folders)
The folder manipulation work on virtually no different than the file too, but of course it does not have to use the command
vi
.
In this section, you will understand the operation as:
- How to create a folder
- Accessing the folder
- How to copy folders
- How to delete folder
3.1) How to create folders and folder access
Ok, make sure you are still in the directory
/ root
, which is denoted ~
on the command line there.
To create a folder, we will use the command
mkdir
structure:
1
| mkdir directory-name-letter-to-create |
For example, I want to create a folder data in the current directory, it will knock the
mkdir data
.
To access the data folder you just created, we will use the cd command with the structural
data cd
.
As you can see, when access to the data directory of the current directory name will change to the data so you know. To know the exact address of your folder path is executing the command type
pwd
to check.
3.2) Learn more about the command cd
Above her was just how to use the cd command to access a specific folder, but much that is not enough, I'll explain more in this section.
For example, now you are in the directory / root / data and want to access the folder / root, which is reduced by a layer folder, it will write the command
cd ..
The two dots mean you go back to a floor directory, but you can not use more than 2 dots.
In case you need to exact a certain directory, then type structure is
cd / path / folder
. For example, he wants to directory / etc / init , it will knock thecd / etc / init
.
You helped me a place to note, if your path on which stamp / front (eg / etc / init ), it will start from the root, this is the concept of absolute paths.
If you write that missing bracket / front, it will understand that you want to access the folder in the folder you are currently implementing. For example, you are in the directory / rootwhich type
cd etc / init
, it will understand you want to access the directory / root / etc / init and will error if this directory does not exist.
To return to the folder of the user you are logged in (in this case / root ), you can type
cd ~
.
Want access to the root directory on the server, then typing
cd /
.
3.3) More on the command ls
In part 2 of this article, and I have many times used the ls command for the purpose of viewing the files and folders in the current directory. However, some would say more about their options so you can use more flexible.
ls
to see the entire file but only display the file name, and does not include hidden files and folders.ls
to see all the files and folders, including hidden files and folders.l ls
are viewing the entire file / folder together with details of the file / folder, but does not include the file / folder hiding.ls -al
is considered the entire file / folder with detailed information including file / folder is hidden.
Example of use:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| [Root @ vpscanban ~] # ls anaconda-ks.cfg install .log thachpham- share .html data install .log.syslog thachpham.html [Root @ vpscanban ~] # ls . .bash_logout data. ssh .bash_profile .. install .log .tcshrc anaconda-ks.cfg .bashrc install .log.syslog thachpham- share .html .bash_history .cshrc .pki thachpham.html [Root @ vpscanban ~] # ls l total 32 rw ------- 1 root root 896 Dec 17 2013 anaconda-ks.cfg drwxr-xr-x 2 root root 4096 Sep 20 21:52 data rw-r - 1 root root 8412 r-- Dec 17 2013 install .log rw-r - 1 root root 3384 r-- Dec 17 2013 install .log.syslog rw-r - 1 root root 36 r-- Sep 20 21:31 thachpham- share .html rw-r - 1 root root 36 r-- Sep 20 21:30 thachpham.html [Root @ vpscanban ~] # ls -al total 68 dr-xr-x --- 5 root root 4096 Sep 20 21:52. dr-xr-xr-x 21 root root 4096 Sep 20 19:15 .. rw ------- 1 root root 896 Dec 17 2013 anaconda-ks.cfg rw ------- 1 root root 0 May 2 16:16 .bash_history rw-r - 1 root root 18 r-- May 20 2009 .bash_logout rw-r - 1 root root 176 r-- May 20 2009 .bash_profile rw-r - 1 root root 176 r-- Sep 22 2004 .bashrc rw-r - 1 root root 100 r-- Sep 22 2004 .cshrc drwxr-xr-x 2 root root 4096 Sep 20 21:52 data rw-r - 1 root root 8412 r-- Dec 17 2013 install .log rw-r - 1 root root 3384 r-- Dec 17 2013 install .log.syslog drwxr ----- 3 root root 4096 Apr 9 16:31 .pki drwx ------ 2 root root 4096 Sep 20 19:15. ssh rw-r - 1 root root 129 r-- Dec 3 2004 .tcshrc rw-r - 1 root root 36 r-- Sep 20 21:31 thachpham- share .html rw-r - 1 root root 36 r-- Sep 20 21:30 thachpham.html |
3.4) How to copy folder
Folder, the copy command is similar to file copy command, which is to use the command
cp
but others are written in the form:
1
| cp -r name-letter-entry-name-directory-old-new item |
Parameters
-r
means you will copy all the files and folders contained therein.
For example, the folder you want to copy data to a new folder named -new data is written as follows:
1
| share new data-data -r |
3.5) Move the folder
Just like moving files only, which is using the mv command structure.
1
| mv letter-entry-to-switch-switch-mail-entries to |
For example his time creating one folder named web.
1
| mkdir web |
Then transfer the data folder in the web directory
1
| mv web data |
3.6) Delete folders
Only one very simple command:
1
| rm -rf name-letter-entry-to-delete |
For example, the folder you want to delete the web and subfolders inside it is written as:
1
| rm web -rf |
Note : When you delete can not be restored.
Epilogue
In this article you have just come through the most basic commands in Linux to serve on the manipulating files and folders on the VPS as well as access to a specific folder is like.
If you are still not understood very vaguely, please read the following articles because I need you to understand this truth because his firm will not explain it in the following article.
0 nhận xét:
Post a Comment