如何解决普通用户使用sudo找不到命令
一、在linux的普通用户下,要使用root权限的命令需要使用sudo
[dev@dev1 client_api]# sudo git pull origin develop
sudo: git: command not found
但是发现git命令找不到
二、使用whereis找git的绝对路径
[dev@dev1 client_api]$ whereis git
git: /usr/local/git
再次尝试
[dev@dev1 client_api]$ sudo /usr/local/git pull origin develop
sudo: /usr/local/git: command not found
还是不对的 换成which试试
[dev@dev1 client_api]$ which git
/usr/local/git/bin/git
这次找到的位置是截然不同的
再次尝试
[dev@dev1 client_api]$ sudo /usr/local/git/bin/git pull origin develop
From IP地址:client_api
* branch develop -> FETCH_HEAD
Updating 81608e5..815cbbb
error: Your local changes to the following files would be overwritten by merge:
app/Models/OrderMaster.php
app/Services/OrderService.php
config/params.php
Please, commit your changes or stash them before you can merge.
Aborting
很明显成功了
三、寻找原因
因为sudo默认的配置文件下只是指定三个命令位置,如下
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
所以采用软连接的方式
ln -s /usr/local/git/bin/git /usr/bin/git
这次再尝试直接使用命令
[dev@dev1 client_api]$ sudo git pull origin develop
remote: Counting objects: 34, done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 21 (delta 13), reused 0 (delta 0)
Unpacking objects: 100% (21/21), done.
From IP地址:018_client_api
* branch develop -> FETCH_HEAD
815cbbb..a93dc24 develop -> origin/develop
Updating 81608e5..a93dc24
error: Your local changes to the following files would be overwritten by merge:
app/Models/OrderMaster.php
app/Services/OrderService.php
config/params.php
routes/api.php
Please, commit your changes or stash them before you can merge.
Aborting
好了 完美
如何解决普通用户使用sudo找不到命令的更多相关文章
- [转]sudo找不到命令:修改sudo的PATH路径
sudo有时候会出现找不到命令,而明明PATH路径下包含该命令,让人疑惑.其实出现这种情况的原因,主要是因为当 sudo以管理权限执行命令的时候,linux将PATH环境变量进行了重置,当然这主要是因 ...
- Linux sudo 找不到命令
普通用户执行需要root权限的命令,提示"找不到命令",但是root用户执行该命令不报错,可能是由于该命令未处在sudo搜索的路径. 本文以sudo easy_install 为例 ...
- sudo 找不到命令 go
错误描述 环境 CentOS7.1 x64 golang 1.9.3 golang目录:/home/moonlightwatch/go/ 环境变量配置: # /etc/profile export G ...
- [Deepin 15] sudo source /etc/profile 提示找不到 source 命令(切换到 root 用户:sudo su)
在 Deepin/Ubuntu 系统 中,因为修改了下 配置文件,然后执行 source 命令重新加载配置文件,结果: sudo source /etc/profile 提示找不到 source 命令 ...
- Linux记录-普通用户下执行sudo xxx 找不到命令解决方案
chmod 777 /etc/sudoers vim /etc/sudoers 1.可以使用 secure_path 指令修改 sudoers 中默认的 PATH为你想要的路径.这个指令指定当用户执行 ...
- 普通用户开通sudo权限:xxx is not in the sudoers file.This incident will be reported.的解决方法
1.切换到root用户下,怎么切换就不用说了吧,不会的自己百度去. 2.添加sudo文件的写权限,命令是: chmod u+w /etc/sudoers 3.编辑sudoers文件 vi /etc/s ...
- RedHat Linux下普通用户无法使用sudo命令的解决方法
Ref:http://blog.sina.com.cn/s/blog_4aa35ca101012qb6.html 装完linux系统,发现普通用户无法使用sudo 命令, 提示:User1(普通用户) ...
- sudo pm2 提示 找不到命令
一共有 3 台 staging 环境服务器,5 台生产环境服务器,centos7系统.前阵子刚给所有研发配置了自己的账号,今天有小伙伴说,在其中两台服务器上 sudo pm2 list 提示: sud ...
- Linux给用户添加sudo权限
一.linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file. This incident will be ...
随机推荐
- tomcat配置manager
tomcat-users.xml配置 <role rolename="manager-gui"/><user username="tomcat" ...
- [Android Pro] Android源码编译后,再重编译所需要做的清理工作
1.在源码目录的根目录下,make clean; 2.进到源码的\linux\kernel\目录下,执行make mrproper: 3.再退回到根目录,执行source build/envsetu ...
- kafak-python函数使用详解
Consumer是非线程安全的 Kafka只保证消息不漏,即at lease once,而不保证消息不重.关键点:假如consumer挂了重启,那它将从committed offset位置(告诉ser ...
- 附 Java对象内存布局
注意:本篇博客,主要参考自<深入理解Java虚拟机(第二版)> 1.对象在内存中存储的布局分为三块 对象头 存储对象自身的运行时数据:Mark Word(在32bit和64bit虚拟机上长 ...
- BS系统经验总结
本文章是对刚做完BS系统的总结.主要记录开发过程中遇到的问题,及问题是如何解决的. 1,界面显示 一个系统界面首先要和谐,比如不同页面文本框长度高度要统一,按钮样式要一致,表格显示一样居中都居中靠左都 ...
- Okhttp【简介】应用 示例
资源 GitHub:https://github.com/square/okhttp 官网 文档 API You'll also need Okio[https://github.c ...
- Observer 观察者模式 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- Div+Css实现段落首行缩进两个字符(text-indent标签)
段落前面空两个字的距离,不要再使用空格了,用CSS实现段落首缩进两个字符.应该使用首行缩进text-indent.text-indent可以使得容器内首行缩进一定单位.比如中文段落一般每段前空两个汉字 ...
- jquery获取元素各种宽高及页面宽高总结
window.onload=function(){ var a = $("#div").width(),//width()返回元素的宽高,不包括padding/border/mar ...
- python3之日期和时间(转载)
转载:https://www.cnblogs.com/zhangxinqi/p/7687862.html a = datetime.datetime.now() time.sleep(10) b = ...