8

Don't try this command.

While I'm trying to purge the package login, the package manager 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?

0

5 Answers 5

11

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! -  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 ...

Congratulations, now you can no longer login to your system.

5
  • 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, 2014 at 5:36
  • Some commands like command > /dev/sda1 do not require even sudo. Mar 19, 2014 at 5:55
  • 3
    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, 2014 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, 2014 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, 2014 at 10:19
9

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

4

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.

2

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.

1

Removing login would make it impossible for you to login normally, so don't remove this package. Instead, look in /var/log/apt/history.log to see which packages you have installed and removed that led to this situation, and carefully reverse every action. By "carefully" I mean using the --simulate option without sudo to test apt or apt-get commands without actually making any changes to your system.

For example instead of running this command:

sudo apt remove package1 package2 package3 

Simulate the above command without sudo like this:

apt remove --simulate package1 package2 package3

You can also use the --simulate option to simulate installing and removing manually downloaded .deb packages. To simulate the installation of a .deb file named FILE.deb change directories using cd to the directory that contains FILE.deb and run the following command:

apt install --simulate ./FILE.deb

If there are any unmet dependencies that are required to install FILE.deb the above command will list them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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