Today on HakTip monitoring your system resources in Linux and this hack tip is brought to you by Eero
Welcome to HakTip the show where we break down concepts tools and techniques for hackers gurus and IT ninjas
I'm your host Shannon Morse and today we are talking about monitoring system resources in the terminal now
I have already talked previously on HakTip about ps, kill, and top commands those videos are really great primers
But there is a lot more to monitoring system resources than just those commands so in the next two episodes
I'm going to delve farther into how you can use these plus talk about some new commands that can be very useful
So to start let's go ahead and review PS with some new options PS
so PS by itself lists your current processes if I bring this up in my
Computer and hit PS you'll see that I'm running bash and PS and that is it so this by itself can be very
Useful if you just want to see what's running on your machine. That's currently open
Taking it a step further you can type in "ps aux"
Like so and this brings up a slew of information so this list processes for all users
Which is the a the u lists user oriented
Processes in the X list processes that don't have a controlling terminal screen
So you're pretty much gonna get everything from your computer now once you get your list
I'm not gonna cover
Which each and every column means because I already did that
Previously now since this lists all of those different processes it is gonna be a very long list I can look for a specific
Process itself by greping it so we have already talked about grep as well
So I could type in "ps aux" pipe to grep and I'll specifically look for
Chrome and it looks like I have one process running Chrome right now. That's good, but if I open Chrome
I'll just restore anything that I had on here like hak5, and I'll just minimize that so we can come back here
I will
Open that up again this time
We see that Chrome is running a lot of processes when you actually open it as you user
So this is going to show me the data for each chrome process if you want to make the big list more organized
But you still want to see all processes you can add the F option
So I'll hit up a couple of times add an F
And then hit enter so if I look through here you will find that certain processes have a lot of additional
Processes with them keybase is a great example up here, and if I scroll down a little bit
You'll see that chrome is pretty much the same way
So that's interesting that could be useful for us in the future spoiler alert next thing
I could type in is PS
Uppercase U snubs and that is going to show me every single process that is running under my user account
And obviously it doesn't have to list that they're all snubs because they obviously are because that's what I searched for
then if you find something that you don't want running you can always use kill again to kill the process so for example if I
Want to kill keybase I'll just scroll up and find key base real quick
Let's see the main command is 2-1-5-8
So I will use kill 2158 and then that will kill keybase
But it does leave the other keybase processes under different PIDs, so I could instead use killall
keybase hit
Enter and then that will kill all the processes with the name keybase in it. Now there are a few
Options available for kill so make sure that you check out the man page for kill as well because they can be very very useful
And I will mention more about that in just a moment, but we are going to take a quick break
and
Thank our sponsor when you are looking to improve your wireless network
Making sure your entire home has a strong signal is a must and that is where Eero comes in they are launching their very first
Second generation mesh Wi-Fi system that comes with one Eero and one to two beacons and these are mesh access points
They are not extenders. They are smaller they also plug into an outlet
They have an ambient nightlight, and they are more powerful than the originals
But of course if you already have the original Eero has you covered as well these babies are backwards compatible
And they can be purchased separately systems start at $399 for all three components together
but if you want to just buy one beacon you can totally do that as well you can and they're cheaper than the originals at
$149 each we've gotten a chance to test these out in the warehouse where our Wireless usually does not reach from one end to another
The EEro mesh does a really great job of fixing that headache
And it gives me the speeds that I pay for from my ISP plus
It was really easy to set up and it's also very reliable so Eero is also announcing the Eero plus subscription
which includes advanced network security monitoring
Supplementing the features that are already built in that you get for free with the device
And they also include content filtering
Which is really great for houses with kids and with any system you get automatic
updates two-factor authentication for the admin access and Eeros backing with a bug bounty program and third party audits
We've got a coupon code for you two for free overnight shipping to the US or Canada you can visit
eero.com and at checkout select overnight shipping and then enter haktip to make it free check it out and learn more at
eero.com we are now back with monitoring system resources
so I have mentioned it before but it is definitely worth a re-mention you can type top to run a
dynamically updating list of processes and see how much CPU
Each of your different processes is running so if I type in top you will see all these different
Processes now if I do something in Chrome like I will load up. Let's see I'll load up my
YouTube account and
then watch the processes as
I should pause that that was really loud, okay.
So if I look at top then it will show me that the processes are taking up a whole bunch of CPU the ones with
The most CPU usage are at the top, so you can easily look at that and kill the process that are taking up the most
Area on your CPU I've already gone over all the details about what everything up here at the top of top means
So check my previous haktip episode along with my terrible presenting skills from five years ago in the show notes below
But something that is really cool
The top is you can simply press K like that and then you see this additional line show up right here
And if I want to kill Chrome, I'll type in 3-4-8-3
Hit enter it asks me this weird thing about 15/sigterm
Whatever hit enter and then it kills chrome cool, so I should probably mention what that 15 meant so it's basically a signal
Identification number for kill so some common ones that you might run into are -1 which hangs up controlling processes that have died
-15 terminates processes gracefully by killing any stray files or processes along with that PID and -9
Stops all the things and just kills everything out there for that process so that's kind of like the blue screen of death
Version I guess it just ends everything even if you haven't saved it
So I will end with a very simple command that can just list open files on a system
Everything on a Linux file system is considered a file so while I
Just have this text file opened up in the background on my username for example
There's actually a whole bunch of other stuff open too so the command "lsof" will list all the files
Open which kind of makes sense given the the terminology there on your machine?
But much of it requires root access so if I quit out of top
And I did that with Q. Then type in lsof
And it's going to list a slew of stuff here and again that means root access
Where else each of the files will say permission denied no worries there though?
We are just giving you an example here
You can also add the -u option to that and then snubs to see all the files that are open just first snubs
Particularly and that's about it for now be sure to subscribe to our YouTube channel
Which is youtube.com/hak5 for more great stuff
Just like this make sure to hit that little like button and comment below on your favorite
Tips and tricks for the Linux terminal and make sure to check out our sister show which is hak5 for more great stuff just
Like this and again, I will be there reminding you to trust your techno lust