Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed the latest version of the QtProject so now I can debug C++ code.

While trying to debug for the first time I got this error:

ptrace: Operation not permitted.

Could not attach to the process. Make sure no other debugger traces this process.
Check the settings of
For more details, see /etc/sysctl.d/10-ptrace.conf
share|improve this question

On Ubuntu versions after 10.10 you'll run into this in more related applications, such as QtCreator. It is a security feature of Ubuntu that prevent the debugger to attach to processes not owned by him.

This is filed as a bug #3509 against QtCreator. To work around this issue, do this:

  • temporary solution (won't survive a reboot):

     echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
  • In a file /etc/sysctl.d/10-ptrace.conf (should already exist), change the value of kernel.yama.ptrace_scope to 0 and then reload the configuration: sudo sysctl -p.

I'm explicitly posting the temporary solution, as you probably don't want to keep this feature disabled on a regular machine for security reasons.

share|improve this answer

I had the same problem while running the project in terminal. Just uncheck (or check - run - uncheck if it is for some reason unchecked) the box "Run in terminal" in "Projects" (on the left bar) - "Run" tab - "Run" section.

share|improve this answer
Thanks this worked for me debugging now starts in QTCreators application output. – squarebear Nov 5 '14 at 20:18

You can change gdb capabilities with

sudo setcap cap_sys_ptrace=eip /usr/bin/gdb

man capabilities tells cap_sys_ptrace gives right to

Trace  arbitrary  processes  using ptrace(2); apply get_robust_list(2)
to arbitrary processes; inspect processes using kcmp(2).

See also man cap_from_text.

This is a solution that is not removed by reboot, but it is not completely safe either. I'm open to suggestions how to do this permanently and safely.

share|improve this answer

Just open QtCreator via a Terminal with root permissions; it worked for me.

sudo qtcreator
share|improve this answer
It reveals big security hole. – enedil Jan 27 '15 at 16:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.