Tag Info

Hot answers tagged

7

The pgrep command, and its sibling pkill, exists precisely for this purpose: pgrep firefox will list all processes whose commands match firefox pgrep -f firefox will list all processes whose entire command lines match firefox pgrep -x firefox will list all processes whose commands exactly match firefox ... and so on. And naturally, pgrep will exclude ...


6

ps -fC process-name example: ps -fC firefox from man ps -C cmdlist Select by command name. This selects the processes whose executable name is given in cmdlist. -f Do full-format listing. This option can be combined with many other UNIX-style options to add ...


4

You can't. Not without killing the whole process. From man 3 pthread_kill, a function used for signal handling: NOTES Signal dispositions are process-wide: if a signal handler is installed, the handler will be invoked in the thread thread, but if the disposition of the signal is "stop", "continue", or "terminate", this action will ...


3

You're on the right track: I would also have one user watching the other. If top doesn't give you the output you want I would use ps aux in an infinite loop with a 1 second delay. #!/bin/bash # Example script for watching a logging off user # This script is an answer to ...


3

Use pkill: pkill node This would match the other command as well, so fine tune it: pkill -f "node --harmony app.js" This matches the full command line (-f) exactly, so it should only hit the desired command.


3

This answer by Radu gives you a complete overview of how to execute particular script upon logout or shutdown. What you can do is create the script like this #!/bin/bash ps -u username > /home/yourusername/outputfile.txt Then sudo chmod +x scriptname and add line session-cleanup-script=/path/to/script to /etc/lightdm/lightdm.conf As for shutdown . ...


3

require authentication for all changes to that file (even as root) I have a feeling that this is not possible. Definitely not completely waterproof. The superuser is God on the system. To monitor a file or folder, you can use the following command: sudo apt-get install auditd # if not already installed sudo auditctl -w <path_to_file> -p w ...


2

It is not Ubuntu that does this. It is the Linux kernel that does this. Wikipedia has a topic on this: Out of memory (OOM) is an often undesired state of computer operation where no additional memory can be allocated for use by programs or the operating system. Such a system will be unable to load any additional programs, and since many programs may ...


2

You can use killall. The simplest syntax is: killall "Process_name" In you case: killall "node --harmony app.js" The upside of killall is that it will match the exact name so there is no chance of killing other processes unwantedly. Although you can use -r option to express the process as a regular expression pattern like pkill. Check man killall ...


1

Use an alias and your own "command word" for it. E.G.go to your home Dir and create the file .bash_aliases Put the following text into the file alias nerdalert='pkill -f "node --harmony app.js"' and then search in your home folder for your .bashrc looking for this part and make sure it's not commented out. # Alias definitions. # You may want to put all ...


1

Use the following to list all the processes of any particular user: $ ps -fu "username" For example: $ ps -fu foobar To save it in a file: $ ps -fu foobar > ~/ps_foobar Here is a one liner that can be used via cron or any other repitition mechanism: [[ $(ps -u foobar | wc -l) -gt 1 ]] && echo "user foobar has process running" || echo ...


1

You can run htop from one of the tty consoles so that you can log a user out of an xsession but still maintain an open terminal (htop is better than top and easier to read). CTRL + ALT + F2 You can login a text session under a different username from there and then, use: sudo htop to start it up. Use F6 and then scroll up to USER using the arrow button ...


1

You have written: If a process is running how can I find its disk path using command on terminal ? In my case a process synergy is running and I want to locate it on disk Open a terminal and run the following commands, depending on how you want to proceed. I use synergy because you mentioned it: If you really want to use ps, then you can use this ...


1

If you know the PID of the process, you can examine the contents of its /proc entry, in particular, the exe file: $ ls -l /proc/$$/exe lrwxrwxrwx 1 muru muru 0 Apr 17 19:41 /proc/13339/exe -> /usr/bin/zsh $ sudo ls -l /proc/1/exe lrwxrwxrwx 1 root root 0 Apr 17 17:40 /proc/1/exe -> /usr/lib/systemd/systemd IIRC what ps -ef reports are the ...


1

Setting immutable attribute on the file would help preventing any changes to it. As for monitoring - you can probably achieve it in many ways starting with some shell script verifying size, checksum, modification time or whatever else you find useful, ending on some more sophisticated integrity checking solutions like tripwire or whatever currently is ...


1

top allows you to search for string when you hit uppercase L; the process will be highlighted, and use up and down arrow keys to scroll through list of processes. Similarly, htop command allows highlighting a particular process when you hit /. And \ will filter all the processes with a particular string in the name. For those who like awk, here's an awk ...


1

You can also use htop and then hit F4 to filter the results with a matching user-defined string. You also have a custom search feature available by hitting F3.


1

Full screen terminal applications ( think nano ) that are badly written/broken can fail to resume properly in that they don't repaint the screen correctly after its contents changed while the program was suspended. Well behaved applications notice when they have been suspended and resumed and will repaint the screen properly. That's about it.


1

And this is why you shouldn't grep or otherwise parse the output of ps for matching commands, but use tools like pgrep and pidof. When you run ps | grep foo, the grep foo process is also listed by ps - therefore grep foo matches itself along with any other foo processes. The exact same thing happens when you do echo $(ps aux | awk '/firefox/...) - the awk ...


1

As muru already pointed out grep leaves trace of itself in the ps, however, there is a small workaround for using grep with ps : use double quotes and brackets on the first letter like so ps aux | grep "[f]irefox" (Source: http://unix.stackexchange.com/a/74186/85039).



Only top voted, non community-wiki answers of a minimum length are eligible