WordPress: UNIX Shell Skills:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
 
(未显示同一用户的2个中间版本)
第1行: 第1行:
<div style="border:blue 1px solid; background:#E5F2FF; text-align:center; margin:5px; padding:10px">'''Note''': This article covers an advanced topic.</div>
<div style="border:blue 1px solid; background:#E5F2FF; text-align:center; margin:5px; padding:10px">'''注意''': 这篇文章包含一个高级主题。</div>
<div style="border:blue 1px solid; background:#E5F2FF; text-align:center; margin:5px; padding:10px">'''注意''': 这篇文章包含一个高级主题。</div>
__TOC__
__TOC__
__TOC__
If you have recently moved to [[WordPress:WordPress]] from a hosted blogging solution like Blogger or TypePad, you may be unfamiliar with the tasks of managing a webspace as well as a blog.  WordPress is based on [[WordPress:Glossary#PHP|PHP]]; many [[WordPress:Hosting WordPress|hosting services]] use servers running Linux and Apache; many web hosts offer not only web-based [[WordPress:Wikipedia:Control panel|control interfaces]] to their customers but also [[WordPress:Wikipedia:Operating system shell|shell access]] or [[WordPress:Wikipedia:Command line interface|command-line interfaces]]. Many WordPress users may not be familiar with using the [[WordPress:Wikipedia:Operating system shell|shell]] to manage their file systems. This article explains the more commonly-used UNIX commands and demonstrates how a routine administrative task, namely a minor WordPress upgrade, is carried out in the shell.


如果你最近从一个托管的写博客的solution,如Blogger或者TypePad中进入了[[WordPress:WordPress|WordPress]],你可能对于管理网络空间和博客的任务不太熟悉。WordPress是以[[WordPress:Glossary#PHP|PHP]]为基础的; 许多[[WordPress:Hosting WordPress|托管服务]]使用服务器运行Linux 和Apache; 许多网络服务器不仅向它们的顾客提供以网络为基础的 [[WordPress:Wikipedia:Control panel|控制界面]] 还提供 [[WordPress:Wikipedia:Operating system shell|shell权限]] 或者[[WordPress:Wikipedia:Command line interface|命令行界面]]。许多WordPress用户对于使用[[WordPress:Wikipedia:Operating system shell|shell]] 来管理文件系统,可能不熟悉。这篇文章介绍了更加常用的UNIX命令并且示范了一个常规的管理任务是如何运行的,如一个小型的WordPress升级,就是在shell上执行的。
如果你最近从一个托管的写博客的solution,如Blogger或者TypePad中进入了[[WordPress:WordPress|WordPress]],你可能对于管理网络空间和博客的任务不太熟悉。WordPress是以[[WordPress:Glossary#PHP|PHP]]为基础的; 许多[[WordPress:Hosting WordPress|托管服务]]使用服务器运行Linux 和Apache; 许多网络服务器不仅向它们的顾客提供以网络为基础的 [[WordPress:Wikipedia:Control panel|控制界面]] 还提供 [[WordPress:Wikipedia:Operating system shell|shell权限]] 或者[[WordPress:Wikipedia:Command line interface|命令行界面]]。许多WordPress用户对于使用[[WordPress:Wikipedia:Operating system shell|shell]] 来管理文件系统,可能不熟悉。这篇文章介绍了更加常用的UNIX命令并且示范了一个常规的管理任务是如何运行的,如一个小型的WordPress升级,就是在shell上执行的。


=== The bash shell ===
=== The bash shell ===
=== The bash shell ===
The shell offered by your web host is likely to be [[WordPress:Wikipedia:Bash|bash]], which stands for "Bourne Again Shell" after [[WordPress:Wikipedia:Stephen_Bourne|Stephen Bourne]] who wrote the [[WordPress:Wikipedia:Bourne_shell|original modern Unix shell]].  [[WordPress:Wikipedia:Bash|bash]] is distributed by the [http://www.gnu.org/ Free Software Foundation]. There are a number of different Unix shells. The commands briefly described below apply to almost all of them.


你的网络主机提供的shell很可能是[[WordPress:Wikipedia:Bash|bash]],bash指的是"Bourne Again Shell",是以编写了[[WordPress:Wikipedia:Bourne_shell|original 现代 Unix shell]]的[[WordPress:Wikipedia:Stephen_Bourne|Stephen Bourne]] 命名的。[[WordPress:Wikipedia:Bash|bash]]是由[http://www.gnu.org/ 免费软件基金会]来命名的。有许多不同的Unix shells。下面简单描述的命令行几乎对于所有的Unix shells都是适用的。
你的网络主机提供的shell很可能是[[WordPress:Wikipedia:Bash|bash]],bash指的是"Bourne Again Shell",是以编写了[[WordPress:Wikipedia:Bourne_shell|original 现代 Unix shell]]的[[WordPress:Wikipedia:Stephen_Bourne|Stephen Bourne]] 命名的。[[WordPress:Wikipedia:Bash|bash]]是由[http://www.gnu.org/ 免费软件基金会]来命名的。有许多不同的Unix shells。下面简单描述的命令行几乎对于所有的Unix shells都是适用的。
=== ssh, the secure shell ===
=== ssh, 安全 shell ===
=== ssh, 安全 shell ===
The [[WordPress:Wikipedia:Secure Shell|Secure Shell]] (ssh) is a complete set of tools for remote administration of your website. It includes [[WordPress:Wikipedia:SSH_file_transfer_protocol|SFTP]] (Secure File Transfer Protocol) for the uploading of files to your host. The main benefit of using [[WordPress:Wikipedia:Secure Shell|ssh]] to interface with a remote server is increased security. With other server access tools, your login password may be transferred over the Internet in plain text, which may be intercepted.
[[WordPress:Wikipedia:Secure Shell|安全 Shell]] (ssh)是用于远程管理你的站点的一套完整的工具。包含有[[WordPress:Wikipedia:SSH_file_transfer_protocol|SFTP]] (安全文件传输协议)用来向你的主机上传文件。使用[[WordPress:Wikipedia:Secure Shell|ssh]]的主要好处是,通过与一个远程的服务器接触来增加安全性。与其它的服务器访问工具一起,你的登录密码可能通过一个纯文本在因特网上传输,可能会被截取。
[[WordPress:Wikipedia:Secure Shell|安全 Shell]] (ssh)是用于远程管理你的站点的一套完整的工具。包含有[[WordPress:Wikipedia:SSH_file_transfer_protocol|SFTP]] (安全文件传输协议)用来向你的主机上传文件。使用[[WordPress:Wikipedia:Secure Shell|ssh]]的主要好处是,通过与一个远程的服务器接触来增加安全性。与其它的服务器访问工具一起,你的登录密码可能通过一个纯文本在因特网上传输,可能会被截取。
'''To use [[WordPress:Wikipedia:Secure Shell|ssh]] under Windows''', use [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY] or [http://www.cygwin.com/ Cygwin], a UNIX-like environment for Windows. The [http://filezilla.sourceforge.net FileZilla] [[WordPress:FTP Clients|ftp client]] also supports sftp via ssh-2.


'''在Windows下,使用 [[WordPress:Wikipedia:Secure Shell|ssh]] ''', 使用 [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY] 或者[http://www.cygwin.com/ Cygwin], 为Widows使用一个类似UNIX的环境。The [http://filezilla.sourceforge.net FileZilla] [[WordPress:FTP Clients|ftp client]] 通过ssh-2也支持sftp 。
'''在Windows下,使用 [[WordPress:Wikipedia:Secure Shell|ssh]] ''', 使用 [http://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY] 或者[http://www.cygwin.com/ Cygwin], 为Widows使用一个类似UNIX的环境。The [http://filezilla.sourceforge.net FileZilla] [[WordPress:FTP Clients|ftp client]] 通过ssh-2也支持sftp 。
'''To use [[WordPress:Wikipedia:Secure Shell|ssh]] on a Mac running OS X''', use the Terminal-based SSH program supplied with Mac OS X or download [http://rsug.itd.umich.edu/software/fugu/ Fugu].


'''要在一个运行OS X的Mac上使用[[WordPress:Wikipedia:Secure Shell|ssh]] ''', 使用Mac OS X 支持的,以终端为基础的SSH程序或者下载[http://rsug.itd.umich.edu/software/fugu/ Fugu]。
'''要在一个运行OS X的Mac上使用[[WordPress:Wikipedia:Secure Shell|ssh]] ''', 使用Mac OS X 支持的,以终端为基础的SSH程序或者下载[http://rsug.itd.umich.edu/software/fugu/ Fugu]。
'''On Linux or UNIX-based operating systems''', you can use the text-based SSH and SFTP clients from terminals such as Konsole, Gnome Terminal or xterm. Graphical FTP clients such as [http://kbear.sourceforge.net/ KBear] and [http://gftp.seul.org/ gFTP] also support [[WordPress:Wikipedia:SSH_file_transfer_protocol|sftp]].


'''在 Linux 或者以 UNIX为基础的操作系统上''', 你可以从终端上使用以文本为基础的SSH和SFTP clients,如Konsole, Gnome Terminal 或者xterm。 图画式的 FTP clients 如[http://kbear.sourceforge.net/ KBear] and [http://gftp.seul.org/ gFTP] 也支持[[WordPress:Wikipedia:SSH_file_transfer_protocol|sftp]]。
'''在 Linux 或者以 UNIX为基础的操作系统上''', 你可以从终端上使用以文本为基础的SSH和SFTP clients,如Konsole, Gnome Terminal 或者xterm。 图画式的 FTP clients 如[http://kbear.sourceforge.net/ KBear] and [http://gftp.seul.org/ gFTP] 也支持[[WordPress:Wikipedia:SSH_file_transfer_protocol|sftp]]。


Your hosting company will provide the username and host details  (the "shell account") necessary to use these. They may be different from the ones you use with your control panel. To use, at the Terminal prompt type <pre>ssh username@host</pre> or <pre>sftp username@host</pre>
你的主机公司会提供用户名你和主机的详细信息,使用这些信息是必要的。这些信息可能与你在控制面板上使用的信息有所不同。要使用这些信息,在Terminal prompt 输入<pre>ssh username@host</pre> or <pre>sftp username@host</pre>
 
你的主机公司会提供用户名你和主机的详细信息,使用这些信息是必要的。这些信息可能与你在控制面板上使用的信息有所不同。要使用这新信息,在Terminal prompt 输入<pre>ssh username@host</pre> or <pre>sftp username@host</pre>
 
== Terminology ==


== 术语==
== 术语==  
 
Before we get started with some UNIX commands, let's review some terminology. 


在开始处理一些UNIX commands之前,让我们来阅读一些术语。
在开始处理一些UNIX commands之前,让我们来阅读一些术语。
;'''Directories? Folders?'''


;'''目录? 文件夹?'''  
;'''目录? 文件夹?'''  
:A Directory is the same thing as a folder. Directories can contain subdirectories.


;目录与文件夹指的是同一样的内容。目录可以包含有子目录。
;目录与文件夹指的是同一样的内容。目录可以包含有子目录。
* A dot (period or full stop) refers to the current directory; two dots represent the directory above the current directory. 


*点(句点或者句号)指的是当前的目录;两个点指的是当前目录的上级目录。
*点(句点或者句号)指的是当前的目录;两个点指的是当前目录的上级目录。
* The tilde character (~) refers to your home directory.


*曲线字符(~)指的是你的主页目录。
*曲线字符(~)指的是你的主页目录。


* The tilde followed by a user's name (as in <tt style="font-weight:bold; color:#036">~username</tt>) refers to that user's home directory.
*用户名后面的曲线字符(如在<tt style="font-weight:bold; color:#036">~username</tt>)指的是用户的主页目录。
 
*用户名后面的曲线字符(如在<tt style="font-weight:bold; color:#036">~用户名</tt>)指的是用户的主页目录。
 
:Both the dot symbols and the tilde can be treated as directory names.  For example, <tt style="font-weight:bold; color:#036">../config.php</tt> refers to the file <tt style="font-weight:bold; color:#036">config.php</tt> in the directory above the current one. The directory <tt style="font-weight:bold; color:#036">./functions.php</tt> refers to <tt style="font-weight:bold; color:#036">functions.php</tt> in the current directory. And <tt style="font-weight:bold; color:#036">~/public_html</tt> or <tt style="font-weight:bold; color:#036">~/htdocs</tt> are (usually) the names of your main web directory, which is likely to be a subdirectory of your home directory. The domain [[WordPress:Glossary#URI|URI]] shown in your web browser's address bar refers to the main web directory, not to the site owner's home directory.
 


:句点标记和曲线符号都可以看作为目录名称。例如, <tt style="font-weight:bold; color:#036">../config.php</tt>指的是当前目录的上一次目录上的文件 <tt style="font-weight:bold; color:#036">config.php</tt>。目录 <tt style="font-weight:bold; color:#036">./functions.php</tt> 指的是当前目录中的 <tt style="font-weight:bold; color:#036">functions.php</tt>。而且 <tt style="font-weight:bold; color:#036">~/public_html</tt> or <tt style="font-weight:bold; color:#036">~/htdocs</tt> (通常)是你的主要网页目录的名称,这个名称很可能是你的主页目录的一个子目录的名称。显示在你的网络服务器的地址框中域 [[WordPress:Glossary#URI|URI]] 指的是主要的网页目录,而不是站点所有者的主页目录。
:句点标记和曲线符号都可以看作为目录名称。例如, <tt style="font-weight:bold; color:#036">../config.php</tt>指的是当前目录的上一次目录上的文件 <tt style="font-weight:bold; color:#036">config.php</tt>。目录 <tt style="font-weight:bold; color:#036">./functions.php</tt> 指的是当前目录中的 <tt style="font-weight:bold; color:#036">functions.php</tt>。而且 <tt style="font-weight:bold; color:#036">~/public_html</tt> or <tt style="font-weight:bold; color:#036">~/htdocs</tt> (通常)是你的主要网页目录的名称,这个名称很可能是你的主页目录的一个子目录的名称。显示在你的网络服务器的地址框中域 [[WordPress:Glossary#URI|URI]] 指的是主要的网页目录,而不是站点所有者的主页目录。


;'''前斜线(/)'''  
;'''前斜线(/)'''  
:The forward slash fulfils the same role it does in a website URI: it shows the item after to be in a subdirectory or the directory before it. A forward slash on its own refers to the root directory, which is at the <em>top</em> of the file system.


:前斜线的功能与前斜线在网站URI上的功能相同:it shows the item after to be in a subdirectory or the directory before it.斜线本身代表根目录,在文件系统的<em>顶上方</em>。
:前斜线的功能与前斜线在网站URI上的功能相同:it shows the item after to be in a subdirectory or the directory before it.斜线本身代表根目录,在文件系统的<em>顶上方</em>。
;'''Directory Name Character Rules and Spaces'''


;'''目录名字符规则和空格'''  
;'''目录名字符规则和空格'''  
:A file or directory name can contain any standard character except a forward slash &mdash; including white spaces. However, when entering shell commands, you separate commands, parameters, and files with spaces. If you have a space in a file or directory name, you need to use a backslash in front of it or put quotation marks round the name.  A directory called <tt style="font-weight:bold; color:#036">My Pictures</tt> would be entered as <pre>"My Pictures"</pre> or as <pre>My\ Pictures</pre>


:文件或者目录名称可以包含任何标准的字符,但是一个前斜线&mdash除外;空格也除外。然而,当输入shell 命令行的时候,你用空格将命令行,参数,和文件分开。如果你的文件或者目录名中有一个空格,你需要在空格的前面使用一个前斜线。或者在文件或目录名称的周围加上一个引号。一个称为<tt style="font-weight:bold; color:#036">我的图片</tt>的目录,会以<pre>"我的图片"</pre> 或者 <pre>我的\ 图片</pre>输入。
:文件或者目录名称可以包含任何标准的字符,但是一个前斜线&mdash除外;空格也除外。然而,当输入shell 命令行的时候,你用空格将命令行,参数,和文件分开。如果你的文件或者目录名中有一个空格,你需要在空格的前面使用一个前斜线。或者在文件或目录名称的周围加上一个引号。一个称为<tt style="font-weight:bold; color:#036">我的图片</tt>的目录,会以<pre>"我的图片"</pre> 或者 <pre>我的\ 图片</pre>输入。
'''The * and ? Symbols''': The <tt style="font-weight:bold; color:#036">*</tt> and <tt style="font-weight:bold; color:#036">?</tt> symbols are called [[WordPress:Wikipedia:Wildcard_character|wildcards]] and can be used in any command which deals with files.  The <tt style="font-weight:bold; color:#036">*</tt> represents any number of characters. The <tt style="font-weight:bold; color:#036">?</tt> represents just one. Note that Linux filenames are case-sensitive &mdash; the norm is lowercase.  All commands are lowercase.<br /><br />


''' *和? 符号''': <tt style="font-weight:bold; color:#036">*</tt> 和<tt style="font-weight:bold; color:#036">?</tt> 符号称为[[WordPress:Wikipedia:Wildcard_character|通配符]] 可以用在任何处理文件的命令行中。<tt style="font-weight:bold; color:#036">*</tt> 指的是许多字符。<tt style="font-weight:bold; color:#036">?</tt>指的是一个字符。注意Linux 文件名是区分大小写的&mdash; 规范的形式是小写形式。所有的命令行都是小写的。 <br /><br />
''' *和? 符号''': <tt style="font-weight:bold; color:#036">*</tt> 和<tt style="font-weight:bold; color:#036">?</tt> 符号称为[[WordPress:Wikipedia:Wildcard_character|通配符]] 可以用在任何处理文件的命令行中。<tt style="font-weight:bold; color:#036">*</tt> 指的是许多字符。<tt style="font-weight:bold; color:#036">?</tt>指的是一个字符。注意Linux 文件名是区分大小写的&mdash; 规范的形式是小写形式。所有的命令行都是小写的。 <br /><br />
'''Command Options''': Commands usually accept options or parameters, which are given in a sequence beginning with a hyphen (-). If you would want to set options <tt style="font-weight:bold; color:#036">b</tt>, <tt style="font-weight:bold; color:#036">r</tt> and <tt style="font-weight:bold; color:#036">f</tt> for a command, type <pre>command -brf</pre> Other specifications, like file names, go after the options.


'''命令选项''':命令通常接受选项或者参数, 这些选项和字符以一个连字号开始,挨次给出。如果你想为一个命令设置选项<tt style="font-weight:bold; color:#036">b</tt>, <tt style="font-weight:bold; color:#036">r</tt> and <tt style="font-weight:bold; color:#036">f</tt>,输入<pre>command -brf</pre>,其它的详细信息,例如文件名,在选项的后面。
'''命令选项''':命令通常接受选项或者参数, 这些选项和字符以一个连字号开始,挨次给出。如果你想为一个命令设置选项<tt style="font-weight:bold; color:#036">b</tt>, <tt style="font-weight:bold; color:#036">r</tt> and <tt style="font-weight:bold; color:#036">f</tt>,输入<pre>command -brf</pre>,其它的详细信息,例如文件名,在选项的后面。
== Shell Commands ==


== Shell 命令 ==
== Shell 命令 ==
Here's a brief introduction to some useful UNIX shell commands.


下面简要介绍一些有用的UNIX shell命令。
下面简要介绍一些有用的UNIX shell命令。


=== ls ===
=== ls ===
=== ls ===
This command displays a listing of a directory's contents. Unmodified, the command displays the contents of the current directory; you can also specify another directory's content to list. Some useful options are:


这个命令显示了一个目录的内容的列表。为更改前,命令显示了当前目录的内容;你可以特别规定列出另一个目录的内容。一些有用的选项是:
这个命令显示了一个目录的内容的列表。为更改前,命令显示了当前目录的内容;你可以特别规定列出另一个目录的内容。一些有用的选项是:


* <tt style="font-weight:bold; color:#036">ls -l</tt>
* <tt style="font-weight:bold; color:#036">ls -l</tt>
* <tt style="font-weight:bold; color:#036">ls -l</tt>
:If the list is long, you can display the list in pages. To do this, type <pre>ls -l |less</pre>


:如果列表很长,你可以在网页上显示列表。输入<pre>ls -l |less</pre> ,执行这一步
:如果列表很长,你可以在网页上显示列表。输入<pre>ls -l |less</pre> ,执行这一步
 
   
: (Note: The vertical bar <tt style="font-weight:bold; color:#036">|</tt> is also known as a UNIX ''pipe''). The pipe bar means that the output from <tt style="font-weight:bold; color:#036">ls -l</tt> is submitted to the program <tt style="font-weight:bold; color:#036">less</tt>, which displays pages of whatever input it receives. You can press space to view the next page, or the arrow keys to go up and down.  
: (注意: 竖线 <tt style="font-weight:bold; color:#036">|</tt>也成为一个 UNIX ''pipe''). pipe bar 指的是来自<tt style="font-weight:bold; color:#036">ls -l</tt>的输出,提交到了一个程序 <tt style="font-weight:bold; color:#036">less</tt>, 这个程序显示了任何收到的输入内容。你可以点击空白处,来访问下一个网页,或者点击箭头,向上或者向下翻看。
 
: (注意: 竖线 <tt style="font-weight:bold; color:#036">|</tt>也成为一个 UNIX ''pipe''). pipe bar 指的是来自<tt style="font-weight:bold; color:#036">ls -l</tt>的产出,提交到了一个程序 <tt style="font-weight:bold; color:#036">less</tt>, 这个程序显示了任何收到的输入内容。你可以点击空白处,来访问下一个网页,或者点击箭头,向上后者向下翻看。
 
* <tt style="font-weight:bold; color:#036">ls -la</tt>
:Includes hidden files (i.e. files that begin with a dot, like [[WordPress:Glossary#.htaccess|.htaccess]])in the directory listing.


* <tt style="font-weight:bold; color:#036">ls -la</tt>
* <tt style="font-weight:bold; color:#036">ls -la</tt>
第137行: 第64行:


* <tt style="font-weight:bold; color:#036">ls -l g*</tt>
* <tt style="font-weight:bold; color:#036">ls -l g*</tt>
* <tt style="font-weight:bold; color:#036">ls -l g*</tt>
:Specifies any other directory or file group to list after the options, and in this example would list all the files beginning with g, while <tt style="font-weight:bold; color:#036">ls public_html</tt> would list the contents of public_html.


:指定任何其它的目录或者文件组列在选项的后面,在一个例子中,会列出所有以g开始的文件,然而<tt style="font-weight:bold; color:#036">ls public_html</tt>会列出public_html的内容。
:指定任何其它的目录或者文件组列在选项的后面,在一个例子中,会列出所有以g开始的文件,然而<tt style="font-weight:bold; color:#036">ls public_html</tt>会列出public_html的内容。
=== cd ===
=== cd ===
=== cd ===
The <tt style="font-weight:bold; color:#036">cd</tt> command changes the current directory. To switch from the current directory into a sub-directory, put the sub-directory's name after the command. To change into a sub-directory <tt style="font-weight:bold; color:#036">wp-content</tt>, you'd type
<pre>
cd wp-content
</pre>
<tt style="font-weight:bold; color:#036">cd</tt>命令更改了当前的目录。要从当前的目录切换到一个子目录中,将子目录的名称放到命令行的后面。要变成一个子目录<tt style="font-weight:bold; color:#036">wp-content</tt>,你需要输入
<tt style="font-weight:bold; color:#036">cd</tt>命令更改了当前的目录。要从当前的目录切换到一个子目录中,将子目录的名称放到命令行的后面。要变成一个子目录<tt style="font-weight:bold; color:#036">wp-content</tt>,你需要输入
<pre>
<pre>
cd wp-内容
cd wp-wp-content
</pre>
</pre>


To move up into the directory above the current directory, type


要进入当前目录的上级目录,请输入:
要进入当前目录的上级目录,请输入:
第168行: 第79行:
</pre>
</pre>


<pre>
cd ..
</pre>
To change from the current directory to your home directory, type


要从当前目录切换到你的主目录中,输入
要从当前目录切换到你的主目录中,输入
<pre>
cd
</pre>
<pre>
<pre>
cd
cd
</pre>
</pre>
=== mkdir ===


=== mkdir ===
=== mkdir ===


The <tt style="font-weight:bold; color:#036">mkdir</tt> command creates a new directory inside the current one. To create a directory named <tt style="font-weight:bold; color:#036">audio</tt> inside the current directory, type
<tt style="font-weight:bold; color:#036">mkdir</tt>命令创建了一个在当前目录内部创建了一个新的目录。要在当前的目录中,创建一个名为<tt style="font-weight:bold; color:#036">audio</tt>目录,请输入
<pre>
mkdir audio
</pre>
 
<tt style="font-weight:bold; color:#036">mkdir</tt>命令创建了一个在当前目录内部创建了一个新的目录。要在当前的目录中,创建一个名为<tt style="font-weight:bold; color:#036">音频的</tt>目录,请输入
<pre>
<pre>
mkdir audio
mkdir audio
</pre>
To remove an empty directory, type <tt style="font-weight:bold; color:#036">rmdir directoryname</tt> for example:
<pre>
rmdir audio
</pre>
</pre>


第212行: 第98行:


=== rm ===
=== rm ===
=== rm ===
The <tt style="font-weight:bold; color:#036">rm</tt> command deletes ('removes') a file. To remove an entire directory and its contents in one go, type <tt style="font-weight:bold; color:#036">rm -rf directoryname</tt>. To delete the entire content of the current directory, use
<pre>rm -rf *</pre>
Beware &mdash; once something is removed in this way, it is gone forever.
<tt style="font-weight:bold; color:#036">rm</tt>命令删除('移除')一个文件。要一次地删除整个目录以及目录中所包含的内容,输入<tt style="font-weight:bold; color:#036">rm -rf directoryname</tt>。要删除当前目录中的所有内容,使用
<tt style="font-weight:bold; color:#036">rm</tt>命令删除('移除')一个文件。要一次地删除整个目录以及目录中所包含的内容,输入<tt style="font-weight:bold; color:#036">rm -rf directoryname</tt>。要删除当前目录中的所有内容,使用
<pre>rm -rf *</pre>  
<pre>rm -rf *</pre>  
要谨慎&mdash;一旦某个内容以这样的方式删除掉了,这个内容就永远都不会返回了。
要谨慎&mdash;一旦某个内容以这样的方式删除掉了,这个内容就永远都不会返回了。
=== exit ===


=== 离开当前命令行外壳 ===
=== 离开当前命令行外壳 ===
The <tt style="font-weight:bold; color:#036">exit</tt> command ends your shell session.


<tt style="font-weight:bold; color:#036">exit</tt>命令结束了你的shell部分。
<tt style="font-weight:bold; color:#036">exit</tt>命令结束了你的shell部分。
第234行: 第108行:
=== mv ===
=== mv ===


=== mv ===
<tt style="font-weight:bold; color:#036">mv</tt>命令将文件从一个位置移到了另一个位置;同时还会重新命名文件。输入


The <tt style="font-weight:bold; color:#036">mv</tt> command moves files from one place to a another; it is also used to rename files. Type
<pre>mv file new-location</pre>   
<pre>mv file new-location</pre>   


<tt style="font-weight:bold; color:#036">mv</tt>命令将文件从一个位置移到了另一个位置;同时还会重新命名文件。输入
如果 <tt style="font-weight:bold; color:#036">new-location</tt> 参数是当前文件系统中的一个 (有效的) 目录,文件就会被移动到这个目录;如果目录不是有效地目录 (而且目录名不与当前的文件名相冲突的话), <tt style="font-weight:bold; color:#036">文件</tt> 就会被重新命名为 <tt style="font-weight:bold; color:#036">new-location</tt>。你也可以使用一个命令,移动和重新命名一个文件:
 
<pre>mv 文件 移到新的位置</pre> 
 
If the <tt style="font-weight:bold; color:#036">new-location</tt> parameter is a (valid) directory in the current filesystem, the file is moved into that directory; if it isn't (and if it doesn't clash with an existing filename), the <tt style="font-weight:bold; color:#036">file</tt> will be renamed as <tt style="font-weight:bold; color:#036">new-location</tt>. You can also move and rename a file with one command:
<pre>mv file ~/path/to/new-file-name</pre>
 
如果 <tt style="font-weight:bold; color:#036">new-location</tt> 参数是当前文件系统中的一个 (有效的) 目录,文件就会一旦这个目录;如果目录不是有效地目录 (而且目录名不与当前的文件名相冲突的话), <tt style="font-weight:bold; color:#036">文件</tt> 就会被重新命名为 <tt style="font-weight:bold; color:#036">new-location</tt>。你也可以使用一个命令,移动和重新命名一个文件:
  <pre>mv file ~/path/to/new-file-name</pre>
  <pre>mv file ~/path/to/new-file-name</pre>
=== cp ===


=== cp ===
=== cp ===


 
<tt style="font-weight:bold; color:#036">cp</tt>命令复制文件或者目录。要复制一个目录和目录的全部内容,请使用
The <tt style="font-weight:bold; color:#036">cp</tt> command copies files or directories.  To copy a directory and its entire contents, use
 
<tt style="font-weight:bold; color:#036">cp</tt>命令复制文件或者目录。要目录一个目录和目录的全部内容,请使用
 
<pre>cp -rf source-file destination</pre>
 


<pre>cp -rf source-file destination</pre>
<pre>cp -rf source-file destination</pre>
=== ln ===


=== ln ===
=== ln ===
 
<tt style="font-weight:bold; color:#036">ln</tt>命令创建链接。与我们的目标相关的链接是"符号链接" 或者 ''symlinks'' &mdash;文件系统中 "指向" 其它文件或者目录的文件。当你访问一个 symlink的时候,你真正是在使用原始文件。如果你想要将你的WordPress目录的位置,如从<tt style="font-weight:bold; color:#036">/wordpress/</tt> 改到<tt style="font-weight:bold; color:#036">/blog/</tt>中,你可以创建一个如下的symlinks: <pre>ln -s wordpress blog</pre>
The <tt style="font-weight:bold; color:#036">ln</tt> command creates links. The links relevant to our purposes are "symbolic links" or ''symlinks'' &mdash; files which "point" to other files or directories in the filesystem. When you access a symlink, you are actually accessing the original file. If you want to change the location of your WordPress directory from, say, <tt style="font-weight:bold; color:#036">/wordpress/</tt> to <tt style="font-weight:bold; color:#036">/blog/</tt>, you could create a symlink as follows:
<pre>ln -s wordpress blog</pre>
 
<tt style="font-weight:bold; color:#036">ln</tt>命令创建链接。与我们的目标相关的链接是"符号链接" 或者 ''symlinks'' &mdash;文件系统中 "指向" 其它文件或者目录的文件。当你访问一个 symlink的时候,你真正是在使用原始文件。如果你想要将你的WordPress目录的位置,如从<tt style="font-weight:bold; color:#036">/wordpress/</tt> 改到<tt style="font-weight:bold; color:#036">/博客/</tt>中,你可以创建一个如下的symlinks: <pre>ln -s wordpress blog</pre>
 
 
Access will then be through either the file or directory's actual name &mdash; <tt style="font-weight:bold; color:#036">wordpress</tt> &mdash; or through the link name &mdash; <tt style="font-weight:bold; color:#036">blog</tt>. In the [[WordPress:Administration_Panels#Options_-_Configuration_Settings|Options]] panel in the Wordpress [[WordPress:Administration Panels]], set the "Blog address (URI)" field to show the symlink rather than the name of the directory.


然后通过文件或者目录真正的名称来访问&mdash; <tt style="font-weight:bold; color:#036">wordpress</tt> &mdash;或者通过链接名&mdash; <tt style="font-weight:bold; color:#036">blog</tt>。在WordPress[[WordPress:Administration Panels|管理面板]]的[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]]面板中,设置"博客地址(URI)"区,来显示symlink取代目录名。
然后通过文件或者目录真正的名称来访问&mdash; <tt style="font-weight:bold; color:#036">wordpress</tt> &mdash;或者通过链接名&mdash; <tt style="font-weight:bold; color:#036">blog</tt>。在WordPress[[WordPress:Administration Panels|管理面板]]的[[WordPress:Administration_Panels#Options_-_Configuration_Settings|选项]]面板中,设置"博客地址(URI)"区,来显示symlink取代目录名。


=== tar and unzip ===
=== tar and unzip ===
 
<tt style="font-weight:bold; color:#036">tar</tt> <tt style="font-weight:bold; color:#036">unzip</tt> 命令是用来压缩和解压"归档"文件的。存档指的是已经被"压缩的"文件或者文件加 &mdash; 例如,文件按大小得到了压缩&mdash; 通常是用来发行或者作为备份用的。<tt style="font-weight:bold; color:#036">解压</tt> 命令是用来将文件以<tt style="font-weight:bold; color:#036">.zip</tt>结束; the <tt style="font-weight:bold; color:#036">tar</tt> 命令是用来将文件以<tt style="font-weight:bold; color:#036">.tgz</tt> 或者 <tt style="font-weight:bold; color:#036">.tar.gz</tt>结束.  
=== tar 和解压 ===
 
 
The <tt style="font-weight:bold; color:#036">tar</tt> and <tt style="font-weight:bold; color:#036">unzip</tt> commands are used to compress and decompress "archive" files. Archives are files or folders that have been "compressed" &mdash; i.e. reduced in file-size &mdash; and are commonly used for distribution and backup purposes. The <tt style="font-weight:bold; color:#036">unzip</tt> command is used for files ending with <tt style="font-weight:bold; color:#036">.zip</tt>; the <tt style="font-weight:bold; color:#036">tar</tt> command is used for files ending with <tt style="font-weight:bold; color:#036">.tgz</tt> or <tt style="font-weight:bold; color:#036">.tar.gz</tt>.
 
<tt style="font-weight:bold; color:#036">tar</tt> 和 <tt style="font-weight:bold; color:#036">解压</tt> 命令是用来压缩和解压"归档"文件的。存档指的是已经被"压缩的"文件或者文件加 &mdash; 例如,文件按大小得到了压缩&mdash; 通常是用来发行或者作为备份用的。<tt style="font-weight:bold; color:#036">解压</tt> 命令是用来将文件以<tt style="font-weight:bold; color:#036">.zip</tt>结束; the <tt style="font-weight:bold; color:#036">tar</tt> 命令是用来将文件以<tt style="font-weight:bold; color:#036">.tgz</tt> or <tt style="font-weight:bold; color:#036">.tar.gz</tt>结束.  
 
 
'''Unzipping files''': If the file is a <tt style="font-weight:bold; color:#036">.tar.gz</tt> archive, type <pre>tar -zxvf file.tar.gz</pre>


'''解压文件''':如果文件是一个<tt style="font-weight:bold; color:#036">.tar.gz</tt>归档,请输入<pre>tar -zxvf file.tar.gz</pre>  
'''解压文件''':如果文件是一个<tt style="font-weight:bold; color:#036">.tar.gz</tt>归档,请输入<pre>tar -zxvf file.tar.gz</pre>  
If it's a <tt style="font-weight:bold; color:#036">zip</tt> archive, you may need to create a temporary directory into which you'd unzip its contents (its files might be unzipped into the current directory otherwise).


如果文件是<tt style="font-weight:bold; color:#036">压缩</tt>归档,你可能要创建一个临时的目录,你将文件的内容解压到这个目录中(否则,文件就会解压到当前的目录中)。
如果文件是<tt style="font-weight:bold; color:#036">压缩</tt>归档,你可能要创建一个临时的目录,你将文件的内容解压到这个目录中(否则,文件就会解压到当前的目录中)。
=== chmod and file permissions ===


=== chmod和文件权限 ===
=== chmod和文件权限 ===
The <tt style="font-weight:bold; color:#036">chmod</tt> command changes the permissions on a given file. UNIX file permissions specify who can do what with a given file. The <tt style="font-weight:bold; color:#036">ls -l</tt> command will tell you what permissions a file or directory has:
<tt style="font-weight:bold; color:#036">chmod</tt>更改了一个特定的文件的权限。UNIX 文件权限规定了谁可以对文件进行什么样的处理。<tt style="font-weight:bold; color:#036">ls -l</tt> 命令告诉了你一个文件或者目录拥有什么权限:
<tt style="font-weight:bold; color:#036">chmod</tt>更改了一个特定的文件的权限。UNIX 文件权限规定了谁可以对文件进行什么样的处理。<tt style="font-weight:bold; color:#036">ls -l</tt> 命令告诉了你一个文件或者目录拥有什么权限:
<pre style="font-size: 0.82em">
-rw-r--r--      1 domain60 vweb    840  Feb 21 06:38 wp-config-sample.php
-rw-r--r--      1 domain60 vweb    826  Jun 29 20:31 wp-config.php
drwxr-xr-x      4 domain60 vweb    4096  Jun 29 20:30 wp-content
-rw-r--r--      1 domain60 vweb    762  Mar 29 16:05 wp-feed.php
drwxr-xr-x      3 domain60 vweb    4096  Jun 29 18:46 wp-images
drwxr-xr-x      2 domain60 vweb    4096  Jun 29 18:46 wp-includes
</pre>


<pre style="font-size: 0.82em">
<pre style="font-size: 0.82em">
第322行: 第144行:
  drwxr-xr-x      2 domain60 vweb    4096  六月 29 18:46 wp-includes
  drwxr-xr-x      2 domain60 vweb    4096  六月 29 18:46 wp-includes
</pre>
</pre>
The permissions are displayed in the string of letters in the first column. The very first letter of that column indicates whether it is a file, a link, or a directory.  A <tt style="font-weight:bold; color:#036">d</tt> denotes a directory, a <tt style="font-weight:bold; color:#036">l</tt> denotes a link, a hyphen denotes a file.


权限显示在第一个栏中的字母串中。那个栏中的第一个字母暗示了字母串是文件,链接还是目录。<tt style="font-weight:bold; color:#036">d</tt>表示目录,<tt style="font-weight:bold; color:#036">l</tt>表示链接,一个破折号表示一个文件。
权限显示在第一个栏中的字母串中。那个栏中的第一个字母暗示了字母串是文件,链接还是目录。<tt style="font-weight:bold; color:#036">d</tt>表示目录,<tt style="font-weight:bold; color:#036">l</tt>表示链接,一个破折号表示一个文件。
The permissions are declared with the following nine letters, which are shown in groups of three.  The first group of three concerns the owner, the second the group he belongs to (this is unlikely to concern you as a web host user), and the third concerns everyone else.  Note that people with root access (administrators) have access to all files on the system.


权限是用下面九个字母公告的,这九个字母作为三组显示。第一组的三个字母,涉及所有者,第二组他所属于的那个组(不可能设计到你,一个网络主机用户),第三组涉及到其他所有的人。注意拥有根权限(管理员)的人能够访问系统上的所有文件。
权限是用下面九个字母公告的,这九个字母作为三组显示。第一组的三个字母,涉及所有者,第二组他所属于的那个组(不可能设计到你,一个网络主机用户),第三组涉及到其他所有的人。注意拥有根权限(管理员)的人能够访问系统上的所有文件。
The letters <tt style="font-weight:bold; color:#036">r</tt>, <tt style="font-weight:bold; color:#036">w</tt> and <tt style="font-weight:bold; color:#036">x</tt> stand for read, write and execute; if the file is a directory, executable means traversible, that is, that you can move into that directory with the <tt style="font-weight:bold; color:#036">cd</tt> command. Where a hyphen is shown in the permissions list, the permission is absent.


字母<tt style="font-weight:bold; color:#036">r</tt>, <tt style="font-weight:bold; color:#036">w</tt> 和 <tt style="font-weight:bold; color:#036">x</tt>代表着阅读,写和执行;如果文件是一个目录,可执行的指的是可移动的,意思是你可以用<tt style="font-weight:bold; color:#036">cd</tt>命令,移动到那个目录上。当权限列表上出现一个破折号的时候,这个权限不存在。
字母<tt style="font-weight:bold; color:#036">r</tt>, <tt style="font-weight:bold; color:#036">w</tt> 和 <tt style="font-weight:bold; color:#036">x</tt>代表着阅读,写和执行;如果文件是一个目录,可执行的指的是可移动的,意思是你可以用<tt style="font-weight:bold; color:#036">cd</tt>命令,移动到那个目录上。当权限列表上出现一个破折号的时候,这个权限不存在。
You change permissions with the <tt style="font-weight:bold; color:#036">chmod</tt> command. You may, in fact, not have to change the permissions at all; some hosts automatically set certain permissions on any file in the web directory. Your host may also tell you what permissions need to be set on your server.


你用<tt style="font-weight:bold; color:#036">chmod</tt>命令更改权限。事实上,你可能不需要更改权限;一些主机在网络目录上的任何文件上,自动地设置某个权限。你的主机可能会通知你,你的服务器上需要设置什么权限。
你用<tt style="font-weight:bold; color:#036">chmod</tt>命令更改权限。事实上,你可能不需要更改权限;一些主机在网络目录上的任何文件上,自动地设置某个权限。你的主机可能会通知你,你的服务器上需要设置什么权限。
The <tt style="font-weight:bold; color:#036">chmod</tt> command can be used to set permissions in two ways: with letters or with numbers. If you use letters, you could type <pre>chmod o+w filename</pre> 
This grants write privileges to everyone with access to the system. The first letter can be u (user), g (group) or o (other), or a combination; the + (grant) can also be - (withhold), and the third can also be r or x (read or execute).


<tt style="font-weight:bold; color:#036">chmod</tt>命令可以用来以两种方式设置权限:用字母或者用数字来设置权限。如果你使用字母,你可以输入<pre>chmod o+w 文件名</pre>   
<tt style="font-weight:bold; color:#036">chmod</tt>命令可以用来以两种方式设置权限:用字母或者用数字来设置权限。如果你使用字母,你可以输入<pre>chmod o+w 文件名</pre>   
这赋予每个人使用系统的特权。第一个字母可以使u(用户),g(小组)或者o(其它的),或者一个组合;the + (grant) 也可以是 be - (withhold), 第三个字母也可以是 r 或者 x (阅读或者执行)。
这赋予每个人使用系统的特权。第一个字母可以使u(用户),g(小组)或者o(其它的),或者一个组合;the + (grant) 也可以是 be - (withhold), 第三个字母也可以是 r 或者 x (阅读或者执行)。
If you use numbers, all permissions for a file are set in one go. An example:
<pre>chmod 755 wp-images</pre>
sets the permssions of the <tt style="font-weight:bold; color:#036">wp-images</tt> directory to 755, whereby the first number (the "hundreds") is for the user, the second (the "tens") is for the group and the third (the "units") is for everyone else.


如果你使用数字,文件的所有权限都可以一次设置好。如:
如果你使用数字,文件的所有权限都可以一次设置好。如:
<pre>chmod 755 wp-images</pre>  
<pre>chmod 755 wp-images</pre>  
设置了<tt style="font-weight:bold; color:#036">wp-images</tt>目录的权限为755,然后第一个数字("百位数")是为用户设置的,第二位数("十位数")是为小组设置的,第三位数("个位数")是为其他所有的人设置的。
设置了<tt style="font-weight:bold; color:#036">wp-images</tt>目录的权限为755,然后第一个数字("百位数")是为用户设置的,第二位数("十位数")是为小组设置的,第三位数("个位数")是为其他所有的人设置的。
'''More about numerical permissions settings:''' To add 4 in any of the fields grants read privileges; to add 2 grants write and to add 1 grants executability; each combination has a unique number. The directories in the example above have the permission set 755, which is common for web-available directories, in which the user has full privileges while others have read and execute only; the files in the example have the permission set 644, in which the user can read and write while others can only read.


'''更多关于数字权限设置的内容:'''在任何区域中添加4,赋予了阅读权限;添加2赋予了编写的权限,而添加1赋予了执行的权限;每个组合都有一个独特的数字。上述例子中的目录,将权限设置为755,对于网络上可以使用的目录,这个权限非常常见,用户拥有所有的特权,而其他人只有阅读和执行的权限;上述例子中的文件的权限设置为644,用户可以阅读和编写文件,而其他人只能够阅读文件。
'''更多关于数字权限设置的内容:'''在任何区域中添加4,赋予了阅读权限;添加2赋予了编写的权限,而添加1赋予了执行的权限;每个组合都有一个独特的数字。上述例子中的目录,将权限设置为755,对于网络上可以使用的目录,这个权限非常常见,用户拥有所有的特权,而其他人只有阅读和执行的权限;上述例子中的文件的权限设置为644,用户可以阅读和编写文件,而其他人只能够阅读文件。
第367行: 第171行:
  drwxr-xr-x  2 domain60 vweb  4096 Jun 29 18:46 wp-includes
  drwxr-xr-x  2 domain60 vweb  4096 Jun 29 18:46 wp-includes
</pre>
</pre>
<pre style="font-size: 0.9em">
  6  4  4
  420400400
-rw-r--r--  1 domain60 vweb  840  Feb 21 06:38 wp-config-sample.php
  7  5  5
  421401401
drwxr-xr-x  2 domain60 vweb  4096 Jun 29 18:46 wp-includes
</pre>
=== wget ===


=== wget ===
=== wget ===
The <tt style="font-weight:bold; color:#036">wget</tt> command downloads a file if you put a web location (URI) after it. To download the latest WordPress release type <pre>wget http://wordpress.org/latest.tar.gz</pre>


如果你在<tt style="font-weight:bold; color:#036">wget</tt>命令后,加上一个网络地址(URI),这个命令就会下载一个文件。要下载最新发行的WordPress版本,请输入<pre>wget http://wordpress.org/latest.tar.gz</pre>
如果你在<tt style="font-weight:bold; color:#036">wget</tt>命令后,加上一个网络地址(URI),这个命令就会下载一个文件。要下载最新发行的WordPress版本,请输入<pre>wget http://wordpress.org/latest.tar.gz</pre>
== Upgrading WordPress from the Shell ==


== 从Shell中升级WordPress ==
== 从Shell中升级WordPress ==
Let's use the example of upgrading WordPress using the command line. First, establish the location of your WordPress on your web server's filesystem. This example assumes it is located at <tt style="font-weight:bold; color:#036">~/public_html/blog</tt>.


让我们来使用,用命令行升级WordPress的例子。首先,在你的网络服务器的文件系统上确立你的WordPress的位置。这个例子中假如WordPress位于<tt style="font-weight:bold; color:#036">~/public_html/blog</tt>。
让我们来使用,用命令行升级WordPress的例子。首先,在你的网络服务器的文件系统上确立你的WordPress的位置。这个例子中假如WordPress位于<tt style="font-weight:bold; color:#036">~/public_html/blog</tt>。


<ol>
<li>Download the current version of WordPress to your shell account's home directory and unzip it: <pre>wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz</pre>
<ol>
<ol>
<li>为你的shell帐户的主页目录下载当前的WordPress版本并且将这个版本解压:<pre>wget http://wordpress.org/latest.tar.gz
<li>为你的shell帐户的主页目录下载当前的WordPress版本并且将这个版本解压:<pre>wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz</pre>
tar -zxvf latest.tar.gz</pre>
The WordPress archive will be unpacked into a new directory named <tt style="font-weight:bold; color:#036">/wordpress</tt>.</li>
<li>Enter the new directory with the following command: <pre>cd wordpress</pre></li>


WordPress存档文件会被解压到一个新的目录,目录名为<tt style="font-weight:bold; color:#036">/wordpress</tt>.</li>
WordPress存档文件会被解压到一个新的目录,目录名为<tt style="font-weight:bold; color:#036">/wordpress</tt>.</li>
<li>用下面的命令输入新的目录:<pre>cd wordpress</pre></li>
<li>用下面的命令输入新的目录:<pre>cd wordpress</pre></li>
<li>Remove <tt style="font-weight:bold; color:#036">wp-config-sample.php</tt>: <pre>rm wp-config-sample.php</pre> (We will use our current <tt style="font-weight:bold; color:#036">wp-config.php</tt> instead)</li>


<li>移除 <tt style="font-weight:bold; color:#036">wp-config-sample.php</tt>: <pre>rm wp-config-sample.php</pre> (取而代之,我们会看到当前的<tt style="font-weight:bold; color:#036">wp-config.php</tt>)</li>
<li>移除 <tt style="font-weight:bold; color:#036">wp-config-sample.php</tt>: <pre>rm wp-config-sample.php</pre> (取而代之,我们会看到当前的<tt style="font-weight:bold; color:#036">wp-config.php</tt>)</li>
<li>Remove the entire <tt style="font-weight:bold; color:#036">/wp-content</tt> directory from the new directory (we will replace it with the one from our WordPress blog directory): <pre>rm -rf wp-content</pre></li>


<li>将整个<tt style="font-weight:bold; color:#036">/wp-content</tt> 目录,从新的目录中移除 (我们会用WordPress博客中的目录来代替这个目录): <pre>rm -rf wp-content</pre></li>
<li>将整个<tt style="font-weight:bold; color:#036">/wp-content</tt> 目录,从新的目录中移除 (我们会用WordPress博客中的目录来代替这个目录): <pre>rm -rf wp-content</pre></li>
<li>Copy the blog's <tt style="font-weight:bold; color:#036">wp-config.php</tt> and <tt style="font-weight:bold; color:#036">.htaccess</tt> file to the new directory: <pre>cp ~/public_html/blog/wp-config.php .


<li>将博客的<tt style="font-weight:bold; color:#036">wp-config.php</tt> 和<tt style="font-weight:bold; color:#036">.htaccess</tt> 文件复制到新的目录中: <pre>cp ~/public_html/blog/wp-config.php .
<li>将博客的<tt style="font-weight:bold; color:#036">wp-config.php</tt> 和<tt style="font-weight:bold; color:#036">.htaccess</tt> 文件复制到新的目录中: <pre>cp ~/public_html/blog/wp-config.php .


 
cp ~/public_html/blog/.htaccess .</pre> 注意: 不要忘了两个命令后面的点号!</li>
cp ~/public_html/blog/.htaccess .</pre> Note: Don't forget the dot at the end of both commands!</li>
 
cp ~/public_html/blog/.htaccess .</pre> 注意: 不要网络两个命令后面的点号!</li>
 
 
<li>Copy the <tt style="font-weight:bold; color:#036">wp-content</tt> directory to the new directory (it contains all our themes and plugins): <pre>cp -rf ~/public_html/blog/wp-content/ .</pre> Again, note the dot at the end of the command.</li>


<li>将<tt style="font-weight:bold; color:#036">wp-content</tt>目录复制到新的目录(包含了我们所有的主题和插件): <pre>cp -rf ~/public_html/blog/wp-content/ .</pre> 再一次地注意,命令结尾的点号。</li>
<li>将<tt style="font-weight:bold; color:#036">wp-content</tt>目录复制到新的目录(包含了我们所有的主题和插件): <pre>cp -rf ~/public_html/blog/wp-content/ .</pre> 再一次地注意,命令结尾的点号。</li>
<li>Remove the entire contents of your WordPress blog directory: <pre>rm -rf ~/public_html/blog/*</pre></li>


<li>移除你的WordPress博客目录中的所有内容: <pre>rm -rf ~/public_html/blog/*</pre></li>
<li>移除你的WordPress博客目录中的所有内容: <pre>rm -rf ~/public_html/blog/*</pre></li>
<li>Finally, copy the entire contents of the new directory to your main blog directory: <pre>cp -rf * ~/public_html/blog</pre></li>
</ol>


<li>最后,将新目录的所有内容复制到你的主要博客目录中: <pre>cp -rf * ~/public_html/blog</pre></li>
<li>最后,将新目录的所有内容复制到你的主要博客目录中: <pre>cp -rf * ~/public_html/blog</pre></li>
</ol>
</ol>
== SFTP Shell Commands ==


== SFTP Shell 命令 ==
== SFTP Shell 命令 ==
SFTP stands for Secure File Transfer Protocol.  It is an encrypted replacement for FTP, and as with FTP, you may use a shell-based client or one of the graphical clients mentioned at the top of this article. If your host supports SSH, it also supports SFTP.


SFTP代表安全文件传输协议,是加密的FTP形式,如FTP,你可以使用在这篇文章的顶端所提到的一个shell为基础的client或者一个图形client。如果你的主机支持SSH,主机就同样支持SFTP。
SFTP代表安全文件传输协议,是加密的FTP形式,如FTP,你可以使用在这篇文章的顶端所提到的一个shell为基础的client或者一个图形client。如果你的主机支持SSH,主机就同样支持SFTP。


=== Shell-identical commands ===
=== 与Shell一样的命令===
=== 与Shell一样的命令===


 
Shell类型支持的命令,类似于用在bash中的命令。这些包括 <tt style="font-weight:bold; color:#036">cd</tt>, <tt style="font-weight:bold; color:#036">ls</tt>, <tt style="font-weight:bold; color:#036">mkdir</tt>, <tt style="font-weight:bold; color:#036">rm</tt> 和 <tt style="font-weight:bold; color:#036">rmdir</tt>。也支持 <tt style="font-weight:bold; color:#036">ln</tt>, 不同的是,你不需要使用<tt style="font-weight:bold; color:#036">-s</tt> 选项来创建symlinks; 在sftp中, <tt style="font-weight:bold; color:#036">ln</tt> 命令使得symlinks 是默认的。所有这些命令对于你的主机系统上的文件都起作用。
Shell-type SFTP clients support commands similar to those used in bash.  These include <tt style="font-weight:bold; color:#036">cd</tt>, <tt style="font-weight:bold; color:#036">ls</tt>, <tt style="font-weight:bold; color:#036">mkdir</tt>, <tt style="font-weight:bold; color:#036">rm</tt> and <tt style="font-weight:bold; color:#036">rmdir</tt>. It also supports <tt style="font-weight:bold; color:#036">ln</tt>, with the difference that you do not need to use the <tt style="font-weight:bold; color:#036">-s</tt> option to create symlinks; in sftp, the <tt style="font-weight:bold; color:#036">ln</tt> command makes symlinks by default. All of these work on files on your host's system.
 
 
Shell类型支持的命令,类似于用在bash中的命令。这些包括 <tt style="font-weight:bold; color:#036">cd</tt>, <tt style="font-weight:bold; color:#036">ls</tt>, <tt style="font-weight:bold; color:#036">mkdir</tt>, <tt style="font-weight:bold; color:#036">rm</tt> 和 <tt style="font-weight:bold; color:#036">rmdir</tt>。也支持 <tt style="font-weight:bold; color:#036">ln</tt>, 不同的是,你不需要使用<tt style="font-weight:bold; color:#036">-s</tt> 选项来创建symlinks; 在sftp中, <tt style="font-weight:bold; color:#036">ln</tt> 命令使得symlinks 是默认的。所欲这些命令对于你的主机系统上的文件都起作用。
 
=== put and mput ===


=== put and mput ===
=== put and mput ===
These two commands transfer to your host (i.e. upload) a single file (<tt style="font-weight:bold; color:#036">put</tt>) or any files that match the pattern you supply (<tt style="font-weight:bold; color:#036">mput</tt>); the wildcards <tt style="font-weight:bold; color:#036">*</tt> and <tt style="font-weight:bold; color:#036">?</tt> described above can be used here.


这两个命令转移到你的主机(例如上传)一个单独的文件(<tt style="font-weight:bold; color:#036">put</tt>)或者任何与你支持的模式相匹配的文件(<tt style="font-weight:bold; color:#036">mput</tt>);以上所描述的通配符<tt style="font-weight:bold; color:#036">*</tt> 和<tt style="font-weight:bold; color:#036">?</tt>可以用在这儿。
这两个命令转移到你的主机(例如上传)一个单独的文件(<tt style="font-weight:bold; color:#036">put</tt>)或者任何与你支持的模式相匹配的文件(<tt style="font-weight:bold; color:#036">mput</tt>);以上所描述的通配符<tt style="font-weight:bold; color:#036">*</tt> 和<tt style="font-weight:bold; color:#036">?</tt>可以用在这儿。


=== get and mget ===
=== get and mget ===
=== get and mget ===
These two commands transfer from your host to your local computer (i.e. download) a single file (<tt style="font-weight:bold; color:#036">get</tt>) or any files that match the supplied pattern (<tt style="font-weight:bold; color:#036">mget</tt>).  As with <tt style="font-weight:bold; color:#036">mput</tt>, <tt style="font-weight:bold; color:#036">*</tt> and <tt style="font-weight:bold; color:#036">?</tt> can be used.


这两个命令从你的主机转移到你的本地电脑上(例如下载)一个单一的文件(<tt style="font-weight:bold; color:#036">get</tt>)或者任何匹配支持的模式的文件(<tt style="font-weight:bold; color:#036">mget</tt>)。与<tt style="font-weight:bold; color:#036">mput</tt>一样,可以使用<tt style="font-weight:bold; color:#036">*</tt> 和 <tt style="font-weight:bold; color:#036">?</tt>。
这两个命令从你的主机转移到你的本地电脑上(例如下载)一个单一的文件(<tt style="font-weight:bold; color:#036">get</tt>)或者任何匹配支持的模式的文件(<tt style="font-weight:bold; color:#036">mget</tt>)。与<tt style="font-weight:bold; color:#036">mput</tt>一样,可以使用<tt style="font-weight:bold; color:#036">*</tt> 和 <tt style="font-weight:bold; color:#036">?</tt>。


=== cd, mkdir, ls ===
=== cd, mkdir, ls ===
=== cd, mkdir, ls ===
These commands are identical to their bash shell counterparts: change the current directory, make a new directory, and list the contents of the current directory. To do the same things within SFTP on your own machine, add an <tt style="font-weight:bold; color:#036">l</tt> to the front of the commands: <tt style="font-weight:bold; color:#036">lcd</tt>, <tt style="font-weight:bold; color:#036">lmkdir</tt>, <tt style="font-weight:bold; color:#036">lls</tt>.


这些命令与命令的bash shell命令是相同的:更改当前的目录,创建一个新的目录,列出当前目录的内容。在你自己的电脑的SFTP内部执行同样的操作,在命令的前面添加一个<tt style="font-weight:bold; color:#036">l</tt>:<tt style="font-weight:bold; color:#036">lcd</tt>, <tt style="font-weight:bold; color:#036">lmkdir</tt>, <tt style="font-weight:bold; color:#036">lls</tt>。
这些命令与命令的bash shell命令是相同的:更改当前的目录,创建一个新的目录,列出当前目录的内容。在你自己的电脑的SFTP内部执行同样的操作,在命令的前面添加一个<tt style="font-weight:bold; color:#036">l</tt>:<tt style="font-weight:bold; color:#036">lcd</tt>, <tt style="font-weight:bold; color:#036">lmkdir</tt>, <tt style="font-weight:bold; color:#036">lls</tt>。
== Further Reading ==


==深入阅读 ==
==深入阅读 ==
[http://catcode.com/teachmod/ chmod tutorial]
[http://catcode.com/teachmod/ chmod 指南]
[http://catcode.com/teachmod/ chmod 指南]
[http://www.classical-webdesigns.co.uk/resources/whatchmod.html What chmod?] online file permissions calculator
[http://www.classical-webdesigns.co.uk/resources/whatchmod.html 什么 chmod?]在线文件权限计算器
[http://www.classical-webdesigns.co.uk/resources/whatchmod.html 什么 chmod?]在线文件权限计算器
== See also ==


== 也看看 ==
== 也看看 ==
[[WordPress:Changing File Permissions]]
[[WordPress:htaccess for subdirectories]]


[[WordPress:Changing File Permissions|更改文件权限]]
[[WordPress:Changing File Permissions|更改文件权限]]


[[WordPress:htaccess for subdirectories|子目录的htaccess]]
[[WordPress:htaccess for subdirectories|子目录的htaccess]]

2008年7月1日 (二) 14:58的最新版本

注意: 这篇文章包含一个高级主题。

如果你最近从一个托管的写博客的solution,如Blogger或者TypePad中进入了WordPress,你可能对于管理网络空间和博客的任务不太熟悉。WordPress是以PHP为基础的; 许多托管服务使用服务器运行Linux 和Apache; 许多网络服务器不仅向它们的顾客提供以网络为基础的 控制界面 还提供 shell权限 或者命令行界面。许多WordPress用户对于使用shell 来管理文件系统,可能不熟悉。这篇文章介绍了更加常用的UNIX命令并且示范了一个常规的管理任务是如何运行的,如一个小型的WordPress升级,就是在shell上执行的。

The bash shell[ ]

你的网络主机提供的shell很可能是bash,bash指的是"Bourne Again Shell",是以编写了original 现代 Unix shellStephen Bourne 命名的。bash是由免费软件基金会来命名的。有许多不同的Unix shells。下面简单描述的命令行几乎对于所有的Unix shells都是适用的。

ssh, 安全 shell[ ]

安全 Shell (ssh)是用于远程管理你的站点的一套完整的工具。包含有SFTP (安全文件传输协议)用来向你的主机上传文件。使用ssh的主要好处是,通过与一个远程的服务器接触来增加安全性。与其它的服务器访问工具一起,你的登录密码可能通过一个纯文本在因特网上传输,可能会被截取。

在Windows下,使用 ssh , 使用 PuTTY 或者Cygwin, 为Widows使用一个类似UNIX的环境。The FileZilla ftp client 通过ssh-2也支持sftp 。

要在一个运行OS X的Mac上使用ssh , 使用Mac OS X 支持的,以终端为基础的SSH程序或者下载Fugu

在 Linux 或者以 UNIX为基础的操作系统上, 你可以从终端上使用以文本为基础的SSH和SFTP clients,如Konsole, Gnome Terminal 或者xterm。 图画式的 FTP clients 如KBear and gFTP 也支持sftp

你的主机公司会提供用户名你和主机的详细信息,使用这些信息是必要的。这些信息可能与你在控制面板上使用的信息有所不同。要使用这些信息,在Terminal prompt 输入

ssh username@host

or

sftp username@host

术语[ ]

在开始处理一些UNIX commands之前,让我们来阅读一些术语。

目录? 文件夹?

;目录与文件夹指的是同一样的内容。目录可以包含有子目录。

  • 点(句点或者句号)指的是当前的目录;两个点指的是当前目录的上级目录。
  • 曲线字符(~)指的是你的主页目录。
  • 用户名后面的曲线字符(如在~username)指的是用户的主页目录。
句点标记和曲线符号都可以看作为目录名称。例如, ../config.php指的是当前目录的上一次目录上的文件 config.php。目录 ./functions.php 指的是当前目录中的 functions.php。而且 ~/public_html or ~/htdocs (通常)是你的主要网页目录的名称,这个名称很可能是你的主页目录的一个子目录的名称。显示在你的网络服务器的地址框中域 URI 指的是主要的网页目录,而不是站点所有者的主页目录。
前斜线(/)

:前斜线的功能与前斜线在网站URI上的功能相同:it shows the item after to be in a subdirectory or the directory before it.斜线本身代表根目录,在文件系统的顶上方

目录名字符规则和空格

:文件或者目录名称可以包含任何标准的字符,但是一个前斜线&mdash除外;空格也除外。然而,当输入shell 命令行的时候,你用空格将命令行,参数,和文件分开。如果你的文件或者目录名中有一个空格,你需要在空格的前面使用一个前斜线。或者在文件或目录名称的周围加上一个引号。一个称为我的图片的目录,会以

"我的图片"

或者

我的\ 图片

输入。

*和? 符号: *? 符号称为通配符 可以用在任何处理文件的命令行中。* 指的是许多字符。?指的是一个字符。注意Linux 文件名是区分大小写的— 规范的形式是小写形式。所有的命令行都是小写的。

命令选项:命令通常接受选项或者参数, 这些选项和字符以一个连字号开始,挨次给出。如果你想为一个命令设置选项b, r and f,输入

command -brf

,其它的详细信息,例如文件名,在选项的后面。

Shell 命令[ ]

下面简要介绍一些有用的UNIX shell命令。

ls[ ]

这个命令显示了一个目录的内容的列表。为更改前,命令显示了当前目录的内容;你可以特别规定列出另一个目录的内容。一些有用的选项是:

  • ls -l

:如果列表很长,你可以在网页上显示列表。输入

ls -l |less

,执行这一步

(注意: 竖线 |也成为一个 UNIX pipe). pipe bar 指的是来自ls -l的输出,提交到了一个程序 less, 这个程序显示了任何收到的输入内容。你可以点击空白处,来访问下一个网页,或者点击箭头,向上或者向下翻看。
  • ls -la
包含隐藏文件 (例如,以一个圆点开始的文件,像目录列表中的 .htaccess)。
  • ls -l g*

:指定任何其它的目录或者文件组列在选项的后面,在一个例子中,会列出所有以g开始的文件,然而ls public_html会列出public_html的内容。

cd[ ]

cd命令更改了当前的目录。要从当前的目录切换到一个子目录中,将子目录的名称放到命令行的后面。要变成一个子目录wp-content,你需要输入

cd wp-wp-content


要进入当前目录的上级目录,请输入:

cd ..


要从当前目录切换到你的主目录中,输入

cd

mkdir[ ]

mkdir命令创建了一个在当前目录内部创建了一个新的目录。要在当前的目录中,创建一个名为audio目录,请输入

mkdir audio

要移除一个空目录,请输入rmdir directoryname例如;

rmdir audio

rm[ ]

rm命令删除('移除')一个文件。要一次地删除整个目录以及目录中所包含的内容,输入rm -rf directoryname。要删除当前目录中的所有内容,使用

rm -rf *

要谨慎—一旦某个内容以这样的方式删除掉了,这个内容就永远都不会返回了。

离开当前命令行外壳[ ]

exit命令结束了你的shell部分。

mv[ ]

mv命令将文件从一个位置移到了另一个位置;同时还会重新命名文件。输入

mv file new-location

如果 new-location 参数是当前文件系统中的一个 (有效的) 目录,文件就会被移动到这个目录;如果目录不是有效地目录 (而且目录名不与当前的文件名相冲突的话), 文件 就会被重新命名为 new-location。你也可以使用一个命令,移动和重新命名一个文件:

mv file ~/path/to/new-file-name

cp[ ]

cp命令复制文件或者目录。要复制一个目录和目录的全部内容,请使用

cp -rf source-file destination

ln[ ]

ln命令创建链接。与我们的目标相关的链接是"符号链接" 或者 symlinks —文件系统中 "指向" 其它文件或者目录的文件。当你访问一个 symlink的时候,你真正是在使用原始文件。如果你想要将你的WordPress目录的位置,如从/wordpress/ 改到/blog/中,你可以创建一个如下的symlinks:

ln -s wordpress blog

然后通过文件或者目录真正的名称来访问— wordpress —或者通过链接名— blog。在WordPress管理面板选项面板中,设置"博客地址(URI)"区,来显示symlink取代目录名。

tar and unzip[ ]

tarunzip 命令是用来压缩和解压"归档"文件的。存档指的是已经被"压缩的"文件或者文件加 — 例如,文件按大小得到了压缩— 通常是用来发行或者作为备份用的。解压 命令是用来将文件以.zip结束; the tar 命令是用来将文件以.tgz 或者 .tar.gz结束.

解压文件:如果文件是一个.tar.gz归档,请输入

tar -zxvf file.tar.gz

如果文件是压缩归档,你可能要创建一个临时的目录,你将文件的内容解压到这个目录中(否则,文件就会解压到当前的目录中)。

chmod和文件权限[ ]

chmod更改了一个特定的文件的权限。UNIX 文件权限规定了谁可以对文件进行什么样的处理。ls -l 命令告诉了你一个文件或者目录拥有什么权限:

 -rw-r--r--      1 domain60 vweb     840   二月 21 06:38 wp-config-sample.php
 -rw-r--r--      1 domain60 vweb     826   六月 29 20:31 wp-config.php
 drwxr-xr-x      4 domain60 vweb     4096  六月 29 20:30 wp-content
 -rw-r--r--      1 domain60 vweb     762   三月 29 16:05 wp-feed.php
 drwxr-xr-x      3 domain60 vweb     4096  六月 29 18:46 wp-images
 drwxr-xr-x      2 domain60 vweb     4096  六月 29 18:46 wp-includes

权限显示在第一个栏中的字母串中。那个栏中的第一个字母暗示了字母串是文件,链接还是目录。d表示目录,l表示链接,一个破折号表示一个文件。

权限是用下面九个字母公告的,这九个字母作为三组显示。第一组的三个字母,涉及所有者,第二组他所属于的那个组(不可能设计到你,一个网络主机用户),第三组涉及到其他所有的人。注意拥有根权限(管理员)的人能够访问系统上的所有文件。

字母r, wx代表着阅读,写和执行;如果文件是一个目录,可执行的指的是可移动的,意思是你可以用cd命令,移动到那个目录上。当权限列表上出现一个破折号的时候,这个权限不存在。

你用chmod命令更改权限。事实上,你可能不需要更改权限;一些主机在网络目录上的任何文件上,自动地设置某个权限。你的主机可能会通知你,你的服务器上需要设置什么权限。

chmod命令可以用来以两种方式设置权限:用字母或者用数字来设置权限。如果你使用字母,你可以输入

chmod o+w 文件名

这赋予每个人使用系统的特权。第一个字母可以使u(用户),g(小组)或者o(其它的),或者一个组合;the + (grant) 也可以是 be - (withhold), 第三个字母也可以是 r 或者 x (阅读或者执行)。

如果你使用数字,文件的所有权限都可以一次设置好。如:

chmod 755 wp-images

设置了wp-images目录的权限为755,然后第一个数字("百位数")是为用户设置的,第二位数("十位数")是为小组设置的,第三位数("个位数")是为其他所有的人设置的。

更多关于数字权限设置的内容:在任何区域中添加4,赋予了阅读权限;添加2赋予了编写的权限,而添加1赋予了执行的权限;每个组合都有一个独特的数字。上述例子中的目录,将权限设置为755,对于网络上可以使用的目录,这个权限非常常见,用户拥有所有的特权,而其他人只有阅读和执行的权限;上述例子中的文件的权限设置为644,用户可以阅读和编写文件,而其他人只能够阅读文件。

   6  4  4
  420400400
 -rw-r--r--  1 domain60 vweb  840  Feb 21 06:38 wp-config-sample.php

   7  5  5
  421401401
 drwxr-xr-x  2 domain60 vweb  4096 Jun 29 18:46 wp-includes

wget[ ]

如果你在wget命令后,加上一个网络地址(URI),这个命令就会下载一个文件。要下载最新发行的WordPress版本,请输入

wget http://wordpress.org/latest.tar.gz

从Shell中升级WordPress[ ]

让我们来使用,用命令行升级WordPress的例子。首先,在你的网络服务器的文件系统上确立你的WordPress的位置。这个例子中假如WordPress位于~/public_html/blog

  1. 为你的shell帐户的主页目录下载当前的WordPress版本并且将这个版本解压:
    wget http://wordpress.org/latest.tar.gz
    tar -zxvf latest.tar.gz
    WordPress存档文件会被解压到一个新的目录,目录名为/wordpress.
  2. 用下面的命令输入新的目录:
    cd wordpress
  3. 移除 wp-config-sample.php:
    rm wp-config-sample.php
    (取而代之,我们会看到当前的wp-config.php)
  4. 将整个/wp-content 目录,从新的目录中移除 (我们会用WordPress博客中的目录来代替这个目录):
    rm -rf wp-content
  5. 将博客的wp-config.php.htaccess 文件复制到新的目录中:
    cp ~/public_html/blog/wp-config.php .
    
    cp ~/public_html/blog/.htaccess .
    注意: 不要忘了两个命令后面的点号!
  6. wp-content目录复制到新的目录(包含了我们所有的主题和插件):
    cp -rf ~/public_html/blog/wp-content/ .
    再一次地注意,命令结尾的点号。
  7. 移除你的WordPress博客目录中的所有内容:
    rm -rf ~/public_html/blog/*
  8. 最后,将新目录的所有内容复制到你的主要博客目录中:
    cp -rf * ~/public_html/blog

SFTP Shell 命令[ ]

SFTP代表安全文件传输协议,是加密的FTP形式,如FTP,你可以使用在这篇文章的顶端所提到的一个shell为基础的client或者一个图形client。如果你的主机支持SSH,主机就同样支持SFTP。

与Shell一样的命令[ ]

Shell类型支持的命令,类似于用在bash中的命令。这些包括 cd, ls, mkdir, rmrmdir。也支持 ln, 不同的是,你不需要使用-s 选项来创建symlinks; 在sftp中, ln 命令使得symlinks 是默认的。所有这些命令对于你的主机系统上的文件都起作用。

put and mput[ ]

这两个命令转移到你的主机(例如上传)一个单独的文件(put)或者任何与你支持的模式相匹配的文件(mput);以上所描述的通配符*?可以用在这儿。

get and mget[ ]

这两个命令从你的主机转移到你的本地电脑上(例如下载)一个单一的文件(get)或者任何匹配支持的模式的文件(mget)。与mput一样,可以使用*?

cd, mkdir, ls[ ]

这些命令与命令的bash shell命令是相同的:更改当前的目录,创建一个新的目录,列出当前目录的内容。在你自己的电脑的SFTP内部执行同样的操作,在命令的前面添加一个llcd, lmkdir, lls

深入阅读[ ]

chmod 指南 什么 chmod?在线文件权限计算器

也看看[ ]

更改文件权限

子目录的htaccess