I'm trying to run a program written in C++ by using CLion v1.2 as super user. Anyone here knows how to run it as superuser? I'm using CMake.
I solved this by remote debugging on local machine. I run gdbserver with root privileges and connected to it from CLion.
To start gdbserver sudo gdbserver :port myapp, configure remote GDB debug with port
This was already implemented on CLion, starting 2020.3:
https://www.jetbrains.com/help/clion/debug-as-root.html
If you are asking to run the debugger as sudo/administrator, I had the same issue. On Linux you can open CLion as sudo and gdb will not have root permission issues running an executable:
sudo ./clion.sh
I would guess that you could right click in Windows and "Run as administrator" to get the same result.
There is a feature request into JetBrains to run the debugger as root that could use more up voting.
A workaround is:
From https://www.jetbrains.com/help/clion/attaching-to-local-process.html#prereq-ubuntu
If you are using CLion on Ubuntu (or probably, on some other Linux distribution), upon the first attempt to attach to the local process you can get the ptrace: Operation not permitted. error message. To disable it and enable attach to the local process feature, do the following:
To disable this restriction temporarily, enter the command:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
To disable this restriction permanently, open the file /etc/sysctl.d/10-ptrace.conf for editing and change the line kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0. To apply the changes, enter:
sudo service procps restart or restart your system, at your choice.
You can create a bash script to help you. For example, run.sh:
#!/usr/bin/env bash
echo $LOGIN_PASSWD | sudo -S yourExecutable --with=some-arguments
Don't forget to chmod a+x run.sh, and export the password of current account as an environment variable in Run/Debug Configurations.
Related
While trying to install ClickHouse in a macOS Catalina, doing the following command:
➜ ~ curl -O 'https://builds.clickhouse.tech/master/macos/clickhouse' && chmod a+x ./clickhouse
After trying to execute sudo ./clickhouse install it will complain with the following message:
Copying ClickHouse binary to /usr/bin/clickhouse.new
Code: 76. DB::ErrnoException: Cannot open file /usr/bin/clickhouse.new, errno: 1, strerror: Operation not permitted. (CANNOT_OPEN_FILE) (version 21.10.1.7886 (official build))
Why is it failing even if I sudo the command? Are there any other commands required before trying to install ClickHouse?
/usr/bin is protected by Apple's SIP (System Integrity Protection) mechanism. You can install clickhouse into specific (not protected) directory by passing --binary-path flag. This way you won't have to disable SIP.
For example, on MacOS you can install into /usr/local/bin, which is not protected, by using this command: sudo ./clickhouse install --binary-path /usr/local/bin/.
This is a rootless (SIP) mechanism that Apple has added to the new version of the system. The basic purpose of SIP is to prevent programs from obtaining root privileges and modifying several key system directories. It can indeed play a certain protective role.
The main directories to be protected are:
/System
/usr
/bin
/sbin and preinstalled apps
Close the SIp in the kernel:
Restart the computer and press command+R until the Apple logo appears. At this time, you will enter Recovery Mode.
After selecting a language, enter recovery mode, find Utilities in the above menu, and find Terminal in it;
Open the terminal and enter the following command to close SIP;
You can bypass the problem by installing ClickHouse this way here: https://clickhouse.com/docs/en/quick-start/#1-start-clickhouse.
Try to use docker to install clickhouse server/client.
docker pull yandex/clickhouse-server
docker pull yandex/clickhouse-client
docker run -it --rm --link some-clickhouse-server:clickhouse-server yandex/clickhouse-client --host clickhouse-server
I am trying to get homebrew installed remotely on a machine without a terminal open and without ssh access to the machine. Our company uses a Directory-as-a-Service which allows us to remotely push shell scripts to our computers which is great, but it requires the scripts to have no interactivity.
Is there a way to automate the installer and remove the “Press enter to continue” prompt in the install process?
Thanks,
Zach S
The env variable CI seems to silence this prompt:
export CI=1
I'm gonna to use vagrant on my windows desktop to develop Laravel project. I have followed all the steps to do that. But it has been failed to create homestead.yaml using bash init.sh command.
Below is the error :
Fakhreddin#Lenovo-PC3 /cygdrive/d/laravel-vagrant/homestead
$ bash init.sh
cp: unwritable ‘/home/Fakhreddin/.homestead/Homestead.yaml’ (mode 0500, r-x------); try anyway?
I'm using Cygwin for simulating Unix terminal in the Windows.
(Copy of the comment I wrote above)
Never used Cygwin in my life, but what I would try is to run it as Administrator and re-try.
Otherwise, you may want to consider changing console client. For example, if you install Git, you should be able to use Unix commands via standard Windows console.
I would seriously point the fault at Cygwin, or its settings. I am a member of a team in which all of us run Homestead on Windows 7, with no problems at all. The difference is, we use native Windows command line.
I'm running on Mac OS X 10.6.8 Snow Leopard.
FYI: I can't upgrade my OS so that is not an option for me right now.
So, I install boot2docker and when I go click on the icon I receive the following output:
username#My-Mac:~$ bash
username#My-Mac:~$ unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH
username#My-Mac:~$ mkdir -p ~/.boot2docker
username#My-Mac:~$ if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi
username#My-Mac:~$ /usr/local/bin/boot2docker init
/usr/local/bin/boot2docker up
$(/usr/local/bin/boot2docker shellinit)
docker version
error in run: Failed to initialize machine "boot2docker-vm": exit status 1
username#My-Mac:~$ /usr/local/bin/boot2docker up
error in run: Failed to get machine "boot2docker-vm": machine does not exist (Did you run `boot2docker init`?)
username#My-Mac:~$ $(/usr/local/bin/boot2docker shellinit)
error in run: Failed to get machine "boot2docker-vm": machine does not exist (Did you run `boot2docker init`?)
username#My-Mac:~$ docker version
Client version: 1.6.0
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 4749651
OS/Arch (client): darwin/amd64
FATA[0000] Get http:///var/run/docker.sock/v1.18/version: dial unix /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
username#My-Mac:~$
What does this mean? How can I fix this?
I ran into the same issue. You need to set the environment variables in your shell. Run the following:
eval "$(boot2docker shellinit)"
Since it is only persistent per shell you'll need to add it to your ~/.bashrc, ~/.bash_profile, .zshrc, or whatever other shell profile you need it to run in.
Here is a good example of a plist for auto starting boot2docker. You'll have to modify the plist so the working directory matches yours. https://gist.github.com/krak3n/0f7fe4c3c5828767ec5b
I've installed Kitematic (Version 0.5.19 which is Beta as of this writing) as well as boot2docker on my system. Kitematic does not install a plist for auto starting your boot2docker instance. It boots when you start Kitematic. It most likely shuts it down on close which means your containers that are running will shutdown as well.
Ultimately it is up to how you want to setup and run your environment. If you're going only boot2docker and docker CLI and want things running at boot, create the plist and set your .bash_profile/.zshrc. If you want a GUI and CLI option that only boots and runs when you want it to then Kitematic is the way to go.
The answer above is correct, but you don't need the eval, you can just use:
$(boot2docker shellinit)
You can put this in your .profile
echo '$(boot2docker shellinit)' >> ~/.profile
and then it is setup every time you create a new shell.
This might be a duplicate of a previous question I answered:
Docker TLS error on Mac
After much hassle and delegation I was able to finally figure out what was going on. It was xanderlopez in this post that got me to realize that the problem lied with my shared folder and virtual machine folder locations for VitualBox. After changing the shared folder and renaming the location for the VM to "VirtualBox VMs", once I reinstalled boot2docker, everything ran as was supposed to and the hello world verification succeeded. So that's a gotcha right there. The location of your vm must be inside a folder named "VirtualBox VMs". The location seems to be unimportant as I just created a subfolder folder inside the folder that I was already using. Not sure how that works but it seems to have worked which is good enough for this issue. If I see any problems up ahead later related to the folder structure I'll be sure to reference this post.
The Alt+f2 in ubuntu shows up Run Application prompt. I can type any command there and open an application through it. How can i do the same programmatically, i mean that i have a command that should be passed to Alt+F2 programmatically. By program i mean a shell script
Have a look at xdotool.
You can use gmrun, which can be installed from the Ubuntu repos. Just sudo apt-get install gmrun. man gmrun for more info.
It's not exactly the same as the "run application dialog", but there's no clean way to bring that up from a script that I know of.