一、在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找不到命令的更多相关文章

  1. [转]sudo找不到命令:修改sudo的PATH路径

    sudo有时候会出现找不到命令,而明明PATH路径下包含该命令,让人疑惑.其实出现这种情况的原因,主要是因为当 sudo以管理权限执行命令的时候,linux将PATH环境变量进行了重置,当然这主要是因 ...

  2. Linux sudo 找不到命令

    普通用户执行需要root权限的命令,提示"找不到命令",但是root用户执行该命令不报错,可能是由于该命令未处在sudo搜索的路径. 本文以sudo easy_install 为例 ...

  3. sudo 找不到命令 go

    错误描述 环境 CentOS7.1 x64 golang 1.9.3 golang目录:/home/moonlightwatch/go/ 环境变量配置: # /etc/profile export G ...

  4. [Deepin 15] sudo source /etc/profile 提示找不到 source 命令(切换到 root 用户:sudo su)

    在 Deepin/Ubuntu 系统 中,因为修改了下 配置文件,然后执行 source 命令重新加载配置文件,结果: sudo source /etc/profile 提示找不到 source 命令 ...

  5. Linux记录-普通用户下执行sudo xxx 找不到命令解决方案

    chmod 777 /etc/sudoers vim /etc/sudoers 1.可以使用 secure_path 指令修改 sudoers 中默认的 PATH为你想要的路径.这个指令指定当用户执行 ...

  6. 普通用户开通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 ...

  7. RedHat Linux下普通用户无法使用sudo命令的解决方法

    Ref:http://blog.sina.com.cn/s/blog_4aa35ca101012qb6.html 装完linux系统,发现普通用户无法使用sudo 命令, 提示:User1(普通用户) ...

  8. sudo pm2 提示 找不到命令

    一共有 3 台 staging 环境服务器,5 台生产环境服务器,centos7系统.前阵子刚给所有研发配置了自己的账号,今天有小伙伴说,在其中两台服务器上 sudo pm2 list 提示: sud ...

  9. Linux给用户添加sudo权限

    一.linux给用户添加sudo权限: 有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file.  This incident will be ...

随机推荐

  1. 使用StringBuilder或StringBuffer简单优化

    使用StringBuilder或StringBuffer // join(["a", "b", "c"]) -> "a an ...

  2. python——获取数据类型:type()、isinstance()的使用方法:

    python——获取数据类型   在python中,可使用type()和isinstance()内置函数获取数据类型 如: (1)type()的使用方法: >>> a = '230' ...

  3. java静态代码分析工具infer

    infer是一个静态代码分析工具,探测bugs. 主要支持Java.C/C++ 安装:brew install infer 在线展示:https://codeboard.io/projects/115 ...

  4. 常用sql001_partition by 以及 row_number()和 dense_rank()和rank()区别

    create table student ( sid varchar2(10), --学号 sname varchar2(10), --姓名 classid varchar2(10), --班级号 s ...

  5. Longest Valid Parentheses leetcode java

    题目: Given a string containing just the characters '(' and ')', find the length of the longest valid ...

  6. OkHttp 官方Wiki之【使用案例】

    原文位置:https://github.com/square/okhttp/wiki/Recipes Recipes 食谱/知识点清单 We've written some recipes that ...

  7. Adapter 适配器模式 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  8. Open edX 学习、开发、运维相关链接整理

    原文地址:http://edustack.org/ 所需知识: Linux Git Python (Django Mako coffeescript sass) (MongoDB Mysql) Ans ...

  9. C# 引用访问权限,很多老手都不懂

    同样代码表现的不同行为   创建基类(Super)和派生类(Sub)每个类有一个字段field和一个公共方法getField,并且使用内联的方式初始化为1,方法getField返回字段field.C# ...

  10. Android -- uses-sdk:minSdkVersion 10 cannot be smaller than version L declared in library com.android.support:appcompat-v7:21.0.0-rc1

    这是一个报错,是我在Android Studio上添加完Support-v4和v7包之后爆出的错误,百度了好久也没有百度到.当时我的项目有minSdkVersion 19. 设置版本最小为L的时候也会 ...