Linux commands you NEED to know. PS and GREP
Вставка
- Опубліковано 5 тра 2024
- X: / typecraft_dev
lets kill some processes in linux with the ps command and grep. grep will help you search for items in your process list, and when you found the one you are looking for, you can ... well... kill it with "kill" - Наука та технологія
“ps ax” will display processes from all users, useful if it’s launched by a different user than is doing the debugging.
Considering the merits of having different services run by unique users, this is very important! This is really important for new Linux admins who want to use their root account to run everything, that is horrifically bad practice. Remember, users have different security access. On principle, these services should run by users that only have access to files they need.
As an example, if I'm running a minecraft sever on a Linux distribution, I would run server.jar as it's own user, Minecraft
To further this example, say I instead ran it using the user that runs an email service on the same machine. If the Minecraft user became compromised, those emails would also be compromised.
So long as the Minecraft user was locked down properly, those emails would be safe because they are only accessible to a non-compromised user.
-e also does the same
`pkill puma`
killall puma is the old compatible name . But sometimes you want to use your brain to choose which similar process to kill or signal .
yeah but that isn't the gigachad way of doing it
@@johndododoe1411 fair, personally I use pgrep a couple of times first. I started playing around with a nvim rpc plugin and it’s handy to test degenerate failures.
@@Redyf fuser -k 3000/tcp
btop will allow you to search procceses by name, you can kill the command with two keys at that point
*laughs in zombie process*
Man this type of content is soooo gold! So many little bits.
I think u should do a whole vid on piping
RIP puma
Why not pgrep it to get the pID?
On good systems, pgrep is grep with Perl style search patterns, unlike regular grep, egrep nsd fgrep . If some joke system uses pgrep as a process grep command that's just cruel .
Or `pidof puma`, or `kill -9 $(pidof puma)`, but `killall puma` seems a bit more efficient.
neat, but unnecessary
just do `killall puma` or `pkill -9 -f puma`
Does not fix the problem, if you want to kill just one of more than one process instances. gtfo
Killall left the chat 🥶
I just use pgrep and pkill
pipe the output from grep into awk to get the process id then pipe that into the kill command.
Congratulations on having a system with longer process ids than the common 15 bits .
Hey, nice video. Wondering what keyboard you are using?
Are you using the starship gruvbox prompt with custom colors?
Nice keep up the great work it’s very helpful
I always do ps aux | grep search-string and the kill -9 PID, but yeah same thing
what’s the difference between using kill and pkill?
One of my first ones. So ldur!
Any tips related to battery saving
A useful way I've implemented is to quick check if I have a certain paclaje installed, like so: `sudo apt list | grep (package)`
be rly careful using apt in pipe instead of apt-get because piping the output of apt not being stable behavior is literally the exact reason why a lot of people say use apt-get instead of apt in scripts. its even completely fine to use apt in scripts, as long as you never pipe or otherwise parse its output other than return code.
@@tacokoneko If I need it for something complicated I normally do apt-get, but for just a quick package check I use apt
No need to sudo though
Genuine question: why not just `pkill puma`? Is there some difference under the hood?
Ya might have multiple processes with similar names
Please talk about the flags as well
Noooo, the teasing shorts are cruel. Can't wait.
Is this arch linux?
Linux newbie here-How do you get your prompt to look so pretty?
Check out the channel I have a few videos on that
Just set the PS1 variable to what you want it to look like, including escape codes for wanted screen effects, and backslash codes for useful info like current dir, number of running jobs etc. etc.
use kill but press tab after typing the process name, easy
Killall puma
Btop -> presses f -> puma -> presses k
Puma pants
Purrrrrfect
Bro what terminal emulator are you using, as I want it
It's called starship, I'd recommend getting it with fish for the autocompletes
@@darux268 ok, how hard is it moving from bash to fish?
pgrep -f puma
Cleaner and you don't t see your own proc
"pkill puma" do same thing with less typing
Is all linux users named Chris?
I preffer htop for this.
you can just say `pkill puma` to do the same thing.
i prefer to use a flamethrower
instead of having to copy the PID, you could just do it all in one go:
“ps x | grep puma | awk '{print $1}' | xargs kill”
The most things that you really need to know in Linux are man command and -help
Or you can do help , or just help for a list of builtin commands, or apropos to search through the man database for entries containing that search term (entry titles + one line summary, technically), or tldr for a shortened version of a man page with some trivial examples using that command (must install tldr but it's in the main repos IIRC), or . . . well, I've gone on long enough.
Or u can use pkill puma
Use pkill instead
pedantic ass here:
Is pipe actually a command? It's just a way of redirecting a datastream, no?
pkill
ps -fea | grep explorer.exe
taskkill -im explorer.exe
@@BrknSoul windows virgin
On windows u can use task list and task kill
pidof
Old trick
Task manager is so much easier
bruh 💀💀💀💀💀💀💀
Yea, I prefer my taskmanager 😅
Using 'xargs' would be better!
Or I can use a GUI application and not waste 3 minutes of my life or better yet have Kill bound to a macro.
killall -9 puma
kill $(lsof -ti 3000)
`ps aux | awk '/puma/ {print $2}' | xargs kill`
$($(which find) /usr/bin -name *system*monitor)&
Thank me later.
This will run whichever program under /usr/bin that matches the search . Looks like you are trying to trick people into running something they don't want .
I consider all such obfuscated auto-run tricks as dangerous and potentially malicious .
@@johndododoe1411 😂