Hello, I seem too stupid to understand scripts in linux so I need some help please
from my home dir I want to run a command in a subdir of downloads, However, to run this command I need root permissions. I would love to have a link on my desktop to just run the command so simplify my work but I have no idea how to do that
[Solved]Total newbie question
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
[Solved]Total newbie question
Last edited by FrankB on Thu Feb 15, 2024 9:13 am, edited 1 time in total.
Re: Total newbie question
Maybe we should talk about that to see if it is really true.to run this command I need root permissions.
But regardless, it sounds like you want to do this:
Pass the password to a script running sudo:
viewtopic.php?t=405273
Re: Total newbie question
To add a menu option, right click on the start menu, click on Configure, click on Menu tab, click on the button "Open the menu editor". Then create a new item.
Unless the script is specifically for performing some administrative task, you should not be running it as root. That way, you're giving the script full access to your system to do anything that it likes. Presumably you didn't write the script and don't have enough knowledge to understand what the script is actually doing, so don't give it full access to your system. Not unless you really trust it 100%.
Possibly there's a permissions problem. In the file manager, you can right click on the script and look at the properties, then permissions. There are a bunch of permissions for the "Owner", which should be you. In order to "run" the program, you need execute permission. If the file is owned by some other user, or there is just a number shown as the "Owner" then the ownership of the file needs changing. I don't think that can be done with the GUI file manager, so will require use of the command line
Unless the script is specifically for performing some administrative task, you should not be running it as root. That way, you're giving the script full access to your system to do anything that it likes. Presumably you didn't write the script and don't have enough knowledge to understand what the script is actually doing, so don't give it full access to your system. Not unless you really trust it 100%.
Possibly there's a permissions problem. In the file manager, you can right click on the script and look at the properties, then permissions. There are a bunch of permissions for the "Owner", which should be you. In order to "run" the program, you need execute permission. If the file is owned by some other user, or there is just a number shown as the "Owner" then the ownership of the file needs changing. I don't think that can be done with the GUI file manager, so will require use of the command line
sudo chown $USER <filename>
where <filename> is the exact name of the file including any extension. You'll need to supply your password when prompted because changing file ownership is itself an admin task.Re: Total newbie question
That, and as linked above, and as found elsewhere on the web does NOT work for me.
Code: Select all
$ echo "password" | sudo -S sleep 1 && fdisk -l
[sudo] password for rick: fdisk: cannot open /dev/sda: Permission denied
Code: Select all
$ sudo -S <<< "password" fdisk -l
[sudo] password for rick: Disk /dev/sda: 232.89 GiB, 250059350016 bytes, 488397168 sectors
Disk model: Samsung SSD 850...etc.
Last edited by rickNS on Wed Feb 14, 2024 6:07 pm, edited 1 time in total.
Mint 20.0, and 21.0 MATE on Thinkpads, 3 X T420, T450, T470, and X200
Re: Total newbie question
The OP may well be on a single-user machine, but this is not good for security.
The user will be typing the password into the command line in a way that is visible to anyone looking over their shoulder, or to anyone that can gain access to the shell history. Or if this is put into a script, the password is visible to anyone that can read the file.
Also, the system maybe setup such that sudo doesn't actually require a password. If it's necessary to get prompted in the GUI world, then one option would be to use the
--askpass
argument to sudo instead.Re: Total newbie question
I used it this way in scripts in the beginning and worked for me, later i added the scripts to sudoers. But with every script my sudoers got bigger and bigger and when i got sick and tired of typing my password everytime on the terminal i changed /etc/sudoers. Now i only need passwords for GUI programs. (synaptic, updates etc).
And since i work a lot with midnight commander i change it's wrapper so i can start it in normal, sudo or root mode. This way it changes colors and prompt each mode so i visually see i'm in normal/sudo/root mode. (btw for root i still need password)
normal
sudo
root
And since i work a lot with midnight commander i change it's wrapper so i can start it in normal, sudo or root mode. This way it changes colors and prompt each mode so i visually see i'm in normal/sudo/root mode. (btw for root i still need password)
normal
sudo
root
Re: Total newbie question
Thank you for all your ideas,
The echo <passwd> | sudo <command> works perfectly. As people asked here, I know what I want, I want to start the vpn which is preconfigured and II can give all the parameter on the command line when I am in the subdirectory. I just wanted to have a script to do that from the desktop
The echo <passwd> | sudo <command> works perfectly. As people asked here, I know what I want, I want to start the vpn which is preconfigured and II can give all the parameter on the command line when I am in the subdirectory. I just wanted to have a script to do that from the desktop