issue218:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
issue218:c_c [2025/06/29 07:55] – d52fr | issue218:c_c [2025/06/30 07:17] (Version actuelle) – d52fr | ||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
If we look at this screenshot (below), we can see that I have a terminal open and I am running btop and I ran ps. If you want to see which process launched which process, you need to append “f” (so ps -af ; not to be confused with F!). This is not live though; it is a snapshot of what was running when I hit enter. If you hit the ps man page, it will tell you that it accepts unix style options with one dash, BSD style options with no dash, and gnu style with double-dashes. Meaning “almost” anything goes, you can type ps aux or ps -aux and it will work. As a newbie, just remember, this is not the case in other Linux commands. In my early days of using Linux, the only way I knew to get the environment variables was with ps. If you have no idea what I’m talking about, then in your terminal, type: ps e** | If we look at this screenshot (below), we can see that I have a terminal open and I am running btop and I ran ps. If you want to see which process launched which process, you need to append “f” (so ps -af ; not to be confused with F!). This is not live though; it is a snapshot of what was running when I hit enter. If you hit the ps man page, it will tell you that it accepts unix style options with one dash, BSD style options with no dash, and gnu style with double-dashes. Meaning “almost” anything goes, you can type ps aux or ps -aux and it will work. As a newbie, just remember, this is not the case in other Linux commands. In my early days of using Linux, the only way I knew to get the environment variables was with ps. If you have no idea what I’m talking about, then in your terminal, type: ps e** | ||
+ | |||
+ | Dans le dernier numéro, nous avons abordé davantage de paramètres et expliqué pourquoi j'aime ajouter byobu. Mon ami relecteur m'a demandé pourquoi je ne continuais pas et ne faisais pas une présentation de Terminator. Si je dois aborder Terminator et Tilix, je le ferai, mais j'ai l' | ||
+ | |||
+ | Lorsque nous exécutons nos commandes ou nos scripts, ils deviennent des processus dans le shell. Nous pouvons voir les processus en cours d' | ||
+ | |||
+ | La capture d' | ||
+ | |||
**Do not file this away as not helpful; for instance, in the latest MacOS, they have hidden the sandboxd process from the process viewer. (It is what makes older Mac’s slow as treacle flowing down the road as it uses 100% CPU on one of your cores and also heating it up and getting it to choke.) So the only way to kill it now, is to go and find the process ID and kill it in the terminal. | **Do not file this away as not helpful; for instance, in the latest MacOS, they have hidden the sandboxd process from the process viewer. (It is what makes older Mac’s slow as treacle flowing down the road as it uses 100% CPU on one of your cores and also heating it up and getting it to choke.) So the only way to kill it now, is to go and find the process ID and kill it in the terminal. | ||
Ligne 12: | Ligne 19: | ||
The quickest way to find a PID I know of is via ‘pgrep’. Now that you know the long way (and the how), let me do it the short way. If I type: pgrep btop -I just get the PID back, nothing else. Try this yourself on one of your own processes. ** | The quickest way to find a PID I know of is via ‘pgrep’. Now that you know the long way (and the how), let me do it the short way. If I type: pgrep btop -I just get the PID back, nothing else. Try this yourself on one of your own processes. ** | ||
+ | |||
+ | Ne le rangez pas en disant que c'est inutile ; par exemple, dans la dernière version de macOS, le processus sandboxd a été masqué dans l' | ||
+ | |||
+ | J' | ||
+ | |||
+ | Je viens de prendre le top 5, mais vous pouvez clairement voir que mon jeu, ADOM, est au début, ce qui correspond à btop. (Je n'ai tout simplement pas été assez rapide dans ma capture d' | ||
+ | |||
+ | Le moyen le plus rapide de trouver un PID que je connaisse est d' | ||
+ | |||
**OK, once we find the culprit, we can kill it (stab-stab) No? The kill command actually sends a signal to a process. (It sounds a lot less exciting if you put it this way.) Remember we spoke about SIGHUP previously, that is a signal. If we use keyboard shortcuts, like CTRL+C or CTRL+D, it also just sends off a signal and they are numbered. The one we are interested in is SIGKILL with an ID of 9. (Should be 47... don’t you agree?). | **OK, once we find the culprit, we can kill it (stab-stab) No? The kill command actually sends a signal to a process. (It sounds a lot less exciting if you put it this way.) Remember we spoke about SIGHUP previously, that is a signal. If we use keyboard shortcuts, like CTRL+C or CTRL+D, it also just sends off a signal and they are numbered. The one we are interested in is SIGKILL with an ID of 9. (Should be 47... don’t you agree?). | ||
Ligne 20: | Ligne 36: | ||
I always go and look at the PID, just in case there is more than one process running, but if you are confident, you could use the ‘pkill’ command and simply type: pkill btop (SIGTERM by default). If you want to know the PID of the process that pkill just closed, you can specify the -e option. Maybe I’m living in a bubble, but I have never used any of the other options and I don’t think any of you other n00bs will, it is just usually easier with htop.** | I always go and look at the PID, just in case there is more than one process running, but if you are confident, you could use the ‘pkill’ command and simply type: pkill btop (SIGTERM by default). If you want to know the PID of the process that pkill just closed, you can specify the -e option. Maybe I’m living in a bubble, but I have never used any of the other options and I don’t think any of you other n00bs will, it is just usually easier with htop.** | ||
+ | |||
+ | OK, une fois le coupable trouvé, on peut le tuer (coup de poing). Non ? La commande kill envoie en fait un signal à un processus. (Cela paraît beaucoup moins excitant si vous le présentez ainsi.) Rappelez-vous que nous avons parlé de SIGHUP précédemment : | ||
+ | |||
+ | Je sais déjà que mon processus btop a un PID de 2474920, comme vous pouvez le voir dans les captures d' | ||
+ | |||
+ | Et voilà, btop disparaît. « Graceflly » serait l' | ||
+ | |||
+ | Je regarde toujours le PID, au cas où plusieurs processus seraient en cours d' | ||
+ | |||
**But, as I said, in my previous example with the Mac, as the PID keeps changing, one would need to extract the PID before feeding it to the kill command if you were to script it. Now you see why it would be important. Running a script to kill a nasty process is quicker than manually finding and killing it each time. The one we did not talk about is killall. The reason *I like killall is not because video games made me violent, but I can use the -u option to specify a user name and kill only the processes that particular user owns. This is particularly handy on systems with a lot of users. If you are the only user of your system, you would probably not use this option. Killall can work like kill with a PID or like pkill with just the process name. So typing: killall btop -is acceptable. | **But, as I said, in my previous example with the Mac, as the PID keeps changing, one would need to extract the PID before feeding it to the kill command if you were to script it. Now you see why it would be important. Running a script to kill a nasty process is quicker than manually finding and killing it each time. The one we did not talk about is killall. The reason *I like killall is not because video games made me violent, but I can use the -u option to specify a user name and kill only the processes that particular user owns. This is particularly handy on systems with a lot of users. If you are the only user of your system, you would probably not use this option. Killall can work like kill with a PID or like pkill with just the process name. So typing: killall btop -is acceptable. | ||
Ligne 26: | Ligne 51: | ||
If you have any complaints about the violence, misc@fullcirclemagazine.org** | If you have any complaints about the violence, misc@fullcirclemagazine.org** | ||
+ | |||
+ | Mais, comme je l'ai dit dans mon exemple précédent avec Mac, comme le PID change constamment, | ||
+ | |||
+ | Il y a beaucoup de processus qui attendent de mourir. Non, sérieusement, | ||
+ | |||
+ | Si vous avez des plaintes concernant la violence, veuillez contacter misc@fullcirclemagazine.org | ||
issue218/c_c.txt · Dernière modification : 2025/06/30 07:17 de d52fr