Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Don't try this command.

While i'm trying to purge the package login, terminal asks me to enter the whole text rather than [Y/n].

avinash@avinash-VirtualBox:~$ sudo apt-get purge login
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  login*
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  login
0 upgraded, 0 newly installed, 1 to remove and 303 not upgraded.
After this operation, 1,212 kB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
 ?] 

Why it prompts me to enter the whole Yes, do as I say! text? What will happen if i enter Y or Yes?

share|improve this question
1  
Let's be precise. The "terminal" is not asking you anything. apt-get is presenting you with a strict fail-safe check because you are asking to purge an essential package. –  chaskes Mar 19 at 6:30
add comment

4 Answers 4

up vote 3 down vote accepted

login package consists of programs such as login,newgrp and su.These programs are also called system login tools.These tools are required to be able to login and use your system.

  • The login program invokes your user shell and enables command execution.

  • The newgrp program is used to change your effective group ID (useful for workgroup type situations).

  • The su program allows changing your effective user ID (useful being able to execute commands as another user).

This is an essential system package.So that the Warning message(This should NOT be done unless you know exactly what you are doing!) like below appears and asks you to enter the whole phrase Yes, do as I say!, while you trying to purge the package login

This should NOT be done unless you know exactly what you are doing!
      login
0 upgraded, 0 newly installed, 1 to remove and 303 not upgraded.
After this operation, 1,212 kB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
?] 

What will happen if i enter Y or Yes?

You have to enter correct phrase Yes, do as I say!, so that the package login will be removed.If you enter Y or Yes, it will abort the process of purging the package.Even the exclamatory mark,spaces,upper and lowercase letters are considered strictly.

Yes  -  Abort
Yes, do as I say  -  Abort
yes, do as I say  -  Abort
Yes, do as I say  -  Abort
Yes,do as I say!  -  Abort
Yes, do as I say! -  Success

After you successfully entered the phrase, dpkg removes the login package with force option enabled,

To continue type in the phrase 'Yes, do as I say!'
 ?] Yes, do as I say!
dpkg: warning: overriding problem because --force enabled:
 This is an essential package - it should not be removed.
(Reading database ... 162860 files and directories currently installed.)
Removing login ...
Purging configuration files for login ...
Processing triggers for man-db ...
share|improve this answer
    
It's strange that some more potentially harmful operations do not implement such protection. For example, sudo rm -rf /* only asks for password (may not ask if you already done something with sudo) then does it's dirty job. –  Danatela Mar 19 at 5:36
    
Some commands like command > /dev/sda1 do not require even sudo. –  Registered User Mar 19 at 5:55
1  
Not that strange. apt-get is intended as "an allout cover for dpkg implementing a safer front-end". Its purpose is to protect you from that kind of mistake. The purpose of most other programs is to do what you tell them without bugging you. It's up to you to know how to use a program and be careful. Plus, many progs like rm include safer options if you choose to use them. Use dpkg directly to do this purge and you won't see such a severe check. –  chaskes Mar 19 at 6:23
    
@Danatela Actually, in most rm implementations, it won't allow you to operate recursively on root. GNU rm requires you to use the --no-preserve-root option to successfully run sudo rm -rf /*. –  vurp0 Mar 19 at 9:24
    
@danatela there is a difference between apt-get and typing a command. The last one has options too to prevent harm. Besides vurp0's comment I as an admin always alias rm -rf (but that I consider an admin task not something a system should enforce) –  Rinzwind Mar 19 at 10:19
add comment

The clue is in the prompt

The following essential packages will be removed

apt has a special classification for packages deemed so important that without them, your system would be broken. You can remove them but apt wants to make double-sure you're not going to blame it afterwards.

You can see the installed essential packages with aptitude search '~E~i' which currently (on a 13.10 box) gives the following packages:

apt base-files base-passwd bash bsdutils coreutils dash debianutils diffutils dpkg e2fsprogs findutils grep gzip hostname libc-bin login mount ncurses-base ncurses-bin perl-base sed tar util-linux

I was curious what commands those might include (I know coreutils is fairly massive), so built the following monster query for f in $(aptitude search '~E~i' | awk '{print $2}' | xargs dpkg -L); do [[ $(type -P "${f##*/}") == "$f" ]] && echo ${f##*/}; done

[ addpart add-shell agetty apt-cache apt-cdrom apt-config apt-get apt-key apt-mark arch badblocks base64 basename bash bashbug blkid blockdev captoinfo cat catchsegv cfdisk chattr chcon chgrp chkdupexe chmod chown chroot chrt cksum clear clear_console cmp comm cp csplit ctrlaltdel cut cytune dash date dd ddate debugfs delpart df diff diff3 dir dircolors dirname dmesg dnsdomainname domainname dpkg dpkg-deb dpkg-divert dpkg-maintscript-helper dpkg-query dpkg-split dpkg-statoverride dpkg-trigger du dumpe2fs e2freefrag e2fsck e2image e2label e2undo e4defrag echo egrep env expand expr factor faillog fallocate false fdformat fdisk fgrep filefrag find findfs findmnt flock fmt fold fsck fsck.cramfs fsck.ext2 fsck.ext3 fsck.ext4 fsck.ext4dev fsck.minix fsfreeze fstrim getconf getent getopt getty grep groups gunzip gzexe gzip head hostid hostname hwclock i386 iconv iconvconfig id infocmp infotocap install install-info installkernel ionice ipcmk ipcrm ipcs ischroot isosize join lastlog ldattach ldconfig ldconfig.real ldd line link linux32 linux64 ln locale localedef logger login logname logsave losetup ls lsattr lsblk lscpu mcookie md5sum md5sum.textutils mkdir mke2fs mkfifo mkfs mkfs.bfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.ext4dev mkfs.minix mklost+found mknod mkswap mktemp more mount mv namei ncurses5-config ncursesw5-config newgrp nice nisdomainname nl nohup nologin nproc od oldfind partx paste pathchk perl perl5.14.2 pg pinky pivot_root pldd pr printenv printf ptx pwd raw rbash readlink readprofile remove-shell rename.ul renice reset resize2fs resizepart rev rgrep rm rmdir rmt-tar rtcwake runcon run-parts savelog script scriptreplay sdiff sed seq setarch setsid setterm sfdisk sg sh sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split start-stop-daemon stat stdbuf stty su sum swaplabel swapoff swapon switch_root sync tabs tac tail tailf tar tarcat taskset tee tempfile test tic timeout toe touch tput tr true truncate tset tsort tty tune2fs tunelp tzselect umount uname uncompress unexpand uniq unlink unshare update-alternatives update-locale update-passwd users validlocale vdir wall wc whereis which who whoami wipefs x86_64 xargs yes ypdomainname zcat zcmp zdiff zdump zegrep zfgrep zforce zgrep zic zless zmore znew

share|improve this answer
add comment

The packages has several fields that are filled with information, one of these fields state the importance of the package, which is called priority. There are two priorities given to packages that without them you don't get a functional system, which are essential and required.

These packages gets installed by default in all Ubuntu/Debian installations. Whenever you try to remove them the installer ask you to spell out that you are sure, so you understand the consequences of your actions. So if you continue with the removal is highly likely that some part of the system gets utterly broken that you can't boot anymore.


To get the list of the packages that has these priorities, I recommend the use of aptitude:

aptitude search ~prequired
aptitude search ~pimportant

Or, in case you like synaptic, you should select to show packages priorities.

share|improve this answer
add comment

You are using apt-get to do the purge. apt-get is a command line utility provided by the apt package.

Its stated purpose (found in the source code) is:

apt-get - Cover for dpkg
This is an allout cover for dpkg implementing a safer front end.

In other words, apt-get implements safety checks that other utilities that interact with the package manager may not provide.

Most requested commands will list the affected packages and other information related to the requested transaction and will then be followed by a simple confirmation message:

Do you want to continue [Y/n]?

But if it sees that packages defined in the package manager with essential priority are about to be removed, it follows the package list with this warning:

WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!

It then replaces the standard continuation prompt with a stricter prompt that cannot be confirmed by accident since the answer must match the prompt character for character:

You are about to do something potentially harmful.
To continue type in the phrase "Yes, do as I say!"

apt-get will then allow the transaction to go through to apt, which in turn interacts with dpkg.

It is important to note that the behavior noted in this question is coming solely from apt-get and that, again, apt-get's stated purpose is to provide this kind of safety layer.

It is possible to purge packages through other utilities such as aptitude, synaptic, or dpkg; but the level of protection provided by these other utilities will likely be different.

share|improve this answer
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.