WP-CLI is a command line interface which allows the users to manage their WordPress web sites from the command prompt. Upgrades can be performed, backups can be generated, new posts can be published and most of the regular admin actions can be performed with a set of commands.

This tutorial explains how to use the WP command line interface in order to complete regular administrative tasks like upgrades, database backup creation, plugins and themes installations and removals, publishing and deleting posts, changing site's URL settings and getting help on chosen commands. Note that WP-CLI requires a SSH access.

List the Available WP-CLI Commands

To list all the commands write "wp help" or just "wp". The following list will be shown:

1

2

3

4

5

6

7

8

9

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

35

36

37

38

39

40

41

42

akismet Filter spam comments.

cache Manage the object cache.

cap Manage user capabilities.

checksum Verify WordPress core checksums.

cli Review current WP-CLI info, check for updates, or see defined aliases.

Update WordPress Plugins using WP-CLI

If you would like to upgrade any additional plugins or themes on your WordPress website, you could do that with WP-CLI. To check for example the status of the currently installed plugins, use this command:

1

2

3

4

5

6

7

8

9

10

username@servername[~/WordPress/location]# wp plugin list

+----------------+----------+-----------+---------+

|name|status|update|version|

+----------------+----------+-----------+---------+

|akismet|active|available|3.3.2|

|google-captcha|active|none|1.31|

|hello|inactive|none|1.6|

|jetpack|active|none|5.3|

|sg-cachepress|active|none|3.3.2|

+----------------+----------+-----------+---------+

We have 5 plugins integrated in our sample installation. There is an upgrade for one of them. To perform an upgrade for that plugin, the following command can be used: