Difference between revisions of "Short Notes on Linux Administration"

From PaskvilWiki
Jump to: navigation, search
(Created page with "=== Reset Compiz to Default Settings === gconftool-2 --recursive-unset /apps/compiz and restart.")
 
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
=== Reset Compiz to Default Settings ===
+
== Reset Compiz to Default Settings ==
  
 
  gconftool-2 --recursive-unset /apps/compiz
 
  gconftool-2 --recursive-unset /apps/compiz
 
and restart.
 
and restart.
 +
 +
== Enable and Start <tt>sendmail</tt> ==
 +
 +
If you're getting "'''stat=Deferred: Connection refused by [127.0.0.1]'''" log messages from ''sendmail'', try adding the following line to your '''/etc/mail/sendmail.mc''' file:
 +
DAEMON_OPTIONS(`Port=smtp, Addr=127.0.0.1, Name=MTA')
 +
under the "General defines" section.
 +
 +
Also, make sure the <tt>sendmail</tt> daemon is running:
 +
ps aux | grep sendmail
 +
If not, run it using
 +
sendmail -bd -q1m
 +
where ''-q'' parameter chooses how often the email queue's new messages should be processed (here, every minute).
 +
 +
To test if this all works, use
 +
echo -e "Subject: Hello\nTesting the mailer..." | sendmail -f test@test.com ''myrealaddress@mail.com''
 +
 +
The advantage of <tt>sendmail</tt> over <tt>mail</tt> is that the ''from'' address need not be a valid email address... well... advantage?
 +
 +
== Installing <tt>sendmail</tt> ==
 +
 +
On most systems, <tt>sendmail</tt> comes as a package, and typically gets started during the boot from the <tt>init.d</tt>/<tt>rc.d</tt> scripts.
 +
 +
If you want/need to start <tt>sendmail</tt> manually, or it has died, use
 +
sendmail -bd
 +
or, for debugging purposes
 +
sendmail -bD
 +
that will start <tt>sendmail</tt> daemon, but will keep it in foreground, so you can see its output.
 +
 +
== Sending Emails using <tt>sendmail</tt> ==
 +
 +
The easiest way is to create the message file with all necessary definitions, e.g.
 +
<pre>To: Mr. Recepient <recepient@hosting.com>
 +
Subject: This is a fine example of a subject
 +
Date: 2011-08-15 20:00:00 +0000
 +
From: Mr. Sender <sender@hosting.com>
 +
Content-Type: text/plain; charset=utf-8
 +
Content-Transfer-Encoding: 8bit
 +
Content-Disposition: inline
 +
User-Agent: My email service
 +
 +
The body of the message comes here, after a single blank line...</pre>
 +
and then feed this file to <tt>sendmail</tt>:
 +
<pre>sendmail -t < message_file.txt</pre>
 +
 +
== Find and Mark Bad Blocks ==
 +
 +
To test partition <tt>/dev/sdXN</tt> (such as, <tt>/dev/sda1</tt>) for bad blocks simply run:
 +
<pre>$ sudo backblocks -sv /dev/sdXN > ~/bad-blocks-list
 +
$ fsck -l ~/bad-blocks-list /dev/sdXN</pre>
 +
 +
== Using TLP to Optimize Battery Lifetime ==
 +
 +
<pre># check TLP status and system info
 +
$ sudo tlp-stat -s
 +
 +
--- TLP 1.1 --------------------------------------------
 +
 +
+++ System Info
 +
[...]
 +
 +
+++ TLP Status
 +
State          = enabled
 +
Last run      = 09:13:49,    403 sec(s) ago
 +
Mode          = battery
 +
Power source  = battery
 +
 +
# get battery information
 +
$ sudo tlp-stat -b
 +
 +
--- TLP 1.1 --------------------------------------------
 +
 +
+++ Battery Status
 +
/sys/class/power_supply/BAT0/manufacturer                  = CPT-COS
 +
/sys/class/power_supply/BAT0/model_name                    = L17C4PB0
 +
/sys/class/power_supply/BAT0/cycle_count                    = (not supported)
 +
/sys/class/power_supply/BAT0/energy_full_design            =  45520 [mWh]
 +
/sys/class/power_supply/BAT0/energy_full                    =  44540 [mWh]
 +
/sys/class/power_supply/BAT0/energy_now                    =  37370 [mWh]
 +
/sys/class/power_supply/BAT0/power_now                      =  20057 [mW]
 +
/sys/class/power_supply/BAT0/status                        = Discharging
 +
 +
Charge                                                      =  83.9 [%]
 +
Capacity                                                    =  97.8 [%]
 +
 +
# CPU temperature and fan speed
 +
$ sudo tlp-stat -t
 +
 +
# CPU info
 +
$ sudo tlp-stat -p
 +
 +
# warnings
 +
$ sudo tlp-stat -w</pre>

Latest revision as of 09:19, 21 November 2019

Reset Compiz to Default Settings

gconftool-2 --recursive-unset /apps/compiz

and restart.

Enable and Start sendmail

If you're getting "stat=Deferred: Connection refused by [127.0.0.1]" log messages from sendmail, try adding the following line to your /etc/mail/sendmail.mc file:

DAEMON_OPTIONS(`Port=smtp, Addr=127.0.0.1, Name=MTA')

under the "General defines" section.

Also, make sure the sendmail daemon is running:

ps aux | grep sendmail

If not, run it using

sendmail -bd -q1m

where -q parameter chooses how often the email queue's new messages should be processed (here, every minute).

To test if this all works, use

echo -e "Subject: Hello\nTesting the mailer..." | sendmail -f test@test.com myrealaddress@mail.com

The advantage of sendmail over mail is that the from address need not be a valid email address... well... advantage?

Installing sendmail

On most systems, sendmail comes as a package, and typically gets started during the boot from the init.d/rc.d scripts.

If you want/need to start sendmail manually, or it has died, use

sendmail -bd

or, for debugging purposes

sendmail -bD

that will start sendmail daemon, but will keep it in foreground, so you can see its output.

Sending Emails using sendmail

The easiest way is to create the message file with all necessary definitions, e.g.

To: Mr. Recepient <recepient@hosting.com>
Subject: This is a fine example of a subject
Date: 2011-08-15 20:00:00 +0000
From: Mr. Sender <sender@hosting.com>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
User-Agent: My email service

The body of the message comes here, after a single blank line...

and then feed this file to sendmail:

sendmail -t < message_file.txt

Find and Mark Bad Blocks

To test partition /dev/sdXN (such as, /dev/sda1) for bad blocks simply run:

$ sudo backblocks -sv /dev/sdXN > ~/bad-blocks-list
$ fsck -l ~/bad-blocks-list /dev/sdXN

Using TLP to Optimize Battery Lifetime

# check TLP status and system info
$ sudo tlp-stat -s

--- TLP 1.1 --------------------------------------------

+++ System Info
[...]

+++ TLP Status
State          = enabled
Last run       = 09:13:49,    403 sec(s) ago
Mode           = battery
Power source   = battery

# get battery information
$ sudo tlp-stat -b

--- TLP 1.1 --------------------------------------------

+++ Battery Status
/sys/class/power_supply/BAT0/manufacturer                   = CPT-COS
/sys/class/power_supply/BAT0/model_name                     = L17C4PB0
/sys/class/power_supply/BAT0/cycle_count                    = (not supported)
/sys/class/power_supply/BAT0/energy_full_design             =  45520 [mWh]
/sys/class/power_supply/BAT0/energy_full                    =  44540 [mWh]
/sys/class/power_supply/BAT0/energy_now                     =  37370 [mWh]
/sys/class/power_supply/BAT0/power_now                      =  20057 [mW]
/sys/class/power_supply/BAT0/status                         = Discharging

Charge                                                      =   83.9 [%]
Capacity                                                    =   97.8 [%]

# CPU temperature and fan speed
$ sudo tlp-stat -t

# CPU info
$ sudo tlp-stat -p

# warnings
$ sudo tlp-stat -w