 All server from your normal username using secure shell a few admin things There are a number of servers running and normally servers keep a log of what happens. So let's look at a couple of logs Actually some basic things first clear just clears the screen so you can see it a bit nicer. How big is your hard disk? DF and In human-friendly output DF minus H H for human the hard disk The device VDA one is 20 gigabytes Your VPS was allocated 20 gigabytes. You're currently using 1.7 gigabytes So DF shows the the file system information minus H in human-friendly form How much RAM do you have? Free how much RAM or memory is free? I Think minus M to show it in it shows it in what? kilobytes Free minus M shows it in megabytes And it's a bit confusing how much RAM is free. It depends upon how much is in Someone else is using my Terminal who is it? Okay, they resize theirs I'll fix them Start a new one. Okay. We're back Thank you The way that we're sharing the screen is that anyone could do anything on that one terminal. All right, let's go back I'll log in again The main number is this one This is think of this is the amount of RAM you have free It's the amount free If we subtract any buffers and add in the case so 350 meg free the total memory was 490 meg 512 Megabytes okay, so we have about 500 meg in total. We have about 350 meg free So unused so we're not using much of the RAM at the moment What else can we see? logs Most logs are stored in the directory slash bar slash log CD slash bar slash log You can LS. There are many files. They're here Go into the Apache to sub directory Which is the log files for the website the web server? CD Apache to Ah permission denied. That's annoying All right, we should have set it up better pseudo See if this works. I'll do it again pseudo we need admin access to view the log pseudo less Apache to slash access log access dot log less just shows us the contents of the file and The file is called access log and it's in the Apache to directory and This it's hard to read. It's quite confusing, but it's one line for every time someone accessed our web server It won't show up very well on my screen on yours that we better and it shows information about who accessed your website Which IP address? Okay, the the person who accessed it the web browser the date and time The web page they requested and something about their browser so Over time as your logs build up if you have a website you can start to get statistics of who is accessing your website How often and and do some analysis to understand the patterns of usage? Not very useful because our website has only been accessed three or four times let me bring up my browser Sorry For example after the log file or a website has been used for a long time that the number of You can run some software that does analysis of the log file and give statistics. So here's an example from a website and it gets statistics like Maybe hard to read purely from the log file the number of unique visitors Number of visits the pages visited and so on so different statistics over a period of a month the totals over over time the amount of Data was downloaded how many gigabytes was downloaded from your web server the the daily statistics the Ali statistics and Where people came from so the visitors to your website? Where did they come from and? Normally that can be determined because an IP address is often associated with a country So you can work out when someone visited your website where did they come from sometimes? It doesn't work so well and a number of other statistics like we find When they search for your web when they got to your website via a search page like Google or Bing or others What query did they enter into that search website to get to your website? So some different queries or keywords that are shown here Which come from the referral entry in the log so that's basic analysis of the log gives you information of how that website is accessed Once you create your own website on your VPS, then you can set up the log analysis to get those statistics one more log pseudo less Off log when someone logs in To your system. They need to be authenticated and this log keeps track of who logs in via secure shell and other system other ways pseudo less AUTH log presenter Does it work? It shows many entries some are not so important for us, but if we log it This one. I know what I'm looking for here. This is a log entry saying that this server someone connected via SSH to my server and The they use the name Steve the password was accepted That is that Steve logged in and supplied an appropriate password and and they logged in from this source address Okay, so again from this I can detect who logged into my computer who logged into my server And keep track of what's happening. There are many other things here as well This one becomes important if you run your server for a long time, especially a web server This is where you'll start to see malicious people out on the internet Starting to make thousands of attempts to log in to your server. You'll start to see Literally thousands of entries saying log in attempt root failed Someone tried to log in as the root user and they didn't supply the correct password And there'll be many more attempts and they won't just try the root user. They'll try some common usernames log in as my sql attempt failed log in as Drupal or wordpress attempt failed and many different common usernames will be attempted by malicious people and In some cases they'll be successful and then they get logged into your machine and then they can get access to Things that they shouldn't have access to So once you run your server for for real and especially have a website You need maybe some further security mechanisms to support So to stop that from happening But we will not cover them today What else what else did we say we'd do? I uh, okay Clear let's go home cd goes home top Top shows you some statistics or some information about the processors running Doesn't come up so well on my screen. It's not wide enough Okay, but on yours you can make it bigger and you'll see on the far right the the processors or the commands running The amount of cpu they're using Uh, and you'll see some summary statistics at the top the amount of memory being used And and so on so you keep track of the status of the usage of your resources q to quit what else sudo ip trap Gives us some monitoring of the amount of traffic going in and out sudo ip trap Yours will has a bit better screen than mine uh sudo ip trap I'll log into a different server Bear with me for a moment. I think I have it Try again Why won't it work on mine? Okay, you get some welcome message anyone get that Yep Just quickly. Let's go to detailed interface statistics eth 0 or I think you all you may have eth 1 as well choose eth 0 And it shows you packets going in and out Why is it so slow? Yours you'll see numbers change Mine is not for some reason. There we go mine's set up to run slowly. This shows you Maybe the most the easiest things to see Incoming outgoing rates the amount of kilobits per second going into your vps and coming out of it Okay, so you can monitor the traffic And see it change in real time over time So when you run your server you need to keep track of the the usage of resources bandwidth cpu ram Hard disk X to exit X to exit And I'm going to stop there. I think Any questions? Well, no someone remind me of something else. Uh, I will not stop What about copy files from your computer your vps to your computer? Okay, let's create a file on my vps Currently, there's no files in my home directory. Let's create one uh echo Hello Into my file dot txt Doesn't matter what it is Okay, so I have a file on my vps in my home directory and I want to download it. I want to copy it to my local computer Different ways to do it. We'll do a simple way by the command line So open a terminal on your local computer So this is logged into your vps. Now we want to copy it to your local computer our exit here We can use secure copy scp It's a bit long, but we'll get there so from Your computer make sure you're not logging to your vps in this terminal scp secure copy And it's source destination the source is steve at my vps ip address colon Then the full path i've given slash home Slash steve steve is my username yours is different Slash my file name space Dot it's saying copy this file In this directory on this computer logged in as this user And to the destination dot means to here to my current directory Copy a file from our vps down to your computer see if it works It's a a long way to do it, but A basic approach Okay easy Secure copy is similar to copy cp But it's over a network connection and encrypted On ubuntu you can do it a little bit nicer Open up your file explorer on your computer Open your file explorer And from the menu You can connect to server So in your the the file explorer from the menu connect to server And then work out the options to fill in A specific the protocol Yes, sorry. I haven't shown it. Yes That's a warning don't know I'll come back to it, but I I've seen it many times that warning, but I don't think it's causing a problem When you connect to server it gives you a prompt to enter in some information server address What do we do? I think it's sftp The ip address of your vps Mine is this sftp secure file transfer To your ip and connect Then your username and password And connect I'll go back Port choose the default port. Uh, sorry, you've got an older version of the the client So in your interface you just enter the server ip address and the type Where it says public ftp you select type of select this Type secure shell ssh at the top So yours are slightly different sorry And now I have my file explorer that can explore files on My vps and you can copy and paste drag and drop whatever So much much nicer way to to explore things rather than the command line ssh Username and password The work Oh, you can copy good this one ssh And then your ip address your server And then you can do whatever you like drag and drop You can even I think edit the files And to copy and paste move files and so on So it integrates into the your local computer There are a few other things that About synchronizing files from your server down to another computer, which are very useful Async Scheduling tasks Maybe in the last five minutes. I want to finish Before five Scheduler tasks Log in to your vps Log in if you're not already I think that's the wrong password Sometimes we want to have a task that automatically runs like every one hour every day or every month do something So schedule some job to run So in in unix and linux based systems the software that does that is called cron chronological cron cd slash etc I think we may find one chron dot daily So cd slash etc slash chron dot daily in here are scripts which are run daily by the operating system These green things are just text files which Are bash scripts and if you were here last week we did very basic bash scripts which run commands Uh There's also a cron dot monthly a cron dot hourly directory And you can actually specify You can add your own thing scripts in here If you want a daily Do something like copy files from one place to another Then you'd put that inside a script and put that script in this directory and the operating system would execute it every day But another way to do it if we go back into the just the cron dot d directory There's cron daily cron hourly cron monthly, but there's also a general cron which you can specify exactly when you want to execute it and Let's just look at an example php5 this example script that executes on a regular basis it's a bit confusing but These numbers are the most important ones The syntax is saying if I remember The first two numbers is Execute this command the following stuff Don't worry too much about what the command is. It does something regarding php execute this command At nine minutes past the hour And at 39 minutes past the hour Star means At any hour Any and the other stars. I think any day in any month. There may be another one. I forgot Meaning effectively execute this 30 every 30 minutes At 109 139 209 239 and so on every day So we have some way to make a specification of the time when we want something to execute Executor as the user root What to execute this one? Let's create our own Maybe easier Pseudo nano and I'll call mine mine. Okay our last task for the day Pseudo nano a file name password And let's give the syntax Uh, I think this one will work We may have run out of time, but this is saying Every one minute Every hour so slash one mean is a special case for every one minute star means for which hour Every hour any hour it means Which day any day meaning every day every month. I always forget the last one. I don't think it's year As root user execute this command and whatever we want to put here. I put here run ls on home slash steven output the Output of that command into some file, but unfortunately we run out of space on my screen. So I'll go to the end LS or is slip simpler one Now the problem with chrono is we normally need to specify the exact path. That's where it gets confusing So run ls on the root directory and take the output and put it into this file The idea is that every one minute it will run that command And the output will be updated all the time on that in that file Save it control x Yes Let's hope it works We need to restart chrono. I don't think Have a look look at the time date To see when it might be on the minute Didn't work Didn't work. I don't think okay. Let's do one last attempt Change slash one to 58 If it doesn't work, then we'll give up I'll show you my command after I see if it works It worked I'll show you my command I said 58 no slash 58 meaning at minute 58 on the hour I chose that because I knew it was 357 At minute 58 as root execute this command Don't use 58 now set yours to 59 if it didn't work Then If I look in my home directory I see there's a file called ls.txt created at 358 and it will contain the output of that command So In the first example, I got the syntax wrong. It didn't work But in this case it did so we need to investigate further to get the the perfect syntax Ah the star was missing good. I should have hit star slash one not just slash one To do every minute Physically you can schedule at any time to do particular things To back up your file system to another server To update your web page To to restart something To clear files Anything that can be scheduled can be done with prom and at that time it's a good time to finish