This question already has answers here:
How do I run a sudo command in Emacs?
(8 answers)
Closed 9 years ago.
I know how to open/edit files in Emacs as root with sudo, using Tramp. I wonder if there is a way to run Emacs commands with sudo too, without opening a shell?
Something like:
sudo M-x find-name-dired
or
M-x sudo find-name-dired
for example.
If your command involves some path on the filesystem it is possible to take advantage of tramp like this: M-x find-name-dired RET /sudo::/your/path.
Related
I have root and one other user on my CentOS machine. With other user i can use sudo to perform most of the administrative tasks. Now, I want to take this privilege from this user, So that it can not use sudo anymore.
Does anyone have an idea how to implement that?
One way to achieve that on Centos is by performing the following 2 steps:
Firstly, you have to remove any mention of the aforementioned user
(the one for which you do not want any sudo privileges) from the
/etc/sudoers file or (if it exists) from any file under the
/etc/sudoers.d path.
Secondly, you must remove the user from the wheel group in /etc/group.
(Optional) Finally reboot.
e.g.:
For user centos sudo vim /etc/sudoers or sudo vim /etc/sudoers.d/90-cloud-init-users and remove or comment something
like centos ALL=(ALL) NOPASSWD:ALL (save and quit afterwards).
Then sudo vim /etc/group and change the line wheel:x:10:centos to
wheel:x:10: (save and quit afterwards).
(Optional) Finally sudo reboot.
Hope that helps!
I planed to starting emacs from the the start.sh as
$ head start.sh
#! /bin/bash
{
#starting emacs servers
emacs --daemon=orging
emacs --daemon=coding
#waiting...
#invoke emacsclients
emacsclient -c -s "orging" &
emacsclient -c -s "coding" &
......
} &> /dev/null
Two clients run respectively under servers of orging and coding.
A problem occurred to this situation is that the invoked running clients are not labelled with appropriate server names.
So a manual steps of testing might be need to determine who is who.
As an alternative, the servers could be scheduled with one running at the top , the other at the end after starting from in the start.sh,
How could determine which server a client attached in a straightforward way on a working frame?
You can inspect the variable server-name - interactively with C-h v server-name RET.
I have a strange error with linux somehow interpreting sudo -H as two separate commands.
I'm on Cent OS 7, and I get the following:
/var/tmp/<random string>: line 8: -H: command not found
This is very vexing to me. Why would it not know this uption of sudo?
My guess would be that you have an alias or bash function that is suppressing your call to sudo. Try running the command with the full pathname for sudo (/usr/bin/sudo) on both systems, and type type sudo to see if there is an alias or bash function that is being called instead of the executable.
If there is, check the usual places like ~/.bashrc for where it is being defined so you can remove it.
Alternatively, it could be unrelated to sudo, and instead be related to whatever script you are calling with sudo.
I have installed docker-machine on 64 bit Windows 7 machine. It also installed Oracle Virtual Box to which docker-machine connects to. The issue is that it is getting very difficult to work on docker-machine. Reason is ssh-ing to virtual machine displays a lot of junk characters. Below is what I get when I just vi newfile. Similar junk characters on cat existingfile. Or if I click on backspace to delete any character on command prompt.
I was having the same issue. I came across this page during my search which prompted me to try using bash.
Install git if you do not already have it. You can then run the following command from PowerShell to drop into a bash shell (assuming default location for git).
& "C:\Program Files\Git\bin\bash.exe"
I have created the alias 'bash' for this in my PowerShell profile folder, which you can find from here.
New-Alias bash "C:\Program Files\Git\bin\bash.exe"
Now drop into a bash shell first before using docker-machine ssh and there should be no more junk characters.
I can run normal linux commands in eshell as a non-root user. When I try to su to root, all the usual linux commands are gone (ls, cat, etc.) How do I fix this?
One way is to use tramp:
cd /su::/etc/
ls
then eshell will run command "remotly" using su.
After testing, it seem that ls do work, but there is a problem with some (but not all) external command.