ubuntu 8.04
How to run a command without using sudo password in ubuntu
by sahab on Apr.10, 2011, under Ubuntu, ubuntu 10.04, ubuntu 10.10, ubuntu 11.04, ubuntu 7.10, ubuntu 8.04, ubuntu 8.10, ubuntu 9.04, Ubuntu 9.10
Today I have tried my client PC run shutdown and reboot command without being enter sudo password. The details given below
Use the command “sudo visudo” to edit the file. Now look for the line “# User alias specification” and add a list of users as follows:#
User alias specification User_Alias USERS = user1, user2, user3
Now look for the line “# Cmnd alias specification” and add a command list as follows:
# Cmnd alias specification Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/reboot, /sbin/halt
Now look for the line “%admin ALL=(ALL) ALL” and add the command which will let USERS give SHUTDOWN_CMDS without a password
:%admin ALL=(ALL) ALL USERS ALL=(ALL) NOPASSWD: SHUTDOWN_CMDS
Now those specified users can use the commands “sudo shutdown”, “sudo halt”, and “sudo reboot” without being asked for your password.
EDIT: By the way, the reason that these commands can’t be used by normal users is that Linux was designed as a multi-user system. You don’t want one user shutting down the system while others are using it!
Some usefull Linux scripts
by sahab on Apr.06, 2011, under RHEL5, Ubuntu, ubuntu 10.04, ubuntu 10.10, ubuntu 11.04, ubuntu 7.10, ubuntu 8.04, ubuntu 8.10, ubuntu 9.04, Ubuntu 9.10
A nice script to find out the no of connection from a particular IP address to the apache
root@sahab-desktop# netstat -n|grep :80|awk {‘print $5′}|awk -F: {‘print $1′}>netlist;for i in `sort -u netlist` ;do echo -n$i”->”;grep -c $i netlist; done;
How to remove frozen messages from mail queue?(exim)
This command will help you to remove the frozen messages from the mail queue.
exim -bp|grep ‘*** frozen ***’ |awk {‘print $3′} |xargs exim -Mrm
Command to find all of the files which have been accessed within the last 10 days
The following command will find all of the files which have been accessed within the last 10 days
find / -type f -atime -10 > Monthname.files
This command will find all the files under root, which is ‘/’, with file type is file. ‘-atime -30′ will give all the files accessed less than 10 days ago. And the output will put into a file call Monthname.files.
Find and Remove the editor backup files
find . -name ‘*~’ -type f -print
find . -name ‘*~’ -type f -print |xargs rm -f