Disable Suspend and Hibernate – Ubuntu
Open a Terminal from Applications>Accessories>Terminal. Become a root with su – or sudo su -
- vim /usr/share/polkit-1/actions/org.debian.aptxapianindex.policy
Find the lines:
- <allow_active>yes</allow_active>
Change this entry from “yes” to “no” to disable hibernate/suspend.
- <allow_active>no</allow_active>
Disable screen going blank ubuntu server / Network timeout
Using setterm command.
man setterm : writes to standard output a character string that will invoke the specified terminal capabilities. Where possible terminfo is conâ sulted to find the string to use. Some options however (marked “virtual consoles only” below) do not correspond to a terminfo(5) capability. In this case, if the terminal type is “con” or “linux” the string that invokes the specified capabilities on the PC Minix virtual console driver is output. Options that are not implemented by the terminal are ignored
$ setterm -powersave off -blank 0
If it dumps back you with an error that read as follows:
cannot (un)set powersave mode
You need to shutdown X window system and rerun the above command. Better, add following two commands to your ~/.xinitrc file or /etc/rc.local
setterm -blank 0 -powersave off -powerdown 0
xset s off
Sendmail Linux Examples
Sendmail on the command line:
$ sendmail emailaddress write body of message CTRL-D
The CTRL-D is a end of message code for standard-in.
Example :
From: your-email@example.com
To: email@example.com
enter body of message
This message is missing a useful TO:line as well as a subject. To create these you need to create a file or use a script.
$ vim email.txt
date: todays-date // not required
to: user-email@example.com
subject: subject
from: your-email@example.com
Body of message goes here
Then call sendmail with that file as an input:
$ sendmail -t user-email@example.com < email.txt
Or you can use the -toption to to tell sendmail to read the header of the message to figure out who to send it to.
$ sendmail -t < mail.txt
This will process the To: and CC: lines for you and send the mail to the correct addresses.
Or call from a script:
#!/usr/bin/perl
use Time::localtime;
open (OUT,”|/usr/sbin/sendmail -t”);
print OUT “From: your-email\@domain.com\n”; ## don’t forget to escape the @
print(OUT “Date: “.ctime().”\n”);
print(OUT “To: $email\n”);
print(OUT “Subject: $subject\n”);
print(OUT “\n”);
print(OUT “$body\n”);
close(OUT);
Create tar and copy to another server using tar
Just a note
Code:
tar -cvf – test | ssh -l username domain.com “cd /home1/username && tar -xvf -”
Delete / remove old / order files in linux automatically
find /tmp/test -ctime +60 -delete
The above command will delete any files created over 60 days ago in the /tmp/test folder (and all subfolders).
You can add this to a cron job and it will be automatic daily, weekly, monthly