Languages: English • 中文(简体) • (Add your language)
If you have recently moved to 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 PHP; many hosting services use servers running Linux and Apache; many web hosts offer not only web-based control interfaces to their customers but also shell access or command-line interfaces. Many WordPress users may not be familiar with using the 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.
wp-cli is "a command line interface for WordPress". It's a great tool that can save you a lot of time if you know more about using shells.
The shell offered by your web host is likely to be bash, which stands for "Bourne Again Shell" after Stephen Bourne who wrote the original modern Unix shell. bash is distributed by the Free Software Foundation. There are a number of different Unix shells. The commands briefly described below apply to almost all of them.
The Secure Shell (ssh) is a complete set of tools for remote administration of your website. It includes SFTP (Secure File Transfer Protocol) for the uploading of files to your host. The main benefit of using 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.
To use ssh under Windows, use PuTTY or Cygwin, a UNIX-like environment for Windows. The FileZilla ftp client also supports sftp via ssh-2.
To use ssh on a Mac running OS X, use the Terminal-based SSH program supplied with Mac OS X or download 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 KBear and gFTP also support 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 typessh username@hostor
sftp username@hostIf the SSH server you're connecting to is running on a non standard port, use the -p argument, followed by the port number. So, for example, if the remote server SSH was running on port 1000 you would type
ssh username@host -p 1000To use sftp to connect to a remote server on a non-standard port use the -oPort= argument. So, for example, to connect to a remote server using sftp on port 1000 you would type
sftp -oPort=1000 user@host
Before we get started with some UNIX commands, let's review some terminology.
"My Pictures"or as
My\ Pictures
The * and ? Symbols: The * and ? symbols are called wildcards and can be used in any command which deals with files. The * represents any number of characters. The ? represents just one. Note that Linux filenames are case-sensitive — the norm is lowercase. All commands are lowercase.
command -brfOther specifications, like file names, go after the options.
Here's a brief introduction to some useful UNIX shell commands.
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: