I'm a root user
sudo -i, now i want to execute the
Downloads/my.sh from root. how do i do that?
First you should know there are 2 ways:
First make your file executable just right click it, under permission tab check allow executing file as program
The Graphical way
A.1) Open your file manager as root(Assuming you are using Ubuntu gnome version if not, change nautilus for your file manager)
$ sudo nautilus
A.2) With your file manager is open as root, you should navigate to the folder containing your executable file
A.3) Now you just double click it, if didn't work you right click it and then click "open with" and in the new window select "list all" and now you can search for "execute program" or something similar
The Terminal Way
B.1) You open your Terminal Window and the you type(just to be sure you are at your home directory)
$ sudo cd
B.2) Now you type this
$ sudo ./Downloads/my.sh
alternate way is
$ cd the/route/to/the/folder/containing/the/file
and now you execute
$ sudo ./file.sh
if you want to execute something as root user, not just asking for permission try this
$ sudo su
and now you locate the file and execute it
edited it for your needs as you commented it
- You need to use absolute path:
When you write command
root -iyou are the root user. So that, If you write command
Download/my.shit will be take as
If your are simple user
/home/username/Download/my.sh. So, when you are the root user you need to give command form where you are (absolute path).
I was a real noob back then.
Thanks @NiteRain for your comment.