Linux Processes

Monitoring Processes with pu*

Sending Signals: How to Suspend and Resume Processes

In the bash terminal I can hit Control+Z to suspend any running process... then I can type fg to resume the process.

Is it possible to suspend a process if I only have it's PID? And if so, what command should I use?


You can use kill to stop the process.

For a polite stop to the process (prefer this for normal use), send SIGTSTP:

kill -TSTP PID

For a hard stop, send SIGSTOP:

kill -STOP PID

Note that if the process you are trying to stop by PID is in your shell's job table, it may remain visible there, but terminated, until the process is fg'd again.

To resume execution of the process, sent SIGCONT:

kill -CONT PID

Unable to Use Package Manager due to exclusive lock Error

Unable to get exclusive lock
  This usually means that another package management application(like apt-get or
  aptitude) is already running. Please close that application first.

You might get away with:

sudo rm /var/lib/dpkg/lock

You can remove the lock but you should be really sure that nothing is currently using the package management system, like automatic updates or the like:

sudo rm -v /var/lib/dpkg/lock-frontend

[...] best followed by:

sudo dpkg --configure -a
apt install -f

Still, that same user advised:

  1. You need sudo rights, so the full command is:

    sudo dpkg --configure -a
  2. Try using console terminal program instead. Make sure that all package managers are closed! Issue the commands:

    sudo apt-get update
    sudo apt-get upgrade

Now, in this case, running sudo dpkg --configure -a revealed that the process holding the lock was (already deleted) /usr/bin/python3.12, with pid 2062 and so on.