Sudo apt-get install in terminal asking for password - gcp-ai-platform-notebook

I'm using the AI Platform notebook and I want to install cuda because the Tensorflow can't use GPU.
sudo apt-get install cuda-cudart-10-0
Then in the command line it's asking me for password.
(base) jupyter#cuda-10-1-20201008-115420:~/tutorials/stylegan2$ sudo apt-get install cuda-cudart-10-0
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for jupyter:
Sorry, try again.
I don't recall I gave it any password while setting it up. Is there a default password for it?

To answer the first question, our Notebooks provide TensorFlow and when you create it, you can select to install Nvidia Driver automatically. Probably this option was missed during instance creation.
With respect to the second question, from the output, seems to be that you are in Jupyter Terminal.
Jupyter Notebooks provides access to Instance OS which could be Debian 9/10 or we support Ubuntu now. Jupyter Terminal process is running as jupyter user. While you can still run process as root. I would suggest you that you login via SSH and run commands directly from there. If you create the Notebook via UI we now provide OS login feature which allows you to access instance via SSH with IAM permissions hence your Google Cloud user account. If you are not sure of any of this, please contact your IT admin.

What do you think sudo does? If this is your first time using a Linux system, know that prepending every command in Linux with sudo is same as typing cmd in the windows run box and then pressing shift+enter. sudo is a way to tell the OS that I need admin rights (or in Linux's case, root permissions). So, it is bound to ask you for the password.
The password it is asking for is your account password. Also, it is usually a good idea to set up the root password when in first use. To set it up, drop into the root prompt from your user account using sudo su. Then type in passwd to set up a new password for the root user. Log out, and restart the machine.
Do not forget that root account has the ultimate privileges, and unless absolutely necessary, it is always better to prepend the command with sudo instead of dropping into the root prompt.
PS: A hint: sudo <command> followed by the caller's password is same as su -c '<command>' followed by the root account's password
You also might want to take a look at fakeroot

Which linux distro are you on? Like Kali has default password as root or toor or kali depending on version

Related

How to start anaconda-navigator with root Privileges ? (Linux)

After starting "anaconda-navigator" with a terminal, it ends up with dialogue box prompting that " it can't be run with root privileges.anaconda-navigator startup error as root.
For anaconda-3 run:
source ~/anaconda3/bin/activate root
anaconda-navigator
Hopefully this will solve everything.
I have exactly the same issue that you have and after trying the shocking solutions provided i ended up with more errors as you can find in some of my comments there.
How to Fix this:
The dialogue box as you and I see it, is a common dialogue in the Linux world, it has only one reason and that is your GUI is logged with a "normal user" but somehow you managed to install the anaconda with superuser(root).
so if possible, head to your login section and login with root user + with GUI activated(only saying this because there's a big Linux world out there)
if this didn't help, re-install it but be careful when uninstalling it as python can mess a lot of things up(its an OS bomb actually).
How to prevent this:
1- do not allow Anaconda installation to use any superuser areas like /root
2- try to install it with normal user and with sudo command
Good luck (the thing we all need with python installers)
The installation process should be done with the regular user but no root. In my case, the problem appears when I installed with superuser session. I follow these instructions, installing just with my username (without sudo privileges) and the problem was solved.
In /home/user/anaconda3/lib/python3.7/site-packages/anaconda_navigator/app/start.py:
if (MAC or LINUX) and os.environ.get('SUDO_UID', None) is not None:

Is there a way to 'store' Sudo temporarily

I'm quite new to Linux. I remember using a tutorial were you were able to declare your sudo (+password) at the start and then use terminal without having to do sudo or import your password again.
I.e.
Sudo yum-get update -> yum-get update.
Sorry if this is a very obvious question, I honestly don't remember where the tutorial was from, and how to do it again.
ps - if it helps, I'm on a RedHat Distro, but go between Debian and RedHat.
You can use su. This way you are changing the ownership of the session to root (by default, you can also change to any other user on the system) and therefore you will be able to avoid the sudo.
Here you can find some more information on the command.
You may use
sudo -i
It acquires the root user's environment and kind of simulates a login into the root account

How to run chromium browser as a normal user?

When I try to start chromium I get this:
Please start Chromium as a normal user. If you have previously run Chromium as a root, you will need to change the ownership of your profile directory.
I searched for it, but found articles only like run chromium as a root. I use linux (Ubuntu) not a long time, that I need a help.
Addition If I add new normal user, how can I run chromium from root like them?
You can run Chromium with an argument from the command line like this
chromium --user-data-dir=/foo/bar
This will enable you to run it as root. This is not advised though for security reasons.
If by running as a normal user you mean execute the command as someone else, you can just do
su - username -c "chromium --user-data-dir=/foo/bar"
if you need to use the user's settings, then the path(user-data-dir) should point to them.
If username and password is already set in your Linux System then, answer by #Dropout is perfect.
If there is no password set and you want to run as a normal user, you can just do
su -c "chromium --user-data-dir=/foo/bar"
This will allow you to open Chromium when you don't have a password defined in your Linux System

How to log in into the linux terminal as ROOT user using ruby script

I want to run a script on remote server using SSH.
I have write all the code which runs properly using system command.
To run my code on remote server I need some packages which I need to install on remote server.
To do so I need login into remote terminal as a ROOT user. When I try to do using Ruby script so I get something like following
[not_root_user#remote_server]$ su
Password:
I need some command using which I can able to login into the remote server something like following
[not_root_user#remote_server]$ su -p ******
[root#remote_server]#
Is there any linux command which accepts the password in it?
So you want your script to act as root?
It's not really recommended, but you can use expect: http://en.wikipedia.org/wiki/Expect
The wiki there has a walkthrough for a basic automated telnet session that you could adapt to your needs.
However, you're going to have your root password in plain text, which could be a security issue. If you go that route, I'd definitely obliterate all copies of that script from the universe once this package is installed.
But if you're allowing direct root logins, you've already got a bit of a security problem. Sudo works out-of-the-box on every modern linux distro I've used, I'd stick with that, if possible.
Another option which is equally tasteless would be to set up root-to-root login without a password via ssh.
Sudo would be my first option to getting around this. Although not the best option.
You can also use Key authentication with SSH, and if password authentication is turned off there is no need to enter a password.

Best way elevate the privileges programmatically under different versions of Linux?

There is a standard way (working across Linux distributions) to launch a process (from another application) asking for the root password in order to elevate privileges?
I tried to use gksudo (it is installed in ubuntu by default), but under other distributions (or under other desktop manager) it may not be installed.
I would recommend looking at PolicyKit which is what most modern distros are using to accomplish this.
That works everywhere but does not cache the password and asks for the root and not the user password (as sudo does):
su - -c command
EDIT: Not on ubuntu where the root-account is disabled. Probably you need something like that:
test -x /usr/bin/sudo && sudo command || su - -c command
The only default thing is text mode su. Most distros have also sudo installed.
Now, in KDE based distros you'll have kdesu, while in GNOME based it'll be gksu and gksudo. Machines in Kerberized domains have ksu.
You might try to use /etc/sysconfig/desktop to see which is the default desktop.
Traditionally, if your application needs to allow a user to elevate privileges, it installs its own single-purpose setuid executable -- single-purpose meaning that it performs the task needed, instead of acting as a general-purpose launcher.
$ su -
# cp `type -p id` /usr/local/bin/root-id
# chown root:users /usr/local/bin/root-id
# chmod 4750 /usr/local/bin/root-id
$ /usr/local/bin/root-id
... euid=0(root) ...
OTOH setuid executables have also been a common source of security holes too, so exercise care.

Resources