`

Debian小问题:sudo不能使用

阅读更多
今天本打算用Debian做负载均衡测试,结果发现:
引用

zlex@localhost:~/Desktop$ sudo apt-get install tomcat6

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 zlex:
zlex is not in the sudoers file.  This incident will be reported.

sudo不能使用?!顿时无语!
Google搜索无数,发现:
xxx is not in the sudoers file.  This incident will be reported.
linux默认没有为当前用户开启sudo权限!
切换到root用户:
su


visudo

实际上是编辑/etc/sudoers文件
zlex    ALL=(ALL) ALL加入其中:
引用


# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL
zlex    ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL


再次执行命令:
引用
zlex@localhost:~/Desktop$ sudo apt-get install tomcat6

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 zlex:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
E: 无法找到软件包 tomcat6


sudo终于可以用了!


有时候我们只需要执行一条root权限的命令也要su到root,是不是有些不方便?这时可以用sudo代替。

补充:
使用visudo命令,移动光标,找到root    ALL=(ALL)       ALL一行,按a,进入append模式,输入your_user_name ALL=(ALL),然后按Esc,再输入:w保存文件,再:q退出。这样就把自己加入了sudo组,可以使用sudo命令了。

如果觉得在sudo的时候输入密码麻烦,把刚才的输入换成your_user_name ALL=(ALL)NOPASSWD: ALL


有的时候需要使用到一些服务,譬如使用service命令,启动一些服务,可以这样做:
vim .bashrc

引用
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
export PATH=$PATH:/sbin;

注意加入最后一行export PATH=$PATH:/sbin;,就可以使用/sbin/service了!
3
0
分享到:
评论
6 楼 calvinlyc 2010-09-04  
好像通过把user 加入wheel group也可以实现的 不过我不确定
5 楼 fengsage 2010-08-27  
不错~ 我也纳闷为什么sudo从来都没成功过
4 楼 snowolf 2010-08-27  
daerqwert 写道
引用
sudo apt-get install tomcat6 
  居然还这样安装tomcat!!!

何止,我还这样装apache2!
3 楼 daerqwert 2010-08-27  
引用
sudo apt-get install tomcat6 
  居然还这样安装tomcat!!!
2 楼 snowolf 2010-08-27  
renpeng301 写道
博主这样zlex    ALL=(ALL) ALL  这样是不是吧zlex 账号设置默认成了拥有root的所有权限????

嗯,前提是通过sudo命令操作!
1 楼 renpeng301 2010-08-27  
博主这样zlex    ALL=(ALL) ALL  这样是不是吧zlex 账号设置默认成了拥有root的所有权限????

相关推荐

    debian安装后sudo命令不能用的解决方法

    debian安装完之后发现sudo命令不能用 找了半天发现是没有安装sudo 得了,进入root安包,炸开他,apt-get install sudo 安装完发现又出现一堆怪问题 不管他,继续前进 在root设置sudoers配制文件 代码如下:chmod +w ...

    Debian如何限制sudo权限

    能学到什么:设置普通用户执行sudo的权限,使其只能执行指定的命令。 用户使用su命令切换root。但是权限太大,而且root密码有泄露风险。那么能否在不泄露root密码的前提下对权限进行限制呢?答案就是用sudo。 sudo...

    popura-debian-repo:Debian Popura仓库

    Debian Popura仓库要使用该Debian存储库: sudo apt install -y wget apt-transport-httpssudo wget -O /usr/share/keyrings/popura-archive-keyring.gpg ...[signed-by=/usr/share/keyrings/popura-archive-keyring....

    debian-cd:创建一张 Debian CD,使用 di preseeding 在 VM 中自动安装

    debian-CD 首先安装 simple-cdd 包: sudo apt-get install simple-cdd 然后运行以下命令为 CD 构建 ISO 映像: build-simple-cdd --profiles base,vm --auto-profiles base,vm --dist wheezy 输出文件images/...

    debian-clang:使用 sbuild 使用 Clang 构建和修复 Debian 软件包

    使用 Clang 测试构建 debian 包 配置 使用 更改 sbuild 配置,将以下行添加到~/.sbuildrc : # Do not update chroot everytime i.e. you need to take care of that yourself! $apt_update = 0; $apt_upgrade = 0...

    lxqt-sudo:sudosu的GUI前端

    lxqt-sudo概述lxqt-sudo分别是命令sudo和su的图形前端。 这样,它使普通用户可以使用其他用户(包括root)的权限启动应用程序。安装编译源代码运行时依赖项是qtbase,sudo(应在所有* ix操作系统上默认安装su)和 。...

    debian/ubuntu

    1。选择合适的Ubuntu版本 在系统安装篇已经说过了,32位CPU用户...64位系统同样能使用32位的软件,只要在终端输入以下命令,安装相应的32位包: sudo apt-get install ia32-libs ia32-libs-gtk linux32 lib32asound2

    sunxi-debian:为sunxi板引导最小的debian rootfs

    使用sunxi内核和引导文件引导最小的debian rootfs。 目前只有4个olinuxino板可用。 该存储库中的所有脚本都是通用的,因此添加新的Boad很容易。 如果您创建并测试新板,请提出拉取请求。 我需要olinuxino lime2和...

    java8看不到源码-spring-boot-debian-package:spring-boot-debian-package

    java8 看不到源码Spring 启动 debian ...如果不存在传递依赖项,请使用以下命令: sudo apt-get -fy install 如果安装日志中没有错误,则安装并成功启动具有所有必需依赖项的gs-spring-boot应用程序。

    node-native-keymap:提供OS键盘布局功能作为Node.js模块

    在基于DebianLinux上: sudo apt-get install libx11-dev libxkbfile-dev 在基于Red HatLinux上: sudo yum install libx11-devel.x86_64 libxkbfile-devel.x86_64 # or .i686 在基于SUSELinux上: sudo zypper ...

    debian_setup:我关于设置Debian服务器的说明

    用于Netcup根服务器的Debian服务器设置 图像 网杯:Debian(10)Buster 基本配置 更新软件 通过Webconsole以root身份登录 apt-get update apt-get upgrade apt-get install curl pydf unzip git apparmor-utils 编辑...

    debian:Debian的Docker映像

    在Debian上,您需要sudo权限和以下软件包: # if you build on wheezy please use backports version of debootstrap sudo apt-get -qq -y install debootstrap 在Devuan上,您需要sudo权限和以下软件包: sudo ...

    node-keytar:本机密码节点模块

    keytar - 管理系统钥匙串的节点模块 ... Debian/Ubuntu: sudo apt-get install libsecret-1-dev 基于 Red Hat: sudo yum install libsecret-devel Arch Linux: sudo pacman -S libsecret 建造 克隆存储库

    hotdoc_bootstrap_theme

    启用了Bootstrap的hotdoc主题获取依赖首先确保已安装nodejs在软呢帽上: sudo dnf install nodejs关于debian和朋友: sudo apt-get install nodejs nodejs-legacy npm # debian在Arch Linux上: sudo pacman -S ...

    java8看不到源码-wildfly-debian:Wildfly的Debian和Ubuntu打包

    看不到源码野蝇debian Wildfly 的 Debian 和 Ubuntu 打包 最初基于 通过 PPA 安装 Wildfly 包 如果系统上尚未满足java8-runtime虚拟包依赖项,您可能需要先安装openjdk-8-jre-headless包: sudo apt-get install ...

    4Push:4Push稳定发行版版本库

    您可以选择滚动发布: 稳定发布: 要求: Python3.9.x(推荐) 对于安装Python3软件包, 在Arch Linux上: sudo pacman -S python3基于Debian的: sudo apt update && sudo apt install -y python3吉特对于安装Git...

    debian10安装qq、微信、迅雷、winrar等(2020.3.16)

    debian10安装qq、微信、迅雷、winrar等(2020.3.16)1.加key2.vi /etc/apt/sources.list 加入新源3.安装deepin wine环境,https://gitee.com/wszqkzqk/deepin-wine-for-ubuntu4.安装QQ、微信、迅雷、winrar等 1.加...

    Gamerbot:我的垃圾机器人

    sudo pacman -S git python-pip 基于Debian的: sudo apt install python3-dev git -y pip3 install -r requirements.txt 每个齿轮的其他要求(如果要禁用齿轮,则不需要它的要求): 音乐: 拱门: sudo pacman -S...

Global site tag (gtag.js) - Google Analytics