Reprinted from http://blog.csdn.net/chenjieb520/article/details/7316268
I recently used a package (libpcap) when developing a project. This package can be used for underlying parsing of network streams, but when I want to use this package for network sniffing, the root permission is required and sudo is often used to run the program. In order to facilitate project debugging, the current user is promoted to the root permission.
The method for upgrading is as follows: Enter sudo gedit/etc/passwd in shell to modify the id value of the current user. For example, my current user is chenjieb.
Then you can find chenjieb: X: 1000: 1000: Administrator,:/home. chenjieb:/bin/bash and change the two 1000 values to 0. The final result is:
Chenjieb: X: 0: 0: Administrator,:/home. chenjieb:/bin/Bash: At last, the system is logged out. Then, enter your username and password in the username to log in. In this way, the root permission is obtained. This is because the root ID is 0.
Note: It is best to use the root permission to modify the file. Otherwise, the modification may fail.
I hope this tips will help you.