Mastering the Linux Command Line • Bert Jan Schrijver • GOTO 2019

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Great work... If someone new to the terminal watches this I doubt they'll remember many of the actual examples but what it does is let us know the possibilities. That's the key. Once you know the possibilities of a terminal emu or programming language you are armed with Google search terms and you can begin creating solutions to problems.

👍︎︎ 9 👤︎︎ u/ragnar_graybeard87 📅︎︎ Jan 28 2020 🗫︎ replies

Check out this 45 minute talk from GOTO Amsterdam 2019 by Bert Jan Schrijver, JavaOne rockstar & champion, NLJUG leader & CTO at OpenValue. Give the full abstract read below:

Short version: I'll show you everything you need to know about the Linux command line as a developer.

Long(er) version:

As a developer, you often have to deal with Linux servers. Troubleshooting, digging through logs, editing configuration files, you name it. If you're used to working with Windows or OSX GUI's, the Linux terminal might appear fairly basic and difficult to use.

But, with some basic background knowledge and a small set of terminal commands in your toolbox, it can actually be extremely powerful and loads of fun!

In this session, I'll explain the concepts behind the Linux command line and I'll demo loads of useful stuff. You'll learn how to quickly navigate, find files, examine and search through logs, how to investigate a system under load, a bit of shell scripting, ssh tunneling and more!

At the end of this session, you'll have the chance to throw your own problems and use cases at me - I'll come up with solutions on the spot. Bring your own problems ;-)

This talk takes places entirely in the command line. No slides, no IDE, just a plain terminal window. After this session, you'll be on your way to master the Linux command line yourself!

What will the audience learn from this talk?
In this talk, you'll learn everything you need to know about the Linux command line as a developer.

Does it feature code examples and/or live coding?
Yes, it's a 100% live coding talk – I'll spend the entire session in a Linux terminal.

👍︎︎ 4 👤︎︎ u/goto-con 📅︎︎ Jan 28 2020 🗫︎ replies

Ouch! Have to admit that after +10 years of Linux use I did not know about tab completion.... 🤨 🤯

Thnx for sharing 🙇

👍︎︎ 2 👤︎︎ u/kolerezooi 📅︎︎ Feb 09 2020 🗫︎ replies

I'd say this is more in tune being called a crash course of the Linux commandline. Nevertheless, still pretty comprehensive for devs which are not so familiar with it.

👍︎︎ 1 👤︎︎ u/socium 📅︎︎ Jan 29 2020 🗫︎ replies
Captions
[Music] [Applause] all right so it's good to see that there's so much interest in something has been run for so long so how many of you own one or more devices that run on Linux okay who didn't raise his or her hand you might run Linux devices without even knowing if you have like a set-top box or maybe a phone or maybe even your stove in your kitchen it might run Linux because things kind of everywhere everywhere around us and I first got in touch with Linux when I started studying University intenta in 1998 and my friend Elmer introduced me to this operating system Linux and then it all went downhill from there and it cost me a couple of years of my study but still I learned I had some fun so the next 45 minutes I'm going to share my experiences with using the links come online as a developer so I'm a Java developer and I'd love to share some some tips and tricks with you so it's the first time I'm presenting this talk so it's a new session for me and actually it's kind of a strange session format so typically I either do live coding or I presented slides and now I'm going to type commands in a terminal for 45 minutes and I hope that people actually look listened to it and looked at it and enjoy me doing this but I need some like some some reassurance from you every now and then I'm on the right path so I'd like to ask you two things first is if you see something what you think is awesome please clap or shout or say wow that's awesome if you think something is like optimal please tell me afterwards but I'm really interesting hearing your feedback like this you miss anything this you think I was too fast or too slow please tell me either via the app or afterwards or over email email is up there or over Twitter I'm on Twitter way too much so I'll probably respond there way too quick so let's let's practice with who thinks that my opening slide is okay yeah who thinks it's awesome so you can see what I did in the commands in the top I won't go into that but I liked it was a nice touch to kind of get started so to introduce myself a bit further my name is Rachel - and this is me so it's actually my Twitter profile converted into ASCII I work at open value which is a full-stack Java consultancy startup with offices in detect wrote them a Munich and I also do some stuff for the ML jerk melons Java user group so I must admit I'm a I'm a Java guy so if you want to follow along the entire basically talk is in this text file and this text also might get up get up to combs lesbian you can read everything there that I'll always share in this in this session and let's get started so the assumption from me about you is that you kind of know the basics so you know what Linux is you know what CD and LS and stuff like that is if you don't don't worry don't run away but you might need a little extra introduction afterwards so if you connect to Linux over fear a console via terminal so you're starting a terminal session you can either do this on the server itself or by logging in with some remote protocol like SSH so when you're starting a terminal you have a connection with the machine and then you start a shell and shells a program that interprets whatever you're going to do so I typically use bash which stands for the born again a shell it's one of the most widely used shells so the shell interprets your commands and feeds them to to the kernel so if you ever get stuck with anything the links come online is here to help so you can use mum which is like the man page so for example the mom of PS shows you information about what the process commander's this is big enough for people in the back to read yeah ok and some commands even have like built-in help so probably PS minus minus help says something you can use a simple and will get some more some commands do not have am on page for example CD there's not a manual tree so how do you know how to use CD well you need some help sorry type help CD or if you're more like a post fix person you could type CD - - help and you look at exactly the same page or sometimes even come on - h or in this case and warm work so if you get stuck try mum help - - help or - - H I'm going to show lots of lots of things considering pipes so how many of you are familiar with the concept of pipes in Linux okay well most of you so pipe looks like this it's like the pipe sign and what a pipe does is it takes output from one command and it feeds it into the input of another command so let's take command that we use output like echo test 23 and now we own the command call for some poor F where you can type something in and it will reverse it so we can now chain chain these commands together by saying echo testament free and chain it - ref and then it will fit the output of two of the first into the empty of seconds we can chain it again and we'll switch it back again so for those who thought the example was not elaborate enough we can do it again we can do it again and we can keep doing this all day but I won't bother you with this so I would say that pipes are kind of like pipes - - Linux or somewhat is what rest is - microservices so you can connect all commands together typically in in Linux one command there's one thing and this one thing well so you could kind of compare it to the philosophy of micro services although Linux commands are actually really really micro so if if if you are to take away one thing from this session I would say it would be about tab completion so how many of you know about tab completion okay well most of you so tap completion helps saves you typing so it actually saves wear and tear on your keyboard so let's say that I want to go to the etc directory I could type etc and then see where I need to go and oh I need to go to network and we need to go need to go to I F up dot d just some run I could also wear type cd' ET and n-type tip and anti was something with net tap ok tap again I can even netplan network network D dispatcher it's probably network okay and then I'll keep hitting tap i hmm and another so it can help you quickly navigating to directories and if you even have like a really long directory tree like this is a very long recruiting so when I first and besides someone and I see someone doing this I died a little on the inside so what you can do is CD this and then five top top or if you're adventurous you can do CD this and then here we go just keep it pressed and it will never get all over true so you see like these visual bells this happens when the command well but she expects you to do something it cannot find an order directory to navigate never get into so tap complete you can really help you are navigating really really quickly to directories also to pass to see files just hit tap as often as you can and probably you'll be good so let's say that I'm navigated to this very deep directory and I now want to never get to my home directory sorry type CD then I want to go back to the piece directory it's AB CD - which goes back to the previous and also prints it do it again and you're back you got again inter back so CD - helps you to quickly jump back and forth to different directories if you lose something like a file or something you want to find it you can use a command fight so let's go to the for our directory are typically locks and stuff are there if I had fine dot which is so all the files in this directory but I'm only interested with files that have a name star door lock and this will give me all the log files but now I'm only interested in files that have a size F at least 500 K and it will give me all the files with at least five front ok so to make sure that fine did not lie to us let's see if we can find out the actual size of these files so I'm going to add an execute command and then you can enter a shell command that gets executed for every result of the five commands so let's say echo and then the kind of gets a bit obscure because they you need to type curly braces slash semicolon which basically means like this is where the output of find will be put into and this is to terminate the command so now we execute echo for all the outputs of the command which basically outputs the same because it echoes the files but now if we do like D U which is disk usage and human readable format then we will see that these files are 620 K and 6 away k so you could also do this for example to clean up all blocks if you put an RM in the execute but pro tip if you ever feed RM to execute like execute RM file please test it first by typing echo because you then we get the output of all that finds will do and if it says like RM your entire disk here then you're happy like you typed echo in front of it so first step echo till I can do a dry run then remove it and actually remove the false then let's locate and locate can also help you locate stuff so find it's always executed like runtime you actually find and then starts looking for files then locate works based on a database so I can try locate NPM and MPM is in user bin NPM and use a local bein NPM but I can also make a new file in the root and p.m. so now if 3m p.m. binaries if I now do another locate it will not find this file because locate search is in the database so it makes like a snapshot of your disk not in my search database and it searches there so it gets updated at night I think but you can type update DB which will update the locate DB and if I now locate NPM then my my new NPM binary is also there so sometimes you're wondering especially with NPM which NPM version am I using I'm using one am/pm version but there might be tree on my system so if you want to make sure which one will be executed if I type it you can type which so which NPM will show you whichever executable will be executed if you type it so in this case is to want to use a local BIM probably because this is the first directory in my path that will find the MPN directory so let's check it out this actually don't want to be in executed yes this is you need one npm version and i'm probably this one is another version which it is so which can help you find the binary that's currently on your on your part so obviously the main goal of typing in a terminal is not typing too much in a terminal so touch up tab completion but typically you have like repeating commands so you are executing commands that you've actually before so if you press the up arrow you will gather all your previous commands you've typed and if it's not too much commands in the past and it's easy way to navigate there everything you type is stored in your history so if you type history you will see everything that you typed like in the last 2008 commands in this in this case so you can execute the previous command from your history for example exclamation mark exclamation marks is shortcut for this or even now execute the history command again for example if I type on our date and then exclamation mark who actually to date monogrammed so which is sometimes see is that you you have typed something and it says you don't have X you don't have enough X is any type okay sudo and then actually this command again which will execute it as a super user but be a bit wary of this because if you are not sure what your previous command was and you actually the sudo you might actually screw screw stuff up so sudo runs it as the super user basically as the root user you can also go back to a specific history item for example if I want to go to this directory I can type exhalation mark and then 1989 and I will go down so this will help you save some some typing but there's more there's also reverse search if you press ctrl R then you can actually search through your history so I made this a very long directory tree yeah if I type em Kadir minus P and I typed it correctly then there it appears if you keep pressing ctrl R you will get other matches to this search so this is a fast way to search through your history did you see anything awesome yet I didn't hear you okay good I need the confirmation every now and then there's file and file shows you what type of file a file is so if I go to the the root directory what do we see here there's a large file called swap dot image well I can guess what a swab dot image is but found knows it's a Linux file new style there's fear - what's fear - well this is a symbolic link to something else I go to bin take a binary there this is an elf binary even at a like a Java jar here what's this this is a jar file so this can help you if you for example download the file without an extension to get an idea of what's the file type of this thing so typically use this if I've downloaded something to check whether it's a PNG or JPEG or something or something like that then there's diff which you probably all know from your favorite IDs so let me create a file okay copy it and then remove the last the last line okay so we have now test 1 and test 2 so I can make it this between those and it will show me that oh there's in the second file test for missing but it can also make a side-by-side if side by side and even add color mmm if I know how to enable color - - color so this can help you if you have for example 2 log files to make a diff between them what I sometimes do if there's like really really long jenkins log files you you just download the two jenkins log files on your machine maybe they're already on your machine they can dip them to see if there's like differences between two builds so what I have every now and then is that the build succeeded for ten times and then it fails and I don't want to see okay what was different in all those ten thousand output log lines of my Jenkins build so if you used if it's an easy way to find these differences typically all these command line utilities are really really high performance so they have no trouble comparing to 10 megabyte files while your favorite editor might have some problems reading files this size or maybe if you like 100 megabytes or gigabytes so it's typically really really fast and then there's VI and VI is an amazing editor which is present on every system it's a bit like basic but if you know how to work it and it will work fine let's run problem with VI and that even I don't know how to exit it so there there was a joke about VI like what's your favorite editor my favorite editor is VI I'll be using it for two years because I haven't still haven't found how to exit it yet but the nice thing with VI if if you kind of get to know our work you only need to know like copper commands like I is for insert and : q is for quit that's basically all you need to know it is something at some every system is you can use everywhere and you'll get kind of like a love-hate relationship that I hope it tends to go towards the law side of things so let's go into networking typically the way our you log into a Linux box is by using SSH so I'm now logging in as user Bret down on the IP of my VM so everything I'm showing you is a stock ubuntu server VM so if you get go to Ubuntu org you download the server ISO and you've got almost all the commands that I demoed are in there so nothing specially installed so I'm associating into my machine but then I need to type my password and that's you know typing costs time and causes keyboard wear so I don't want to type so this is thing called SSH key authentication so you can create a private key on in this case on my Mac and if you install the public key from this key on your Linux box so you can log in with key authentication so you don't need type a password you can copy this key with SSH copy ID and let's copy it to my user on this host I need to type my password because I need to log in there but once I've done this my key is installed and now I can log into it without typing a password so that's nice it's also a bit more secure because you're not transmitting your password over the line there's just a public/private key exchange because the username on this server is great job and on my Mac is the same user I can even type just the IP which makes it even quicker I could also maybe put this IP in my host file my Mac and then give it a name so we'll be even quicker but I won't bother you with with yet yes and then SSH tunneling how many of you have heard about SH tunneling before how many of you use it regularly okay so as sage tunneling is pretty cool because you can do all kinds of nasty things that typically Network admins don't want you to do so with SSH tunnel you're kind of like using your SSH connection to tunnel to a host that is reachable from the machine your SSH into so let's say that you are you have like an entire network of servers but it's protected from the internet and there's only one host like best young host or a jimp host that you can access to extra network and you want to connect from your local machine to a database that's running here somewhere so what you can do is SSH into like the jump box and then set up an SSH tunnel that will expose a port on your local machine and connect it to one of the ports of your remote network so let's assume that on this this Ubuntu VM I have here is I don't know running somewhere heavily firewalls I can only connect via SSH to it so let's fire up a Java process here this is a basic spring application that will start listening on port 8080 for HP requests so assume that this box is firewall and that I cannot reach this over directly so what I can do is Association to the machine and then open a safe zone so I'm creating a local tunnel so it opens support on my local machine so it opens port 8080 of my local machine then it locks in to the Linux box and then I need to tell it where they were to connect so it needs to connect and here's where it gets a bit strange it needs to connect to local host local host on the remote machine so actually that remote IP to local 8080 so now I'll be linking for port 8081 on my machine to local host 8080 on the Linux box okay so now I should have local host 8080 on my machine no I shouldn't because I should have any one right because i tunneled local 8080 work an area so let's go to hello and we'll get a nice or nice greeting so this can help you in kind of like opening up Network ports or machines that you cannot reach directly as sage tunneling if ever you are on the machine and you want to find out what is the IP address you can type ifconfig and then you see a bunch of text and you're looking for the inet string so grep is a command that can filter output of well that can filter input basically so the output of ifconfig gets piped into grep and I'm gonna grab I'm a filtering the lines are going to see the lines that have inet in them so I get this then I'm not interested in these I net six lines because our pv6 eyepiece okay there's two left let's see I not interests so I need to filter them so grab - V filter slides so now I have two lines and I'm also not interested in the local IP so the IP of this machine is 83 215 which is to want to be in connecting to all along so probably it's the right of P so sometimes you are building an application you need to build an interface to a remote machine for example like a web service or something you start up your application it says connection timeout or something so what's going on lots of stuff can be wrong so first you need to check network connectivity for example I've had the I need to make a web service that goes to domain Google Dalton L port 81 so first let's see if I can resolve Googlebot now so if I ping it so ping will send like small packets to it it will first resolve the hostname to the IP and then we'll start pinging me happy okay so resolving works because I get the IP I'm also getting pings in reply so in two milliseconds Google is replying to me which is fine so I now know that the NS connection works I now know that it e that the ICMP pink connection works so that basically Network route works between my machine and Google now I can use telnet to set up a connection to Google to now and let's connect to Google now port 81 and it's trying but it's not working because probably port 81 is firewall at Google so I call my friends at Google and said yeah you told me to connect here no no it's port 80 our case protect let's connect to port ready ok I'm not connected to Google la tournelle so what do you do and go to Google you just do HP request right now you get Google so not really a useful example but you get you get the idea with the combination of ping and telnet you can check problems on the nside problems on routing side on internet connectivity and even on connect to specific ports and then the scroll and curls basically like small HTTP client so you can use krill to go to Google little now and you'll get the same result I could also use curl to go to low close 8080 slash actuator slash health to check whether my app is healthy so it's healthy so it's a small like HTTP client you can also use this to download stuff that you need to get on your machine if you want to get stuff on your machine you can also copy it to your machine so I'm now back back on my Mac and let's create a test directory and the test directory let's create a test file so touch is a command that will create that will touch the file for you to create if it's not there it will update the timestamp to today if it's already there so this file should be created today yeah which is true so if I now want to copy I can I would say locally I would say copy we recursive test there to maybe test there too you can also do secure copy which is basically copy over SSH but I need to add the remote host of it which is 1 I 2 1 6 a dot a 3.2 15 and copied to my host to my home directory and call it test there too so now it is copied it so let's check it out and here is a test there and there's the test file okay let's remove it again another way is which is bit more interactive is SFTP which is basically has an FTP like interface but is over SSH so if you do a zippy I can also put the directory to the remote host which will basically do the same and for those that have trouble choosing let's remove to there again for those who have trouble choosing as a third option and third option is our sink so our sink will synchronize a local folder to a remote machine so you can say are saying - our test there to this IP home there and then again to test there ok so now I should be here but the nice thing is that our sink sinks so if LM not a foul here for my local machine it's now not in the remote machine in the test there there's only test on so if I now our sink again it's now there so you can use our sink to sink like a remote directory to a local directory maybe even with if you want to sink like maybe a may propose to or whatever so let's talk about some productivity tools Cal shows you a counter current month Cal with the year so she can for the entire year I use this way much more than I should probably but if you're already a terminal it's easier to just type Cal and take a look at okay August 7 is on a Wednesday that if you need to fire with Outlook or oak my my calendar so it's if you're AF thermal open this can really help in quickly doing things the same goes with BC which is the ball and calculator it can calculate stuff for you stuff easy stuff like 10 divided by 3 is 3 mmm ok it by default the scale is set to I don't know nothing behind the comma so you need to set the scale and it will work better but if you need to calculate something quickly something small it'll it's also useful you can also feed input into BC directly fire pipe you get the answers or you can out you can use this in in scripts if you need to for example calculate something there is a profile foul on a linux box and this is executed every time you log in so let's say that I open its file and I had something like hi from profile when I log out log in again it will say hi from the profile so you can basically put live scripts in there or define aliases so an alias is a way to kind of like create aliases for commands or create your own commands so let's say that you have a you're tired of typing git pull you can say alias GP is get full and I've time in our type GP it to do a get pool and if you want this to if I log out now and log back in again this is God but if I put this in my profile then it will be there forever well until I removed from the profile again log in again GP so it's like a quick way of creating shortcuts for you it will work most of the stuff will work with your when your mech - then if I type like a long line and I want to go back to the beginning I can do this but that's not cool isn't it so you can type ctrl a to go to the beginning Y a I don't know because it's the first letter in the alphabet I'm not sure e for nth works so a and E can go to beginning and end of the line ctrl L clear screen ctrl C Terminator command so let's say that I'm typing watch - n PS so this will watch will continue will execute the command you pass through it every second so for example if you're waiting for some job to finish and you're continuously calling an end point or looking at the log file you can either enter a command every second or you can feed it to watch so if you want to exit this command I type control C and I'm gone if you want to end input your typing for example in a foul or in a shell you type control D and then you're gone so I never want you to type exit or log out again in a console type control D it's faster and it saves you from from typos then there's less unless it's a nice way to go through logs for example so I have logs on my demo app here when less you can scroll to it also page up and page down works you can go to the end with shift G it goes all the way to the end and you can even if this file gets appended you can even follow it so let's say that I'm going to my app here I'm not sure if the tone is still alive now I killed it but I can directly connect to it okay so now I'm adding logs to my log file but I'm not seeing here so if I press shift F it will follow the file and then the new data will get appended you only see the timestamps editing but the data gets appended and then there's brace expansion which is also nice actually everything is nice so let's say that I want to make ten directories I could type make the air test 1 make it test - but it's that kind of sucks right so I could say to demo it with echo echo test and 1 to 10 - which will do echo just wanted to see - little mega test won't attempt now if 10 directories you can also use this to remove to rename files so move test 1 comma 11 and let's equity just to be sure so this will move test one to test 11 so brace expansion helps you in kind of automating stuff when when you have like repeating tasks or or numbers or characters I already showed you watch and I'll show you screen now screen is a way to start commands in a pseudo terminal so with screen you can allocate a pseudo terminal start a process there and then with control ad you can detect from the process it keeps running if you if you log out and you log in again you can still type screen - are two reattached and you still in there so I have my java application running here in the foreground but that's not really working out so let's start a screen start my job application did this detect show control ad and the application will still be running now actually it should it is it was starting so to continue with pipes if we look at the script here I'm saying Java - yar part and then T then we observe lock so T both prints output to the console and write to a log file so now I have my logging in the screen outputted by the process but it's also in the demo app dot log file so if we want only get like the first line of the log file I can use head if you don't want the last line I can do tail so minus n is a number of lines I can also follow the log file minus F and if I keep adding new requests now then it will add new locked new log entries and now let's I kind of do some lock analysis so I've made a couple of requests go - hello - and there's no tree and let's say that I want to get in like an overview of which URLs were were accessed in this log file so let's get the file and then grab oh I don't know how I did I'm not sure that data request - hello - so what we see here is that the dispatcher servlet says get and then the URL so let's grab on this okay let me make it a big bit bigger but there's there's like lots of craft in here that we want to get rid of because I'm only interested in which different URLs have been called and how and how many times so I could use cut and cut can hear use a delimiter or a number of characters to cut something off a string so if I say could mean bytes and then everything from character 50 and further okay then the stuff kept cuts off maybe 70 maybe 90 maybe a hundred maybe 101 and now I have only liked that get and then the URL a string or accuses a WK anybody okay it's like a column based string editor so I now have everything but after say a WK print what would it be like column 13 or something no maybe 12 maybe 11 maybe 10 yes 10 so now I have all the URLs here notice this dispatch dispatch thing in there from an error let's filter it out and now I'm almost good but I'm not really happy with the quotes that are in there so let's remove let's remove the quotes we can you do this by using set which is a string editor so you can basically apply rag access to test to text so let's say set and replace quote with nothing and do this globally so my quotes are gone and also replace the comma at the end set as the comma with nothing okay we're almost there now I want to count it so I want to to count this you can use unique so unique finds unique entries which unique and also count which unique only works for some reason on saw that sorted input so I first need to sort it it's now alphabetically sorted and I can say unique - see which does account so now I've an overview the URLs that were called in my application so let's make this in like a small script call it - dot essay is getting executed by - make it executable execute it okay and I can use watch so Ward's maths and one desktop to search okay so now if I go to my browser and I go to hello for there are this and if you type it like five times 2005 so who needs qivana if you have this so that this this obviously kind of fairly simple example this really helps you in getting really quick in in going through stuff like this let's see we felt most of this lets go to system analysis sometimes you have the idea like what's going on my system is behaving a bit slow what is causing this you can use top and top will show you stuff like virtual size resident size percent CPU percent memory and commands so now let's fire up a command that will keep my CPU busy and see how this how this reflects in my top so I'm doing is reading from def few random run a generator and feeding it to a zip application which it cost some CPU load and indeed is now saying that BC up to is using 90% CPU so let's find this process ID and get rid of it if I am on my oh my limit machine okay so is it gone yes everything's back again and this process has been killed one other nice trick is Esther days with Esther days you can connect to running processes and kind of see what they are doing you need to do this route because it's not a lot for all users but let's get the process any of VI process the FBI because I have my VI running right that's that's this that's this thing a wall at wall that's something we reality with SSH theory of honor let's let's let's stick to VI is easier PDF VI and then I want to trace this or let's Esther is this - P and I'm doing command substitution so I'm doing here the output of this command gets fed into the other commands and I mean s - s minus P 1308 then ostrich egg outputs outputs to standard error which you cannot perform pipe operation zone because pipe operatio only work on standard inputs so I need to redirect my standard error which is output to to output one so now all the standard error output gets fed into Senate output and I can grab on read operations well let's not do it first let's see what happens so now we have the price attached here so if I do something here now you see garbage flying around right but what if we only interested in like reads commands ok so what happens if I type I would repeat hi go to see now basically listen into this process and see what characters have been read from the keyboard so be aware you're never safe of what your system and assertions administrator is watching as 14 you okay we got this VM step is also nice utility to kind of get an idea of what's going on in your system so what you're seeing here is memory so swap three buffers and cache swap and swap out blocks and blocks out interrupts context switches and a CPU user system idle wait and some new flag regarding VMs that I didn't really dive into yet so vmstat is now fairly clean there's no swap being used no I owe this CPU is 90% idle the what if I execute a DD command again that will keep my CPU busy right where are we here let's we said it okay we're seeing now is that the CPU is going from idle to 90% user and there's a lots of interrupts and contacts which is happening so probably some CPU bound process is now running on this machine to find out what it is we go back to top and we see this again this daren't Bishop to command and that we already found how to kill then sometimes you have the same thing like which application is using this port you're starting up application and it cannot bind to port 8080 so can use netstat for this with some options that will give you for example the applications that are listening so I typically use net step - pen because it's easy to like to understand and to remember and then I want to grab a poem okay what's listening on port 8080 okay that's process three nine one four it's a Java process so if I kill this port 8081 become available again you can also use LSO F list open files for this because in linux everything is a file devices are files files are files but also network connections are files so you can say LS o f - I on port 8080 and I will get the same output there's process three four one nine listening on on this port hello so f also can show you which process is using a file so if I'm going to my C to my java application which switch process is accessing my log file well that's the T command because the T command is writing the output from the Java process into the log phone I got three minutes left which I probably will make some what D you shows you sizes of files so if I go to my log directory again d u- h which is human readable four-star make an overview of all sizes of thousand directory of files and directories in this folder so if you like looking to clean up stuff or which of my log files is using too much space you can use d you to kind of get an insight on this really quick on shell scripts you already dove into it a little let's create a shell script i call it test lotus edge it's interpreted by bin - if I put like user bin PHP and there I could write PHP code but I won't bother you with it let's make a variable that will capture the arguments to this program which is dollar one and then echo the arguments okay let's see if this works I need to make executable I need to feed it arguments hi arguments so you can also do stuff like ifs so let's say if arcs is okay we're going to make like a cheat cheat mode so what what is a good cheat code to pass what cheat codes that you use in the past when starting of applications come on you never cheated in the game god okay go to Google if arcs is got then echo cheat mode activated else echo your own your own Phi so in in best scripting most statements that you end with one statement did you open one stay with the Emerald reverse so if Phi case I check stuff like that so let's see I'll see if it worked test Lotus h-hi you're on your own birth death old age God and I achieve what is active a it Wow so one final thing you can see use functions in scripts and then it actually kind of becomes like programming so let's see find a function here and the function says test and I can call the function here so that's not copy-paste too much some things function test one and it echoes test and it doesn't work so did I save it whoa what's going on oh sorry yeah you're absolutely right test one test is a is a linux command that's why it wasn't working okay so we have almost no time for questions but I'm happy to take questions a couple of things I want to share well actually only one if you're getting serious in making scripts with bash there's a tool called BOTS which is kind of funny if you're like a if you're from the Netherlands and both stands for automated testing systems you actually do like TDD with shell scripts so I'll leave it to that my slides are own get up Lacombe slash paid job if you have any other questions feel free to reach out at the a survivor on Twitter I'm happy to help thanks a lot for your attention and please let me know what you thought of this [Applause]
Info
Channel: GOTO Conferences
Views: 43,139
Rating: undefined out of 5
Keywords: GOTO, GOTOcon, GOTO Conference, GOTO (Software Conference), Videos for Developers, Computer Science, Programming, GOTOams, GOTO Amsterdam, Bert Jan Schrijver, OpenValue, Linux, Linux Command Line, ssh tunneling
Id: qmh7Uppd3x0
Channel Id: undefined
Length: 45min 50sec (2750 seconds)
Published: Fri Oct 04 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.