简体   繁体   English

如何让 bashrc 中的 sudo 别名工作

[英]How can i get sudo alias in bashrc to work

I'm trying to create an alias for when I forget to write sudo.当我忘记写 sudo 时,我正在尝试创建一个别名。

sudo !!

It works in Terminal but not when I write it as an alias in the bashrc file.它在终端中有效,但在我将其作为别名写入 bashrc 文件时无效。

alias f='sudo !!'

Any Ideas what I'm doing wrong?任何想法我做错了什么?

This is what I have in my.bashrc这就是我在 my.bashrc 中的内容

alias f='sudo $(history -p !!)'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在.bashrc“ sudo vi / etc / hosts”中为该命令添加别名 - How to add this command an alias in .bashrc “sudo vi /etc/hosts” 如何为.bashrc添加一个接受参数的bash别名? - How can I add a bash alias to .bashrc which will accept an argument? 我为用户〜/ .bashrc添加了别名,但是“sudo -u user -i'alias_name'”仍然报告“找不到命令”? - I added aliases to user ~/.bashrc but “sudo -u user -i 'alias_name'” still reports “command not found”? 我怎样才能让“sudo chmod +x my_script.sh”工作? (不允许操作)(Fedora 30) - How can I get "sudo chmod +x my_script.sh" to work? (operation not permitted) (Fedora 30) .bashrc中的mv命令别名的-i参数被忽略 - -i parameter to mv command alias in .bashrc is ignored 我如何在 linux 中获得没有 sudo 的 pid - How can i get pid without sudo in linux Scrot 程序的别名在.bashrc 中不起作用,但在终端中起作用 - Alias to Scrot program doesn't work in .bashrc but works in terminal 如何使用bashrc函数更改为文件目标目录? - How can I change to the file destination directory using a bashrc function? 无法获得厨师食谱来获取.bashrc的源,我在做什么错? - Can't get a chef cookbook to source .bashrc, what am I doing wrong? bashrc别名的动态目录名称 - Dynamic directory name for a bashrc alias
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM