 I guess. So who here is a developer? All right, good. We don't have anybody that's going to be totally lost while we go through them. Anybody here use command line already? Do you feel competent with it? Or are you just kind of like, I copy and paste what the instructions tell me? Anybody? All right, well, it's OK. I do the same thing, and I like to pretend I know this stuff. So we all do. The important key is to try to read it before you hit Enter. Make sure you understand it. Otherwise, it's a bit of a crapshoot. So if you haven't already, you can get the whole slides on. I've got them up on SlideShare. Probably be the easiest way to reference this as you go, because it's a lot of cheat sheets basically for, hey, I know there was a command that did this thing. How do I do it? But honestly, best cheat sheet in the world, Google. Seriously, just Google it. You'll find the manual or the help guide, or honestly, almost every time I Google what switch or what command does x, y, or z, it's the first article almost always has exactly what I need. But for those of you who are new to the command line, you might be wondering, why would I even want to use the command line? Well, as Dwayne McDaniel says from Pantheon, let the robots do the work for you. Really, if you're doing a bunch of repeatable tasks that could just be a quick script, then just write a quick script. Now, I do have a caveat there. I will be doing a freelancer talk tomorrow, so I'll talk a lot about stuff just like this. But if you are doing something that you might not have to do more than once, really, really consider doing it manually before taking the time to write a script to do it for you, unless you have the education time to burn. I just recently spent probably two hours writing a script to pull all the WordCamp Birmingham details out of the schedule and put them in an app on building when, honestly, if I had sat down and done it, it would have taken me less than an hour to do. I was working on this talk. I really wanted to do something cool, so I wasted more time than I should have. So good rule of thumb when learning to write scripts. If you're only doing it once, it might be better to just do it manually for this time around. But if you have time to learn, if you're doing it a lot, absolutely do it. Another big key point, browsers time out. I don't know how many of y'all have been doing a backup and you get, even if you're doing, using a great plugin like MigrateDB Pro and all of a sudden you just get a 500 error in the middle of it running. It's because browsers time out, servers time out for lots of reasons. Command line very, very rarely does. And it only does is if probably if you're doing something wrong. So best thing in the world, you've got to do a big migration. You have to fix a bunch of broken images, things like that, something that is really going to kill your computer. Just use the command line, it won't time out. Command line is great for mashing commands together. If I have something that I'm starting with over here and I need to change a lot of it before it gets over here, I can just start putting command after command together and mash them together with a pipe mark character and it'll just send data from one side to the other and manipulate it the entire way through. Which is really great if you need to consume something and then have your scripts do something else. I mean, and this last slide says this, but if you didn't know, bash is a full programming language. If you can do it in PHP, if you can do it in JavaScript, there is a bash equivalency. It's an amazing thing when you finally get to know it. Especially the more and more you get into WordPress, WPCLI, it becomes very handy to know how to iterate over arrays or loops or have conditional statements because you are gonna be writing some scripts. So you might as well have the ability to make them as seamless as possible. Let's not assume all the data is where you expect it to be. Let's check for it first. So with that said, how do you get started? Well, if you're running a Mac, it's really easy. You just go right into applications, utilities, click terminal, it's a little black icon with a white cursor on it and you're done. You're up and going. You have everything you need to do at least the first two thirds of the slides in here. If you get to the point where you need to install PHP or you need to start messing with your WordPress site when we get to WPCLI, you might be set up properly on your Mac. Do that, you might not be. If you're on Windows, go to git-scm.com, download Git for Windows. It makes this whole process very easy. Everything I'm about to do here up until WPCLI is going to be in Git-scm. You can now, if you're a Windows user, go and install the Linux subsystem on Windows, which turns your Windows command line right into a Linux box, basically, minus some background server stuff. But that takes a lot of restarts and you gotta go follow the guide. I do have a link to it, so if you go pull the slides up at home, you can follow Microsoft's guide to do that. It's really cool. I mean, it's nice to have, but git-scm takes two minutes to install and you're done. So, anatomy of a command. You have a command on the left side, you have your options, also known as switches, and then you have your parameters. It's very much like PHP in a way, just the syntax is switched around a little bit. Once you know what a function, a parameter, and an option is, then it's really not that hard to bring that over to bash. And then on the right side, we have some basic how do you get around type of things and I am going to switch over and see if I can make my screen work because that's always the catch, isn't it? Display settings. Duplicate. Maybe, maybe. Yay, you guys can see what I see. Okay, so I've just loaded up. Actually, I lied, I didn't load up here. You're gonna see a little navigating to start with. A little cheat sheet. If you ever need a clear console, type clear. It's awesome. So when I open Git SEM, it opens to this folder for me. I manually set it to always open to this folder. If you wanna know how, send me a tweet if you can't Google it. I'm not gonna cover it right now, but I always open up in my vagrant local folder. I wanna know what, and as you can see up here, you have the folder path right there. The little till day, that means home. Home is your, if you're on Windows, it's your username directory. If you're on Mac, it's your home directory. It's funny how that works. And then you have the rest of your path. If you don't happen to have that, some command lines don't include the path on top of it. You can type PWD, present working directory. Tells you where you're at. Super handy. You need to know what's in that folder. LS, it lists everything that's in it. You wanna know everything, including all the extra files like the Git file and stuff like that, you add an option. A parameter in front of something is an option. If you wanna spell out your option instead of using a shortcut, you can do two hyphens and type LS all. And now you see, I have GitHub there, I have Vagrant, I have all these dots that wouldn't show up under normal circumstances. Really, really handy one, LS, LTR. Let's order everything by the most recent as the first item there. I can't walk you through what L, T, and R stand for. I forgot it over the years. But it is the most handy LS command you'll ever need. And then there's just some basics of CD, change directory. I need to go, oh, pro tip, press tab. Tab will autocomplete for you. You can see what's in the next, in that directory. So I type CD, I've hit tab, it shows me what's in there. I need to go to www. I hit tab, it autocompletes it. I wanna go to my directory. I hit tab again, it auto deletes it. And I have now changed directory. Oh wait, I need to go back. CD, one dash, and I've gone back to my vagrant local. That's one that I've been doing command line for many, many years. That dash is awesome. And I didn't even know it existed until about three, four months ago. So yeah, makes my life way easier. I'm back in my markratch folder. And then to drill down deeper, you can always just, it's as easy as just typing in the next folder to go back up to a parent folder. You type dot dot slash. And now I'm in my www directory. And we'll go back into that directory though, because I need to be there. If you need to reference your current directory, which happens quite often, or you wanna launch a script or a file that's inside that directory, you must push type period slash, and then whatever the sh file is. Or as you can see, I can grab folders from there also. So kinda handy to know. I've spent far too much time looking for how to execute an sh file to just realize that all I needed to do was type that dot first. And that would have been it. That solves the problem. So I'm pretty sure that covers a majority of getting around current directory, parent directory, last directory, home directory, which I didn't show you, but I did explain cd till day. We're there, cd dash. I'm back in my directory. It's fun when it works properly. So with that said, let's move on to the next one. File manipulation. This is pretty handy. I'm not gonna go into permissions, by the way. If you run into a permissions error, look it up. I mean, honestly, permissions get really convoluted and complicated from one system to the next. The best thing you can do is look it up at the time. When you find yourself dealing with them on a regular basis, you'll become a master of chmod and chown, but you don't need to do that at this point in time. So I'm gonna actually back out of that so I can get to my notes, because that made it really easy to have access to all my different files. So we're gonna start by creating a file. I know I could actually type this stuff, but what's the fun in that when I could copy and paste it? Okay, so we're gonna create a file. Touchfile.txt. It's really easy, ls. Now we see test.txt. Test.txt there. If we want to write into the file, we can type echo just like in PHP. Hello, and then a carrot pointing to the file, which I find that's how I remember it, is that it's pointing like this content that I'm grabbing here is pointing to that file. So I'm gonna put it in that file. This is also a really easy way to make a file. You don't have to touch file.txt. You can just literally echo whatever you want into a file and it'll do it. So now to read a file, we type cat. catfile.txt, you see it says hello. Now if we want to append something more to the file, we can type whatever we want there. We'll put world. Let's make sure there's a space just in case. And instead of one carrot, we do two carrots. Now cat file name, hello world. Apparently I didn't need the space because it was gonna put it on its own line anyways. I knew that, but yet I forgot. So let's see what else we got in here. Catfile, echo, hello world. Oh, here we go. That's all my commands just in case PowerPoint died. So we have a big file in here. When I hit cat for test.file.txt, as you see that was just a lot. And I want to be able to find information in that or I wanna read it. God forbid I wanna read something that's on my computer inside the command line. Kind of a neat thing. By the way, you can read websites using command line. It's basically a combination between cat and curl, which we'll cover in a little bit. Kind of handy if you wanna just get rid of ads and images and stuff like that. And you literally know you need to read this information right now. But generally speaking, why? Cat, test, text, less. And look at that, I've got pages now. So now I can go through and I can read page by page. It's pretty neat. And take it a step further. I wanna know how many words are in there also. So we're gonna type WC, word count. So, which gives you a lot more than words. There's 300 words, 9,000 eight, or excuse me, 300 lines, not 1,825 words and 66,499 characters. Kind of a neat thing to have access to. So, generally speaking, that's how you read and write files. Removing a file is quite easy, RM, which file are we working with? File.txt, actually before we remove it. Let's copy it, cp is copy. We're gonna copy file into, I'm all over the place. We're gonna make a directory. We're gonna name that directory directory because I'm clever. And now, so to make a directory, mkdir, we're gonna copy the file in there and then we're going to try to remove that directory. Remove dir directory. And it tells us we can't because there's a file in it. Yeah, that's normal. So, the safe thing to do is move that file out if we don't wanna delete it. It's clever, right? So we're gonna go into directory and file and put it right here. Okay, look, that's where I get to use the single dot. All right, so I've moved it out and now I can remove the directory. I don't need to do that. And it's removed safely. But if I need to remove it with the files, everything inside it recursively, we can do that too. This is super dangerous. This is, if you've seen on Twitter, hey, if you need to fix everything, just type rm-rf slash. Yeah, that's how you recursively force delete your entire root of your site. Don't do it, it's bad. It probably should make you type sudo first, but not if you're logged in as root, by the way, key point. Don't log in as root. So we've created our directory. We're moving our test file back in. Was it test? It was file, wasn't it? I don't wanna delete my beautiful lorem ipsum file text. We'll move it to directory. And for all of you who don't know how to destroy your system, rm-rf directory. And the folder is gone. That is the most unsafe thing you could probably do, but it's also the most obvious thing to do in most cases. I can't tell you when I've used rm-dir. I mean, it just doesn't happen. But then again, I can tell you that I have literally changed the permissions on an entire system at the root level for basically the same reason. So be careful, don't use root. Use sudo sparingly. We'll cover sudo in a minute if you don't know what it is. So that is getting around in command line. I hope that's still generally readable, but then again, that's why I posted these online. Oh, did I just, I literally just broke my slideshow. That's awesome. There we go. All right, so we've got file directory. We've done there. I talk about remove rf. Let's move on to the next one. Useful commands and pipes. So you saw me using the pipe already to do stuff like read that particularly long file. It's pretty helpful in that case. Pipe just takes everything from cat.test.txt and it moves it over to less. After less is done with it and moves it over to word count. That's what a pipe does. It makes, it takes the output. So whatever input you put in on the first function, it moves to the next function. That is called standard stand-in STDIN. You'll see this places when you're reading documentation, they'll go, what the heck does that mean? Well, that means anything that's moving from one function piped into another is STDIN. And I wrote this wrong. So let me fix my slides that are now online for everyone to see. That'll be an update for later. So stand out is everything that comes out of a command moving into the next pipe or to the output of your screen. So everything coming into a command, stand in. Everything coming out, stand out. It's very logical, but if you don't know what these things are and you see it for the first time, it can kind of get a little, it could throw you off pretty quickly. So we've got some other useful functions, fine, grep, tail, xargs, which I like to call zargs. I have no reason why. Unique sort. Unique sort is there already piped by itself and I'm gonna explain this before we get to any of the other ones. Unique by itself is not very functional. It only looks at the current line and the next line. So if you have multiple unique or multiple repeated lines, but they're separated by more than one line, it is not gonna remove those. So that's why you use unique pipe sort and it will sort everything and then remove all the duplicates. Makes it much more functional, kind of handy. So I have a fun little example here. If you can see this, find SQL. Let's start by clearing this off also. Oh, another hot tip. You wanna scroll back and forth in your commands that you've written already, up and down arrows. That's it. I wanna see my last commands. I pressed up a few times and there they are. I wanna actually search it, control R. I think it's command R for you Mac users and I can now search. I can do a reverse search of my history of what I used last. So if I wanna see when I last used grep, I actually use grep. Let's go ahead and use this example now. Grep is great for searching strings within other content, within strings. So I had my test.txt file. It was just full of Latin. I mean, it came from Lauren Bipsum. So I wanna find just the word none. I type grep none text.txtxt and it gives me the output of the line with the word none in it. That's a heck of a lot easier than trying to, you know, do it through just cat. I don't know. I'd have to scroll through that for a while and read every word to figure out where the word none was. So grep is very handy in that case. So the next one I'm gonna do is I was gonna search for SQL but it did not like that. Find the name of a file. I bet I need a dash there. There we go. So I just did a quick find of all SQL files inside of my Mark Gratch directory. Pretty handy in case I wanna figure out where all my backups are or see how much space I'm wasting by backing something up like 12 times in five minutes. I don't know if you guys do that but I have backups of backups of backups inside of my backup. So it's like a crazy five level layer deep backup inception. It's kinda crazy. So we have quick use of find. I showed grep just now. Tail, tail is super handy. Does anybody here make sure that debug log is on while they're working on a site for WordPress especially? Isn't it the most obnoxious thing to open that file up and try to figure out what error is going on? And I know you could set up Pimp My Log, you could set up System Event Viewer. There's lots of ways to manage logging based on an existing file. But again, I'm using the command line all the time. I'll probably have 12 of these windows open sometimes. It's not healthy but it is what it is. And I wanna have one of those windows constantly telling me what's happening in my error log on the local machine I'm working at. So enter tail. Tail pulls the last few lines. I don't remember by default how many but the last few lines of any file. So when you add the option dash F which I technically wrote, that's the other thing. Bash, very forgiving on your order of operations. Not for math but for like basic commands. Technically it should say tail dash F and then the file I wanna tail. I had it the other way around. But I tail my debug.log file and now as I create new errors or warnings or notices this page will continue to grow. I don't have to refresh, I don't have to pull up any new information. It's just constantly going to be telling me what's happening in that file. You can also type head dash F but I'm not quite sure what you, maybe like if you wanted to see, if you had some document that's constantly putting at the top of your document the most recent tweet or something like that then maybe it'd be worth doing head dash F and you could see the 10 most recent tweets or something if you're not appending it, if you're prepending it on a file. But that's not really a normal use case. So I didn't really cover ahead here for that reason. Let's see, we've got fine grep tail. Ooh, Xargs, that is a fun one with a lot of piping. So I've got this fun little command that I'm just gonna paste right in. It is going to, it's not an efficient command, I know this already. But it's going to search for, here, put that in. We've got find down here at the bottom, we're gonna find all files. We're going to search within all of the results of those files for, I get to use a little regex here with grep. If you need to use a lot of regex, use egrep, just so you know. Little regex, I'm looking for just files ending with .sql. I'm sorting it to only get the unique ones. And then I'm using Xargs because sometimes a pipe won't work. Pipes pass your data, the stand in as the main parameter on a command. What if you need that to be a argument? You need, you cannot, like the main parameter is copy whatever this file name is, but I need to know the name of that file for the later arguments. Enter Xargs. So I, with Xargs, I have, I'm taking the, what's happening after we're sorting all of my file names. I'm using I to be a stand in instead of needing to know the name of the file, it's now just gonna use the word file. And I'm gonna copy file and I'm gonna move it to my test backup folder. And that will take about a minute, probably. It didn't take that long. So now I can ls my backup folder test backup folder, because my real backup folder has actual useful stuff in it. And you will see all my SQL files there. So by the way, all of the code examples that I've given here are also available on my GitHub account, which I have linked to at the end of this. So in case you see a useful function that I've done here, you can get back to it. So we've covered pipes, we've covered most of the very important stuff. Let's move on to a little bit beyond the basics, which is installing packages, the dreaded sudo. Really, sudo means super user do. Oh, I see sudo. By the way, it's sudo, according to most people who know what they're doing. I just grew up reading it and didn't hear anyone say it and I didn't know what it meant at first. So I've always said it wrong, my entire adult life. But sudo means super user do whatever, do this thing. Or some say it's super user do once. So I guess technically debatable on whether I'm saying it wrong. But super user is the root. It's the, you can do anything, generally speaking, as long as you have the right login credentials for that super user, you can do anything on your server, which can be exceedingly dangerous. So use sudo very sparingly. If you are running on a Mac and you wanna install a whole bunch of packages on your Linux installation, or actually not on Linux, excuse me, on your Mac installation in general, go check out Brew. It seems like the de facto way for most Mac developers on a Mac to get any new packages to their machine. As a Windows user, I don't get Brew. They don't make it for Windows. So I'm stuck using my Linux container, or in this case, Vagrant, and I use app to get. And because I'm logging in not as the super user, in order to install new packages on the entire system, I do need to use sudo. And it's pretty common for most people to need to use sudo to run app to get. We will install a couple of packages in a minute, and I'll explain a little more from there. But so for this, I am switching over to Vagrant because I don't have PHP running on my computer. I have it running on a container. So when I type Vagrant up, it loads into this. So I'm gonna go ahead and find my website here. And there we go. I use a lot of tabs. Okay, so now I'm in the same folder. And we are going to, I'm gonna demonstrate, app, get, install, get. Well, I can't, prohibitions are denied. So I will do what I said and type sudo in front of it. I already had get installed, so it's installed now, but that would have been the whole process. Everybody who does, I cannot say the last time I worked on a site that didn't require NPM of some sort. If you do pre or post processing, or you hear people talking about using grunt and gulp and webpack or building react or good and blocks and all these things, you need to use a task manager or task runner, which means you need grunt, gulp, one of them, so you need to install NPM. NPM, fun fact, doesn't actually stand for node package manager. If you go read it on the site, it means nothing. It's a weird thing to know. To install NPM, you don't type app to get install NPM. That'd be logical, and we live in a world that is not. So we type sudo app to get no JS. And it didn't like it because I didn't type install in front of it. Sorry about that. No JS is now installed. And finally, I don't have a demonstration for this because it took a lot of jumping through hoops, but you can install some pretty fun things. You're not allowed to see it anymore. It's a secret. Let's see if it works. Or if the computer's just out to get us today. That is less than promising. Yay, okay, so I didn't walk you through the install this, but there's a great command. You need to brighten that up your day. Pony say. Have a My Little Pony on your command line. This is a fun one also, sudo apt get. Most systems have fortune installed. It gives you a fortune. I forget that install all the time. I embedded this. All right, so most of them have fortune installed. My computer did not. So now I can do fortune, and I'm gonna pipe it over to pony say. My three-year-old loves this. I can just randomly pull up different ponies, giving you different fortune cookie fortunes, which I do not recommend using their built-in quotes. Some of them are not kid-appropriate. They're not bad. They're just not things you wanna read to a three-year-old. So that brightens up your command line a little bit. It makes it fun. You can go, there are tons of guides to going through and setting up ZShell and Omai ZShell and all these great names, FishShell and all these things. I run a PC. My availability of these things is like this much. And not to mention, I have a real code to write, so spending time making it look really pretty is not usually on the high end of my priority list. But then again, neither is pony say, but it was awesome, so I had to do it. So one of the things that I'm going to demo real quick is NPM. NPM is, you're gonna use it everywhere you go. To install stuff with NPM, it's just like installing with apt-get. You should, NPM says actually very explicitly, do not use sudo. The reason for this, which is kind of the reason that you shouldn't be using for apt-get, when you use apt-get and you don't make any changes to your system, it is downloading from a trusted repository of all the packages for that Linux installation. If you modify what repository is to look at, you should definitely not use sudo because anybody could put code in that repository and now you've just sudo, allowed something to maliciously take over your machine or start destroying stuff, scrape data, whatever it is. So if you don't know the source, really it might take a lot of time to figure out how, but figure out why you're required to write sudo and fix it. I do type sudo for NPM on this, specifically because this is my dev machine. I don't care. In the end, I'm going to export all my files into a non, without any of these source files. It's not gonna have NPM libraries in it and things like that. So it doesn't matter if I use sudo or not. If you're working on a staging site, on a site that is anything but on your computer and even when you're working on a computer, if you don't have this problem starting out, great. Don't try to do everything you can to avoid finding yourself in it. But you should be able to type sudo NPM install and a really useful tool that I've come to love is JSON, lower case. There's an uppercase one, I don't know what it does. NPM is a community package site. Anybody can put a package on there. This is why you'd be very careful when you type sudo for something. I use JSON all the time. It allows me to extrapolate large blocks of JSON and turn it into easy to read data. I love it. So NPM install JSON, we're gonna add a double dash so you can see what I'm actually typing. I'm gonna tell it to install it globally. So that way I can use it everywhere. As you notice, I get a ton of errors. That's because my NPM is not set up right. I think this is probably a problem with everybody who uses VVV, but I don't know, I've never actually tested this. But anyways, I trust what I'm doing here so I'm gonna go ahead and type sudo and it installs JSON, which is really a super handy little function. The only one on here that I have not demonstrated is curl and PV, and I don't know if I'll get to those necessarily, but let's see in a second. Oh, just to show you. I'm not lying, I swear Git was installed. I can just type git. NPM JSON, wait, I can't type that. And you saw me type pony say, definitely useful. So we installed something with node. Okay, so let's make this fun. We are going to use curl, by the way, curl and WGIT. They are not the same command, but they're mostly the same command. I don't remember which one. I think it's WGIT is a command line. It's an actual command, whereas curl is a library. So the chances are if you don't have curl, you have WGIT available to you. They do slightly different things, but you can generally force either one of them to do what you want it to do if you take the time to study the different brain network. If you take the time to study the different options that are available for it. So I'm about to show you curl. I am pulling it from this word camp. That's the JSON that comes when I hit this session endpoint for using the REST API. That is not readable. So I'm going to put a pipe in it because pipe is awesome and type JSON. Now it's readable, even better. And I act as if I know this, but I actually have to look it up every time. So we've got JSON again, and we're going to press space and we're going to type title.rendered because that's a key in there. And then right underneath you see the name of the talk using the command line bash and WPCLI. I can't tell you how great that NPM JSON is. If you work with API endpoints at all, that will be your best friend. It makes my life so much easier. So that is a little beyond the basics. So the next step, what probably a lot of people came in here for, WPCLI. Look, I'm clever, I wrote my own command. Make life easier. Does it negate it if I just called it out? All right, so WPCLI, it is awesome. I use it all the time. I don't have a list of the maintainers here. There's like four major maintainers. We had our first WPCLI contribution day last Friday, maybe two Fridays ago. Unfortunately, I was unable to attend that, but it's great. It's a community. One, it was adopted by Automatic. Therefore, it is officially part of the WordPress project. Or I don't know if, actually let me take that back. I don't know if Automatic had anything to do with it, or if the WordPress foundation did it. It's such a blurry line. Either way, when you go to WPCLI.org and you click any of the links, there is no question that you are on an official WordPress site. The homepage looks a little different. They kept the homepage for austerity reasons, but the austerity, wrong word. They, man, I'm good today. They kept the homepage just for the purpose of keeping the homepage. I'm not gonna attempt to use a vocabulary now. Words hard, but generally speaking, and you now know if you're using this tool on a regular basis, it's not going away. It is an official part of the project. So what do you need to use WPCLI? Bash, sorry, if you're on Windows, go download it, set up your Linux subsystem. You need PHP 5.3.29. It will not work on anything less. And if you wanna work anywhere, but on your local machine, you will need SSH access. The install instructions are on the bottom. It's a little hard to read probably, but I wanted to make sure that it was clear without having a bunch of line breaks in it, but you literally go to the root of your site, to your home directory, you enter in that curl, the whole URL, it downloads a FAR file. FAR, P-H-A-R, I don't know what it stands for, but it's like a package PHP executable. So once you've downloaded it, CHmod, a dreaded permissions command that I am not about to explain, you run CHmod on it, so that way it's now your file and not this random file you downloaded from the internet. And then you use sudo and you move it to your command line, or you can do an alias, but aliases are a little less reliable than actually moving it into your user bin. And then when you're done with that, you can type. Let's close that one, I don't need it anymore. WP, and you get a list of commands, and a big list of commands. I think when I counted 43 of them total, and that does not include sub-commands, there are, every command has probably at least three or four sub-commands to them. So you can do a lot of amazing stuff that you do with WordPress in the dashboard, right from the command line, which is incredibly easy. I mean, it takes so much of the workout. I put the syntax, require the anatomy of a CLI command at the top. It starts with WP, then the command, then whatever sub-command you choose, and then the options. And here is the control click. See if Chrome opens, or if everything just falls apart on me. Because I wanna show you the command page, because I think it's awesome. I live on this tab, like seriously, at any time I'll have three or four windows open, probably all with a dozen tabs at least, some of them up to 60. This is always on at least one of them, probably much more. If there's a command that you see, if you go and start browsing it, and you're like, hey, what does this do? Feel free to raise your hand and ask. We're about out of time, so I'm trying to get through the last couple of examples. But I mean, one of the great things about this, so let's say capabilities is something enrolls. You can go and change capabilities of roles, create them, delete them, do all sorts of crazy stuff with them without touching the dashboard, without changing, writing a file, anything in your functions.php, or anything like that. You can just use CLI to do that. You can use CLI to do so many things. It is, I mean, I'm at a loss. That's why I actually made notes of them. Here's some really helpful ones. I'm gonna make this big for a minute so you can actually see it. But I mean, it goes for basic debugging. First thing everybody tells you to do when you're having a problem with your website, deactivate all the plugins and start activating them one at a time. Well, what if you can't get to your dashboard? Good luck, or good news. With WPCLI, you don't need your dashboard. If you're running WPCLugin, deactivate dash dash all and it's still not working, it's probably telling you where the error is happening. You know, cannot find blah, blah, blah, index is wrong at this line and when you see at that line, you can look at it and see what folder it's in and it'll tell you exactly which theme or which plugin is causing the problem. And then you type deactivate all again, dash dash, skip plugin and then name the plugin. Lo and behold, all of your other plugins deactivate. You can do whatever you need to from that. A 500 error, a white screen of death will not stop your development and actually WPCLI will allow you to look like a magician. You're just gonna go, oh, white screen of death, no big deal, let me log right in with SSH and take a look. Bam, done. You can regenerate all the thumbnails. See, you just change themes and it has a whole new set of image sizes you need. You type regenerate thumbnail and you go have a cup of coffee because if you have a lot of images, it's gonna take a long time. But you don't have to download a plugin to do that and almost every plugin I ever downloaded back in the day when I found myself in the regular problem with this would time out if I had a big media library. This doesn't time out. Update themes, update plugins, update core, clear your object cache. Man, that's so great to have. I don't know if you know this, but if you're running on local by flywheel, it has a great little checkbox in the top right corner to turn off dev mode. A lot of them don't do that, which means you're stuck with whatever cache is already implemented in that local machine or on that live server or that staging site. So clear the cache using the command line. It's so useful. Delete all the transients, especially for local development. That is an amazingly useful tool to have available to you. So again, these are all available on these slides. It's all online. You can go to my gist.github.com slash mark gratch to see more examples or real quick. I am going to show a few of them before you're completely run out of time. So let me start by showing off. This is kind of neat. I didn't wanna store this whole function anywhere where I like in my notes. So I put them all up on GitHub and then I just use curl to call the raw version of it. So now I have the entire function right here. So let's see if I can destroy my site and bring it back up in five minutes. So this function is going to use WPCLI. I'm gonna back up my site. I'm going to drop my database. I'm going to move all my files into a backup folder. I am then gonna install a new core. I am going to create my database. I am going to install core or create my WP config file install core. I'm gonna use curl to go to lorem ipsum.com.net and pull five paragraphs and add it to every one of my five generated posts. I'm gonna use XRs to then take that data and move it to the post ID and move it over to add meta so that I can then add a featured image to every single post, which is going to be using, oh wait, thumbnail ID. Where is my thumbnail ID coming from? Uh-oh, I broke this. Sorry guys. Well, you know what? Let's just run it and see how badly I break everything. It does not like it. Darn. I don't think that worked well. Oh, that's why it didn't work well. I'm trying to install in a non-word press folder. Okay, so let's try that again and this time I'm just gonna be really lazy and copy it all from here. These are, I have again, all these functions are listed on my GitHub account. This is the one we're doing right now. We're gonna back up and we're going to create, we're gonna back up the live site and then create a new site with 25 random posts on it. We'll see how long it takes. This might not work out so well. So while that's going, let me walk you through a couple of other quick functions. We'll use this here. We've got, when this is all said and done, I can then just run these set of functions and that will reset everything we just did or that we're currently doing back to the original markgratch.com. I mentioned the PV command in one of the earlier slides. PV is equivalent to a database import. Only it gives you a status bar, which is awesome. I've had to import a six, seven gig database before and you just type import and walk away because you have no idea if it's working. If you use PV, you get to see it working. It's a nice handy little trick. And then we've got get random images. I use a for loop here so everybody can see how cool for loop is. From here, I then update all 25 posts with brand new images, insert a database that's split into multiple parts, another for loop, delete all posts. And then this last one is a giant block but this is a real use case that I had it. We had a live site, enterprise level, giant company, all of their data was broken for their excerpts. For some reason, the previous developers had created an intro meta and decided not to use excerpt. I don't know why. So what we needed to do while we're currently working on locally and this is all still happening live and we can't break things in two places. I wrote the script. It pulls using WPCLI and bash. It creates a backup folder. It pulls all of the, here, I'll walk through it real quick actually. I removed the XML file in case there is one so we start fresh. I export everything from live using SSH here to run this particular WPCLI command on the live server. And I pull down all the XML data into standout which I then pass into the file, the XML file. I delete all the posts on the local site. I install the WordPress importer plugin. I import the live data. I then loop through it all and I fix all of the meta data that needed to be fixed and then I clean up the XML file when it's all sent and done. One of the smartest people I think in our community told me that was a handy little script. I was very proud of myself. So this is done. So I'm gonna now show you that what it should look like and what it does look like and we will call it quits from there. And if you have questions, find me afterwards. So this is my website. This is the test website that I just broke. Well, I didn't break it. I just put on, oh, it didn't work. Well, sorry guys. Anyways, so that's my talk on WPCLI and Bash. If you have questions, find me afterwards. I'm happy to help. Thank you so much, y'all.