ubuntu下运行sudo Java 时提示“sudo: java: command not found”。在网上找了,其中很多方法都提示要修改/etc/profile的配置,或是修改/etc/environment的配置。配置完sudo java就可以运行了,但是改完之后依然无效。

 根据一个大神的指引,应该是修改/etc/sudoers这个文件, 

sudo vim /etc/sudoers

  显示内容如下:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/java/jdk1.8.0_131/bin" # Host alias specification # User alias specification # Cmnd alias specification # User privilege specification
root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL # Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d

在Defaults secure_path 中添加Java的路径。

再次运行 sudo java 就可以使用了。

Ubuntu 提示sudo: java: command not found解决办法的更多相关文章

  1. sudo: java: command not found

    背景:搭建了jumpserver,给开发划分了所有权限,但是开发那边账户不能执行java命令 报错:sudo: java: command not found 解决方法: 在用户管理权限配置sudoe ...

  2. Linux提示no crontab for root的解决办法

    Linux提示no crontab for root的解决办法 安装crontab:yum install crontabs 说明:/sbin/service crond start //启动服务/s ...

  3. VMware下 Ubuntu 看不到共享文件夹之解决办法

    VMware下 Ubuntu 看不到共享文件夹之解决办法 初学Linux,在VMWare 上装了Ubuntu10.04,主机端和虚拟机相互间的访问是必不可少的,途径有许多,其中vmware tool提 ...

  4. 升级10.11后使用CocoaPod出现-bash: pod: command not found 解决办法-备

    升级10.11后,运行pod命令出现: -bash: pod: command not found 解决办法: sudo gem install -n /usr/local/bin cocoapods ...

  5. Asp.Net Core2.0获取客户IP地址,及解决发布到Ubuntu服务器获取不到正确IP解决办法

    1.获取客户端IP地址实现方法(扩展类) using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.ModelBinding; u ...

  6. Ubuntu不能使用passwd的--stdin的解决办法

    转载请注明来源https://www.cnblogs.com/sogeisetsu/p/11397648.html Ubuntu不能使用passwd的--stdin的解决办法 可以使用chpasswd ...

  7. installshield制作的安装包卸载时提示重启动的原因以及解决办法

    原文:installshield制作的安装包卸载时提示重启动的原因以及解决办法 有时候卸载installshield制作的安装包程序,卸载完会提示是否重启电脑以完成所有卸载,产生这个提示的常见原因有如 ...

  8. 【转】Asp.Net Core2.0获取客户IP地址,及解决发布到Ubuntu服务器获取不到正确IP解决办法

    1.获取客户端IP地址实现方法(扩展类) using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.ModelBinding; u ...

  9. pip install 提示代理连接失败原因及解决办法

    # pip install 提示代理连接失败原因及解决办法 1. 错误提示 在公司电脑上安装Python的虚拟环境时输入命令: pip install virtualenv 系统提示以下异常信息: R ...

随机推荐

  1. cesium地下模式(地表透明)1

    cesium没有提供地下功能,实现地下模式需要以下三步. 1.修改cesium源码,在GlobeSurfaceTileProvider.js文件里修改一行代码 command.pass = Pass. ...

  2. 使用linux中,最让人无语的是软件源

    使用linux的最大的障碍是软件源的配置和系统的安装,这两个搞定了,坚持使用下去都不是问题,如果实在不行,还可以win10下的linux子系统可以作为基本的使用.下面记录两个软件源: Found 2 ...

  3. ubuntu 16.04 脚本开机自启动

    1.首先编写一个shell脚本文件,例如python_self_start.sh (nohup & 指定后台运行) #!/bin/bash nohup python3 /home/senset ...

  4. 一个U盘制作多个系统

    写在前面:一个U盘可以装多个ghost系统,但不能装多个原版ISO系统. 一.一个U盘装多个ghost系统 下载老毛桃或电脑店U盘制作工具,点击一键制作U盘启动盘.然后将gho文件拷贝复制到U盘的GH ...

  5. redhat 7.6下如何更新YUM源(仓库)?

    1. 安装epel-release     yum install epel-release 2. 安装webstatic-release     rpm -Uvh https://mirror.we ...

  6. Linux学习:使用 procrank 测量系统内存使用情况

    程序员应该了解一个基本问题:我的程序使用了多少内存?这可能是一个简单的问题,但是对于像Linux这样的虚拟内存操作系统,答案是相当复杂的,因为top和ps给出的数字不能简单相加.进程中两个最常见的内存 ...

  7. multiprocessing.Pool报pickling error

    multiprocessing.Pool报pickling error 现象 multiprocessing.Pool传递一个普通方法(不在class中定义的)时, 能正常工作. from multi ...

  8. leetcode刷题-559. Maximum Depth of N-ary Tree

    题目: https://leetcode.com/problems/maximum-depth-of-n-ary-tree/description/ n-ary-tree的数据结果表示 // Defi ...

  9. 【转】【很全很新】C3P0 连接池和 DBUtils 配合事务使用总结

    [转]https://blog.csdn.net/guozhaohui628/article/details/84793028 很久没用原生连接池,最近想写个小功能,结果发现很多地方不太懂,然后网上搜 ...

  10. 【ML】seq2seq原理

    最近要做分享,重温seq2seq原理,这篇文章讲的挺清楚: https://zhuanlan.zhihu.com/p/40920384 https://www.jianshu.com/p/b2b95f ...