LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-29-2012, 07:14 AM   #1
prasanth.george
LQ Newbie
 
Registered: Jan 2011
Location: bangalore
Distribution: rhel,ubuntu,centos
Posts: 27

Rep: Reputation: 0
/etc/inittab modification


Goodevening,

How to modify ca::ctrlaltdel:/sbin/shutdown -t3 -r now
in such a way that it should prompt me for a confirmation before going for a restart?
 
Old 09-29-2012, 10:12 PM   #2
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Jessie
Posts: 592

Rep: Reputation: 119Reputation: 119
I do not think it can be done directly with the shutdown command. One way would be to do it in a script. Something like:
Code:
#! /bin/bash

read -p "Are you sure you want to shutdown [yes/no]?
if [ $REPLY = "yes" ]; then
  /sbin/shutdown -t3 -r now &
  exit 0
fi
Make it executable with owner root:root.

Then modify /etc/inittab to point to this script:
Code:
ca::ctrlaltdel:/path/to/script
Hope it helps.
 
Old 10-03-2012, 02:57 AM   #3
prasanth.george
LQ Newbie
 
Registered: Jan 2011
Location: bangalore
Distribution: rhel,ubuntu,centos
Posts: 27

Original Poster
Rep: Reputation: 0
thanks for the help
 
Old 10-04-2012, 02:13 PM   #4
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
Question

Somehow, this is different now in Fedora 17. Check out the inittab. What do you think?

Code:
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To set a default target, run:
#
# ln -s /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
#


---------- Post added 10-04-12 at 01:13 PM ----------

Somehow, this is different now in Fedora 17. Check out the inittab. What do you think?

Code:
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To set a default target, run:
#
# ln -s /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
#
 
Old 10-05-2012, 07:17 PM   #5
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Jessie
Posts: 592

Rep: Reputation: 119Reputation: 119
Fedora now uses systemd instead of the System V init. I looked at F16 but could not find any /etc/systemd/system/ctrl-alt-del.target.

Could you post the contents from your system?
 
Old 10-05-2012, 09:32 PM   #6
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
I don't see it either. This is my directory.
Code:
# pwd
/etc/systemd/system
# ls -al
total 44
drwxr-xr-x. 11 root root 4096 Jun 26 06:01 .
drwxr-xr-x.  4 root root 4096 Sep 22 06:50 ..
drwxr-xr-x.  2 root root 4096 May 22 15:40 basic.target.wants
drwxr-xr-x.  2 root root 4096 May 22 15:41 bluetooth.target.wants
lrwxrwxrwx.  1 root root   41 May 22 15:41 dbus-org.bluez.service -> /usr/lib/systemd/system/bluetooth.service
lrwxrwxrwx.  1 root root   44 May 22 15:40 dbus-org.freedesktop.Avahi.service -> /usr/lib/systemd/system/avahi-daemon.service
lrwxrwxrwx.  1 root root   46 May 22 15:41 dbus-org.freedesktop.NetworkManager.service -> /usr/lib/systemd/system/NetworkManager.service
lrwxrwxrwx.  1 root root   36 Sep 21 22:26 default.target -> /lib/systemd/system/runlevel5.target
drwxr-xr-x.  2 root root 4096 May 22 15:40 default.target.wants
drwxr-xr-x.  2 root root 4096 May 22 15:40 getty.target.wants
drwxr-xr-x.  2 root root 4096 Sep 21 22:29 graphical.target.wants
drwxr-xr-x.  2 root root 4096 Sep 30 08:33 multi-user.target.wants
drwxr-xr-x.  2 root root 4096 May 22 15:41 printer.target.wants
drwxr-xr-x.  2 root root 4096 May 22 15:41 sockets.target.wants
drwxr-xr-x.  2 root root 4096 May 22 15:41 sysinit.target.wants
lrwxrwxrwx.  1 root root   39 May 22 15:40 syslog.service -> /usr/lib/systemd/system/rsyslog.service
#
 
Old 10-08-2012, 07:38 AM   #7
prasanth.george
LQ Newbie
 
Registered: Jan 2011
Location: bangalore
Distribution: rhel,ubuntu,centos
Posts: 27

Original Poster
Rep: Reputation: 0
Thumbs up

the script is running fine with the direct execution but when i point the script location to /etc/inititab
ca::ctrlaltdel:/usr/bin/prompt.sh
-rwxr-xr-x 1 root root 146 Oct 5 16:59 /usr/bin/prompt.sh
$PATH
bash: /usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/george/bin:

when C-A-D is pressed ,its prompting for the question, it hangs most often ,sometimes allows me to give yes or no answer.

Thanks,
Prasanth


Quote:
Originally Posted by towheedm View Post
I do not think it can be done directly with the shutdown command. One way would be to do it in a script. Something like:
Code:
#! /bin/bash

read -p "Are you sure you want to shutdown [yes/no]?
if [ $REPLY = "yes" ]; then
  /sbin/shutdown -t3 -r now &
  exit 0
fi
Make it executable with owner root:root.

Then modify /etc/inittab to point to this script:
Code:
ca::ctrlaltdel:/path/to/script
Hope it helps.
 
Old 10-08-2012, 01:38 PM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,957

Rep: Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267Reputation: 1267
Quote:
Originally Posted by prasanth.george View Post
the script is running fine with the direct execution but when i point the script location to /etc/inititab
ca::ctrlaltdel:/usr/bin/prompt.sh
-rwxr-xr-x 1 root root 146 Oct 5 16:59 /usr/bin/prompt.sh
$PATH
bash: /usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/george/bin:

when C-A-D is pressed ,its prompting for the question, it hangs most often ,sometimes allows me to give yes or no answer.
The most likely cause is that more than one process is trying to read from the keyboard, and there is no way to control which process receives any particular keystroke. In a GUI environment the way to handle that is to pop up an alert window and grab the input focus. There's probably some way to do the equivalent in a non-GUI session, but that's not something I'm familiar with.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
since we have no /etc/inittab scrupul0us Ubuntu 19 12-09-2010 05:54 PM
/etc/inittab cybersam45 Linux - Newbie 6 04-21-2009 07:29 AM
About /etc/inittab zaxonus Linux - General 3 06-04-2007 07:01 AM
rc[0-6] and inittab kpachopoulos Linux - General 1 08-12-2005 05:27 PM
Cant get out of inittab InEeDhElPlInUx Linux - Newbie 3 10-09-2003 03:13 PM


All times are GMT -5. The time now is 04:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration