Just noticed this, I explained it to you in the other thread you created, but for other linux newbies out there, maybe this is going to be useful.
When it says “are you root?” there at the end of the command, it’s not actually asking you the question, it’s a hypothetical/rhetorical question, in the sense of “it failed to the lock the administration directory, probably because you are not root, did you check for that first?”. And then you should see your command prompt again (where it says private@debian:~$
) meaning the previous command is done and now you’re back to the shell (the terminal command interpreter) for you to type the next command. So when you reply here with ‘yes’ what you’re doing is actually to execute the ‘yes’ command, which is why the letter ‘y’ is printed ad infinitum like you said.
there is a linux command called ‘yes’ with the sole purpose of printing ‘y’ indefinitely… this is useful if for example you want to move files and say ‘yes’ to overwrite a lot of them, or you want to run a script that asks a lot of questions and you don’t want to bother and answer yes to everything, you can run ‘yes’ and pipe its output to the input of the new command like this : yes | some_command
and it will write ‘y’ for every prompt the new command asks… you can also do yes n
or yes hello
if you want it to repeatedly print ‘n’ or ‘hello’. Also note, you can stop any command from executing by pressing Control-C, you don’t have to close the terminal to stop it… good to know the next time you accidentally run the yes
command.
Give it a try, play with it and have fun, it will help you get more familiar with the terminal and how it works.
This is an FYI if you’re curious on what happened here…
Here, you typed ‘y’ at the command prompt, after the previous command finished. So what the shell here does is to try and execute the command or program y
but it doesn’t find one, so it tries to see if you made a typo so that if for example you typed aptt-get
it would tell you Command not found. Did you mean apt-get?
to help you see where you made the typo, or if you typed chrome
(no typo), it could tell you Command not found. chrome is available if you install the package google-chrome with apt-get install google-chrome
, etc… (this is just an example, I’m not sure on th exact wording of the sentece, or the name of the commands/package used in this example).
Anyways, to do that, it needs a ‘database’ of all the available commands and all the packages that are not installed and what commands those provide, etc… unfortunately, it didn’t find the database, so it asked you to run the command ‘update-command-not-found’ so it can update its database (this feature is provided by the package ‘command-not-found’ by the way). It didn’t print anything because… I don’t actually know why, maybe it just worked and it doesn’t print anything, or maybe there’s a problem with it not finding where to update its database from so it actually didn’t do anything. Figuring that out is beyond the scope of this thread obviously.
Two things here, first, you only need to type su
, you don’t need to do su login
. That’s because ‘su’ means “switch user”, so you’re basically telling it to "switch to the user named login’ which I don’t think you have a user named ‘login’ in your system. It still asks you for a password then says it’s invalid, instead of saying that the user doesn’t exist, potentially because it doesn’t want to expose to a user whether or not such an account exists on the system. When you type su
without any arguments (without specifying the username to switch to), then it defaults to switching to root.
Second, when you do su
, it asks you for the root password (since you’re switching to the root account), not your user’s password, so you need to enter the root password (which I assume you set up as a different one from your user’s password).
On the other hand, when you do sudo
, it does ask for the user’s password, because it’s a different thing here, it’s not an actual “switch user” but rather a “switch user and do” to execute a single command. Anyone can ‘su’ to a different user if they know that user’s password, but in order to be able to do ‘sudo’, your account needs to have administrator priviledges already, and it’s meant specifically to give users the ability to run root commands without actually knowing the root password.
Finally, another way to achieve this is to do something as simple as : sudo bash
which makes you run the bash command (the Bourne Again Shell). I’ve mentioned the term ‘shell’ to you before, but basically, the “terminal” is just that rectangular black window which interprets your keyboard typing and sends it to the shell and prints to you what the shell tells it to (and it handles word wrapping and resizing of the window and all that), but what you’re thinking of when you think of the terminal is really the SHELL, which is the command interpreter. That program that runs and prints to you the “private@debian:~$” prompt, the one that interprets the up/down arrows to navigate the history of commands typed, etc… that’s the shell. There are many available shells, the most common and popular one being ‘bash’. So when you do sudo bash
you’re basically just executing a new shell as root, which is more or less equivalent to opening a new terminal as root.
See for example my list of processes (which I got with the ps faxu
command) if I open a terminal and run sudo bash
:
kakaroto 2475 0.1 0.6 849836 49400 ? SNsl Jul10 68:13 \_ /usr/libexec/gnome-terminal-server
kakaroto 28768 0.0 0.1 124868 8292 pts/11 SNs Aug06 0:00 | \_ bash
root 19201 0.2 0.1 268304 10000 pts/11 SN 15:24 0:00 | | \_ sudo bash
root 19209 2.3 0.0 120696 5872 pts/11 SN 15:24 0:00 | | \_ bash
root 19241 0.0 0.0 150960 4096 pts/11 RN+ 15:24 0:00 | | \_ ps faxu
You see the gnome-terminal-server process which basically handles all of my terminals then executes ‘bash’ within one of its terminals, then when I do ‘sudo bash’ that command gets executed as root, and it creates a new process ‘bash’ as root, from which I ran the ‘ps faxu’ command.
Alright, this might be a little too advanced, but I prefer to explain to people why rather than just say “use sudo bash” with no explanations on why or how that works… that usually just leads to more errors or questions later.