1. Why you don’t have a root password
While you can create a password for the superuser account allowing you to log in as root with su
, it’s worth mentioning that this isn’t the “Ubuntu” way of doing things. Ubuntu have specifically chosen _not_to give a root login and password by default for a reason. Instead, a default Ubuntu install will use sudo
.
Sudo is an alternative to giving people a root password in order to perform superuser duties. In a default Ubuntu install the person who installed the OS is given “sudo” permission by default.
Anybody with “sudo” permission may perform something “as a superuser” by pre-pending sudo
to their command. For instance, to run apt-get dist-upgrade
as a superuser, you could use:
sudo apt-get dist-upgrade
1 |
|
su
apt-get dist-upgrade
exit
1 |
|
sudo su
1 |
|
sudo: /var/lib/sudo writable by non-owner (040777), should be mode 0700
1 |
|
sudo chmod 777 -R foobs
When manipulating files within your home directory, in this case in ~/Desktop
, you should not have to use sudo
. All the files you create in your home directory should be modifiable by you anyway (and if not, something funny is going on).
Also, you need to be fully aware of the consequences of changing file permissions en masse, such as doing it recursively or on a huge number of files. In this case, you’re changing carefully set up file permissions to be world-writable. Any other user, or any buggy server software on the machine, may have easy access to overwrite all of these files and directories.
It’s almost certain that chmod 777 -R [dir]
it is not an appropriate solution for whatever problem you were trying to solve (and as I mentioned above, there is evidence that you have done it to system files in /var/lib too, and I assume to lots of other places).
A couple of basic rules of thumb:
If you’re just messing with your own files in your home directory, desktop etc, you should never need to use
sudo
or superuser rights. If you do, it’s a warning sign that you’re doing something wrong.
You should never manually modify system files owned by packages. Exception: unless you’re doing it specifically in ways documented by those packages, such as by modifying their configuration in /etc
. This applies also to changing file permissions. If a tutorial or attempt to fix the problem requires sudo
or superuser rights, and it’s not simply a change to a configuration in /etc/, it’s a warning sign that you’re doing something wrong.
原文链接:http://askubuntu.com/questions/444246/why-dont-i-have-a-password-for-su-problems-with-sudo