Hot answers tagged

14

SSH starts a login shell. su, by default does not. In particular, this means that the ~/.profile (or similar file) for that user is not sourced. So changes made in ~/.profile won't take effect. It might also be the case that: even if you start a login shell, different changes were made in root's ~/.profile, which might pollute the user's environment. /...


6

Running commands with sudo is inherently dangerous because of the rights that come with it; therefore use it judiciously and with care. The best way to stop bad things happening is to think twice and act once.


6

First of all, never edit /etc/sudoers manually, always use visudo. Your problem was a syntax error in the file /etc/sudoers.d/90-cloudimg-ubuntu but it is now a malformed /etc/sudoers. So, to fix it (now that you have removed any changes you may have made), run pkexec visudo and make the file look like this: # # This file MUST be edited with the 'visudo' ...


5

Put the following into /usr/bin/dd: if [[ "$*" != *"of=/dev/sda"* ]]; then /bin/dd "$*" else echo "You are not allowed to set dd output to /dev/sda!" fi NOTE: If, in case, you ever need to actually use dd on /dev/sda, use sudo /bin/dd [Arguments for dd] To downvoters: The issue pointed out by @Gilles (Thanks!) has been fixed now, no need to ...


5

What does the root and # mean in the second command line tag? It means you edit the system as "root". That is 1 more level up than from "sudo" and 1 more up from your normal users activities ... what does this mode allow you to do ... and (almost) all permissions checks are neglected. So if want you can seriously destroy your system with a single ...


4

The only way to undo that would be a tedious by hand process for which you would need to know all the files original permissions. Save yourself the headache, Use a live USB/CD in conjunction with an external drive to backup your /home folder and do a clean fresh install.


4

Instead of doing su root, you should use sudo instead, as the root account is not enabled by default in Ubuntu, and will not work. This is why you are getting an "Authentication failure" message. Regarding password entry - it won't show you anything as you type, but, it will accept your password after you press enter. Make sure you entered the right ...


3

sudo sanitizes the environment before running any command. In doing so, if the value of the directive secure_path is set, it will be used as the PATH for the sudo commands, not the current PATH. In my system: % sudo grep -E 'secure_path' /etc/sudoers Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" So i have: % echo ...


3

It is a design feature that since 16.04 you do no longer need root privileges to shut down or reboot the system through any method. Instead the systemd and its systemctl tool accept those commands from regular users. All related commands like shutdown, reboot, halt, poweroff are symbolic links ("symlinks") to /bin/systemctl and init is a symlink to /lib/...


2

Replace sudo with gksudo -- in your script, like this: gksudo -- sh -c "sync; echo 3 > /proc/sys/vm/drop_caches" That will open a simple dialogue window to ask for your password instead of prompting you for it on STDERR which is not connected to a terminal if you run the script from your desktop. On newer releases of Ubuntu, gksudo might not be ...


2

In order to fix this, you can either reinstall sudo, or download a default /etc/sudoers and edit it. Both ways require these steps: First, restart your computer. When the Grub screen displays, instead of choosing Ubuntu xxx, choose Advanced options for Ubuntu xxx. Under Advanced Options, choose Recovery mode. The second step is to mount your partitions rw. ...


2

Maybe there is something wrong in your host file. You can read it by using. cat /etc/hosts EDIT: it has to match your /etc/hostname


2

I solved the problem by going to All Setting > Details > Device Name changed the device name to kaushal Just make sure that your /etc/hostname file has only your machine name.For my case it was kaushal


1

You're correct that root has all privileges, but saying that sudoers have all privileges is not quite correct. They are allowed to attain all privileges by using sudo to run a command as root. That includes running a root prompt, using a command like sudo -i. root is not a sudoer because it is already root - it doesn't need to become root to run commands.


1

The error message sudo: /etc/sudoers is owned by uid 1000, should be 0 means you should change the ownership of /etc/sudoers from you to root. You cannot run sudo until it's fixed. Can you boot to single-user mode, mount / r/w, then chown -R root /etc/sudoers I didn't use sudo because single-user mode is already root (UID 0). I used the -R to affect /etc/...


1

I will answer your question specifically In your /etc/hosts for localhost change 127.0.0.1 kaushal to 127.0.1.1 localhost localhost.localdomain kaushal


1

You had a NOPASSWD rule applied to your user in some file in /etc/sudoers.d. Use sudo grep NOPASSWD /etc/sudoers.d -R to find out which. Your /etc/sudoers is not the default, however. The default sudoers can be obtained by looking at the sudo package: $ apt-get download sudo Get:1 http://mirror.cse.iitk.ac.in/ubuntu xenial-updates/main amd64 sudo amd64 1.8....


1

Edit your sudoers file using sudo visudo. Find this line: Defaults env_reset and change it to this: Defaults env_reset,timestamp_timeout=0 This forces sudo to ask for a password every time your run it.


1

No, this line is not a valid line in /etc/apt/sources.list. Just remove it.


1

cannot create regular file ‘/var/student’: Permission denied "/var" and/or "/var/student" is owned by "root" or another user than you are using to copy the file or "student" does not exist. Make sure "student" is a directory and exists. If it does not the system will try to copy a file into "/var" and name it "student" or replace the file and you need ...


1

You might want to learn to use ddrescue. Enable the univers-repository (if you haven't allready) and install it with: sudo apt-get install gddrescue Using ddrescue is much less error prone and thus less dangerous. Also it features neat things like a progress bar.


1

Login with root (su) and run the following command chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo


1

Nice one-liner to remove sudo prompts for the current user sudo bash -c 'echo "$(logname) ALL=(ALL:ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'



Only top voted, non community-wiki answers of a minimum length are eligible