Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to execute some part of makefile with sudo, some part without sudo?

Tags:

linux

makefile

Say, for example, I have a makefile:

front:
    cd front && (sudo make -f Makefile.linux )   -- require sudo

back: 
    cd back && (make -f Makefile.linux )

clean:
    cd front && (make -f Makefile.linux clean)
    cd back  && (make -f Makefile.linux clean)

Is it possible to do it? If yes, what is the right way to do it? Thanks

LJ

like image 351
user1558064 Avatar asked Nov 10 '22 05:11

user1558064


1 Answers

Sudo is just a program that allows you to authenticate and then run programs as root. After you authenticate, you are allowed to freely run commands as root through sudo, without having to re-authenticate for a configurable period of time. Any commands that you don't prefix with sudo will just be run with your regular user's privileges.

If you are expecting this makefile to be used on the command line then this is the correct way to do it. On the other hand, if you want the makefile to be used in a graphical environment, then you may want to use gksu or gksudo depending on what distribution you're using.

like image 149
Alex W Avatar answered Nov 15 '22 07:11

Alex W