specify password for sudo on 1 line

Asked by maccam912

I would like to run a command right away when I log in, and I have figured out how do that with the sessions/startup programs thing. However, the command I want to run when I log in requires that I use sudo before it, and it doesn't run because it doesn't have the password. Is there some way that I can specify the root password to sudo so that I can run these commands with 1 line? I am not concerned about security, and if it has to be in plain text that is fine by me. I am the only one who will be around this computer and if someone does steal the password there is no information that is too sensitive. Thanks in advance for any help!

Again, for anyone who did not understand all those words, can I give the password to sudo in one line like:
sudo [command] | [password]
or
sudo -[option] [password] [command]

I hope you understand enough what I am talking about to help me.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Markus Thielmann
Solved:
Last query:
Last reply:
Revision history for this message
maccam912 (maccam912) said :
#1

Actually, all the solution needs to accomplish is that I can just press the power button on my computer to turn it on, and have it automatically start my web server for me (which I usually need to use "sudo" with). I already have it set to auto logon my user (which is already capable of everything, the only thing different about it and root is the name) so It will log on and run NON-sudo commands without my intervention. If you can tell me how to auto-logon root user and it would accomplish the same thing, I will consider that as a solution. Thanks again.

Revision history for this message
Josh (theformerprophet) said :
#2

Just curious, what's your webserver? My apache loads automatically at boot. Check to see if it is in the System-->Administration-->Services list. You should have a checkbox option for database, web, etc.

Revision history for this message
maccam912 (maccam912) said :
#3

It is apache, but I'm using xampp as it was VERY easy to get set up and running. I need the PHP and stuff, and it was super easy to install. If it would be possible to use everything from xampp except the apache server and install my own, that would also work, but would take a lot of help I think. I would need to change all the paths I believe.

Revision history for this message
Best Markus Thielmann (thielmann) said :
#4

The solution to your question will raise additional problems, especially regarding your systems security.

So I *highly* recommend to stay with ubuntus LAMP packages. To install Apache2, MySQL and PHP5, just run:

1) sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql

Everything under "/var/www" will be presented on your server. Please make sure that user "www-data" of group "www-data" (that's apache) will need read access to the files.

Revision history for this message
maccam912 (maccam912) said :
#5

Thanks Markus Thielmann, that solved my question.

Revision history for this message
MRT Cuore (backtrackfakhri) said :
#6

$echo <password> | sudo -S <command>