Tag Archives: root

[Solved] Forbid root, handle error sudo must be owned by uid 0

1. Using a non root login is an error in sudo

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Processing: After re-logging in
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo

2. Disable root remote login

*** Not disable root login, not root account
#sudo vim/etc/ssh/sshd_config
Find PermitRootLogin yes and change it to no
*** If the reverse is true, restore root remote, find
Find and comment out this line: PermitRootLogin prohibit-password
PermitRootLogin no to yes

** After the change, sudo /etc/init.d/sshd restart, or just reboot and reboot

3. Other accounts join sudo

First switch to root
Execute su and enter the password
vi /etc/sudoers and add XXX (username) to the following
# User privilege specification
	 root   ALL=(ALL:ALL) ALL
	dhbm    ALL=(ALL:ALL) ALL

Setting root password after installation of Ubuntu 20.04 LTS

Environment:

ubuntu 20.04 LTS version

Questions:

How to set root password after installation of ubuntu 20.04 LTS

How: Method.

Use the command line sudo passwd to set the root password

The command line is as follows.

www@ubuntu:~$ sudo passwd
[sudo] password for www:
New password:
Retype new password:
passwd: password updated successfully
www@ubuntu:~$ su root
Password:
root@ubuntu:/home/www#

Description.
[sudo] password for www: enter the password for the current user
New password: Enter the password for root
Retype new password: Confirm the password for root
www@ubuntu:~$ su root Switch to the root user
Password: Enter the password you just set for root
root@ubuntu:/home/www# Successfully switched to the root user

done!

Solutions to Ubuntu forgetting password and root password

The root of Ubuntu is forbidden by default, and the password of root is not required to be set during installation. To use it, just set the password for root, sudo passwd root. If you just forget the password of ordinary users, you can change it with root. If you forget the root password, enter single user mode

Enter single user mode:

1. When booting to grub loading, please wait…, press ESC to enter the Startup menu, select the recovery mode of the corresponding kernel version, and press e to enter the editing state

2. Move the cursor, change “recovery nomodeset” to “rwsingleinit =/bin/bash”, and then press Ctrl + x to enter single user mode

Then we can use the command passwd to change the password

See: root @ (none):/# enter “passwd” immediately

See: enternewunix password: enter “123” immediately

See: retypenewunix password: enter “123” immediately

The new password is 123

4. Enter “reboot” enter! Can also ctraltdel. In short, restart it

1. Start the system. During startup, press ESC or shift key repeatedly until the following interface appears:

Move up and down, select advanced options for Ubuntu (or some versions show advanced options for Ubuntu), and then press’ Enter ‘to enter the following interface

Select Ubuntu, with Linux 4.13.0-38-generic (recovery mode), as follows:

Press the ‘e’ key to enter the interface as follows

Move the cursor through the up and down left and right keys to find the line of Linux/boot /… Ro recovery nomodeset, as shown below

Change ro recovery nomodeset in the figure to quiet splash RW init =/bin/bash, and the result is as follows

Press’ Ctrl + x ‘for a few seconds to enter the interface as follows:

Enter the command passwd as follows

Press “enter”, the interface is as follows:

After entering the password once, press “enter” and press enter to enter the password again. The interface is as follows

After entering the password twice, press the “enter” key, and the interface is as follows:

The password is entered successfully

Restart the computer (if it is a virtual machine, restart the virtual machine), enter the terminal, enter the command Su – the interface is as follows

Enter the password you just set. The interface is as follows

Root permission NPM global installation (- G) will still have insufficient permissions. Please know the parameter unsafe perm

Environmental description

ganiks@ganiks-ubuntu-trusty-64:/ganiks/parse-server$ npm -v
6.5.0
ganiks@ganiks-ubuntu-trusty-64:/ganiks/parse-server$ node -v
v10.15.0

Problem description

Install and deploy parseserver service

root@ganiks-ubuntu-trusty-64:/ganiks/parse-server# npm install -g parse-server mongodb-runner

The first exception was encountered

> [email protected] install /usr/local/lib/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/bcrypt/lib'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/10.15.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/bcrypt/.node-gyp"
gyp WARN install got an error, rolling back install

Complete error information:

> [email protected] install /usr/local/lib/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for [email protected] and [email protected] (node-v64 ABI, glibc) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/bcrypt/lib'
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/10.15.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/bcrypt/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/bcrypt/.node-gyp'
gyp ERR! System Linux 3.13.0-164-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/bcrypt/lib/binding/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/usr/local/lib/node_modules/bcrypt/lib/binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64"
gyp ERR! cwd /usr/local/lib/node_modules/bcrypt
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/usr/local/lib/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/bcrypt/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:962:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
node-pre-gyp ERR! System Linux 3.13.0-164-generic
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/bcrypt/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/bcrypt
node-pre-gyp ERR! node -v v10.15.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/bcrypt/lib/binding/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/usr/local/lib/node_modules/bcrypt/lib/binding --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v64' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-01-17T08_54_06_070Z-debug.log
  

How to Solve

npm install Adding parameters–unsafe-perm

root@ganiks-ubuntu-trusty-64:/ganiks/parse-server# sudo npm install -g parse-server mongodb-runner --unsafe-perm

References

https://github.com/nodejs/node-gyp/issues/454

https://github.com/nfarina/homebridge/issues/405#issuecomment-164803485

If npm detects it is running as root it drops to a non-privileged user which then doesn’t have permissions to write to/root/.node-gyp.

The–unsafe-permoption stops it from changing user.

nvm doesn’t have this problem when not using sudo because it stores everything under the current users’ home directory.

https://docs.npmjs.com/misc/config#unsafe-perm–unsafe-perm

See the official documentation for an explanation

unsafe-perm
Default: false if running as root, true otherwise
Type: Boolean
Set to true to suppress the UID/GID switching when running package scripts.

If set explicitly to false, then installing as a non-root user will fail.

Add:

There is no need to install parse-server globally (-g), install it to the local directory and you will not encounter the problems in this article.

vagrant@ganiks-ubuntu-trusty-64:~/parse-server-advanced$ npm install parse-server
npm WARN deprecated [email protected]: stop using this version

> [email protected] install /home/vagrant/parse-server-advanced/node_modules/bcrypt
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
[bcrypt] Success: "/home/vagrant/parse-server-advanced/node_modules/bcrypt/lib/binding/bcrypt_lib.node" is installed via remote

> [email protected] postinstall /home/vagrant/parse-server-advanced/node_modules/parse-server
> node -p 'require("./postinstall.js")()'


                  1111111111
               1111111111111111
            1111111111111111111111
          11111111111111111111111111
        111111111111111       11111111
       1111111111111             111111
      1111111111111   111111111   111111
      111111111111   11111111111   111111
     1111111111111   11111111111   111111
     1111111111111   1111111111    111111
     1111111111111111111111111    1111111
     11111111                    11111111
      111111         1111111111111111111
      11111   11111  111111111111111111
       11111         11111111111111111
        111111     111111111111111111
          11111111111111111111111111
            1111111111111111111111
              111111111111111111
                  11111111111


        Thanks for installing parse 🙏
  Please consider donating to our open collective
      to help us maintain this package.

  👉 https://opencollective.com/parse-server

added 356 packages from 381 contributors in 51.675s