Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have just installed SLC6 (derived from SL6 derived from RHEL6). I can send a running process to the background by hitting Ctrl-Z in the terminal where it was started. However, I can't do it when I started the command with sudo. It used to work seamlessly in SLC5.

Is there any configuration I could do to allow this ?

EDIT This is an example of command I try to run :

[user@pcald02 ~]$ sudo emacs
^Z^C

The Ctrl-Z makes the symbols ^Z appear but nothing else happens. Now I realized that even Ctrl-C is ineffective.

Without sudo :

[user@pcald02 ~]$ emacs
^Z
[1]+  Stopped                 emacs
[user@pcald02 ~]$ 
share|improve this question
1  
Since slm says it works for him on RHEL/CentOS6, you might want to update the post with the actual command that you're trying to run, in case it's something specific to that one command. –  Joel Davis Jul 2 '13 at 15:58
add comment

3 Answers

up vote 1 down vote accepted

I'm guessing the real problem here is that the command you are trying to run is Emacs. Running Emacs as root is hardly ever a good idea. Emacs also overrides a number of keystrokes, so C-z might not work simply for that reason. If root is already logged in, emacs might start graphically on root's display. Etc, etc.

Look at using the sudo: method from Tramp for editing files using sudo from Emacs. For example, to edit /etc/motd, do C-x C-f and type the path as /sudo:root@localhost:/etc/motd.

share|improve this answer
add comment

CTRL-Z sends signal SIGTSTP to the process.

So the simplest way to do this is:

sudo kill -TSTP <pid>

from another shell.

share|improve this answer
add comment

If I'm understanding your question the following worked just fine for me on CentOS 6.4 which I would expect to be very similar to SLC6:

initital command
$ sudo sleep 300
^Z
[1]+  Stopped                 sudo sleep 300
background
$ bg
[1]+ sudo sleep 300 &

$ jobs
[1]+  Running                 sudo sleep 300 &

$ ps -eaf|grep sudo
root     25752 25669  0 09:53 pts/0    00:00:00 sudo sleep 300
sam      25755 25669  0 09:53 pts/0    00:00:00 grep sudo
kill job (Ctrl+C)
$ fg
sudo sleep 300
^C

$ ps -eaf|grep sudo
sam      25758 25669  0 09:53 pts/0    00:00:00 grep sudo
OS Info
$ uname -a
Linux mungr 2.6.32-358.6.1.el6.x86_64 #1 SMP Tue Apr 23 19:29:00 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/redhat-release 
CentOS release 6.4 (Final)
share|improve this answer
    
What is strange is that the ^Z after the initial command does nothing. –  Barth Jul 2 '13 at 15:27
add comment

Your Answer

 
discard

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.