YUM Cheat Sheet

The Yellowdog Updater, Modified (YUM) is a libre and open-source command-line packagemanagement utility for computers running the GNU/Linux operating system.
Display yum commands and options
yum help
List all available packages
yum list available
List all installed packages
yum list installed
List installed and available packages
yum list all
List installed and available kernel packages
yum list kernel
List info about vsftpd package
yum info vsftpd
List dependencies and packages providing them
yum deplist nfs-utils
Show package that contains top command
yum provides “*bin/top”
Find packages with samba in name or description
yum search samba
Get info on available security updates
yum updateinfo security

Query repositories for available package updates

yum check-update
Download (no install) vsftpd package to cache (/var/cache/yum/arch/prod/repo/)
yum install --downloadonly vsftpd
Install the vsftpd package
yum install vsftpd
Update the httpd package (if available)
yum update httpd
Apply security-related package updates
yum update --security
Remove httpd and other unneeded packages
yum autoremove httpd
Remove the vsftpd package and dependencies
yum remove vsftpd
Downgrade the abc package to an earlier version
yum downgrade abc
Delete packages saved in cache
yum clean packages
List installed RPM packages and statistics
show-installed
0

SBS 2011 Memory drain

Experienced a memory leak on Windows Server 2011 Small Business Server. Tried to analyze with Process-Explorer and finally found out that the Windows SBS-Manager and the SQL-Database (SBSMonitoring) are the processes which consume more and more memory over the time. After some research i agreed with disabling the two services (https://serverfault.com/questions/522647/removing-sbs-monitoring-permanently-sbs-2008-2011)

 

0

(i)SQL – Cheat Sheet

Informix never forget 😉

Creation/Manipulation of tables:

CREATE TABLE tabelle (nummer int, text char(10), time datetime, date date);
DROP table tabelle;
ALTER TABLE table_name MODIFY (name char(100));
ALTER TABLE table_name ADD column_name column-definition;

can be positioned with AFTER/BEFORE

Unloading tables:

unload to '/home/content.csv'
delimiter ';'
SELECT * FROM content

Transactional Stuff:

BEGIN WORK;
ROLLBACK WORK;

Query Time:

SELECT |ALL|DISTINCT|UNIQUE|FIRST 
FROM table (WHERE)
GROUP BY columnname
HAVING COUNT(**)>1
ORDER BY columnname (ASC|DESC), ....
INTO TEMP tablename

WHERE-Clause:

bla (NOT) BETWEEN bla AND 
bla (NOT) IN (List, of, bla)
bla (NOT) LIKE "bla"
bla (NOT) EXISTS 
bla IS (NOT) NULL

to combine multiple selects

UNION

TO_CHAR transformation for query:

SELECT nr FROM numbers WHERE nr MATCHES "38*"
Error 219: Wildcard matching may not be used with non-character types.

SELECT nr FROM numbers WHERE TO_CHAR(nr) MATCHES "38*"
0

Override DNS with BIND

If you want to manipulate DNS-Entries before and without ISP-DNS Resolution you can do it with extra DNS-Server at your site. Best thing would be putting this DNS in DMZ-Zone.

e.g. Youre hosting WebEx and have one Public-URL to connect. Your Internal Clients will always route the traffic via Internet. To avoid this you can override the DNS – Resolving at your ISP with an own DNS. It’s also possible with your own Windows-DNS but… I like Linux 😉

Here I did with Linux, because its free:

Install BIND and configure named.conf

//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
 
options {
        listen-on port 53 { 127.0.0.1; 10.1.10.100; };
        listen-on-v6 port 53 { ::1; };
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { localhost; 10.1.0.0/16; 10.2.0.0/16; };
        recursion yes;
 
        //dnssec-enable yes;
        //dnssec-validation yes;
        //dnssec-lookaside auto;
 
        /* Path to ISC DLV key */
        //bindkeys-file "/etc/named.iscdlv.key";
 
        //managed-keys-directory "/var/named/dynamic";
 
        forwarders { 8.8.8.8; 8.8.4.4; };
 
};
 
logging {
        channel default_debug {
                file "data/named.run";
                severity dynamic;
        };
};
 
//zone "." IN {
//      type hint;
//      file "named.ca";
//};
 
 
include "/etc/named.rfc1912.zones";

Important parts of config:

Who is allowed to query this DNS?

 allow-query { localhost; 10.1.0.0/16; 10.2.0.0/16; };

Forward-Adresses for DNS-Requests which cannot be handled/resolved by the local DNS

forwarders { 8.8.8.8; 8.8.4.4; };

For your linking your own zones:

include "/etc/named.rfc1912.zones";

If you do changes, dont forget to restart

/etc/init.d/named restart
If you now want to override some URLS you have to create a link inside of /etc/named.rfc1912.zones
zone "override.untony.org" IN {
type master;
file "named.override.untony.org";
allow-update { none; };
};

and of course a file in /var/named called named.override.untony.org (in our example)

$TTL 86400 @       IN SOA  @       root (                                         2013111501      ; serial                                         1D              ; refresh                                         1H              ; retry                                         1W              ; expire                                         3H )            ; minimum @        IN NS          localhost. @        IN A           194.232.104.3

When you now put this DNS Server in your Active-Directory DNS as a forwarder every Request which goes to override.untony.org will be resolved with 194.232.104.3 which us a total different site.

How-To change Forwarder in Active Directory-DNS:
in DNS Console right click the DNS and choose Properties.
Then navigate to forwarders tab and enter the IP-Adress of the new DNS, usually you have there your ISP-DNS or Google DNS servers.
1+

Setting up Clonezilla-Server

In short:

#/etc/apt/sources.list editing
echo -e "\n# Clonezilla" >> /etc/apt/sources.list

echo "deb http://drbl.sourceforge.net/drbl-core drbl stable" >> /etc/apt/sources.list

# Add GPG-Key
wget http://drbl.sourceforge.net/GPG-KEY-DRBL
apt-key add GPG-KEY-DRBL

#Update Packagelist
apt-get update

#drbl installation
apt-get install -y drbl

#Set up Clonezilla und drbl
drblsrv -i
drblpush -i

Inside of your DHCP you have to reconfigure:

For the neccessary scope.

Option 66 with IP Adress of cloning server

Option 67 with  pxelinux.0

Long(er) Explanation here:

OS Installation

Install an Ubuntu or Debian Server first. Then start with Clonezilla SE Installation. Commands have to be executed by root

sudo -i

Add this Line in your /etc/apt/sources.list

deb http://drbl.sourceforge.net/drbl-core drbl stable

then import the GPG-Key

wget http://drbl.sourceforge.net/GPG-KEY-DRBL
apt-key add GPG-KEY-DRBL

To renew sources do:

 apt-get update

and install dbrl

apt-get install drbl

This should also install every dependencies

Set up Clonezilla

First start with configuring dbrl

drblsrv -i
  1. Install Network Boot-Images: If you want to boot from Images, not for installing so i chose „N“
  2. Serial Output: I chose „N“
  3. Operating System update: I chose „N“
  4. Kernel for Client: I chose 1

Next step is:

drblpush -i
  1. DNS-Domain: choose your local domain
  2. NIS/YP Domain-Name: not neccessary
  3. Präfix for Clienthostname: as you wish eg. clonezilla
  4. NIC for Internetaccess: mostly eth0
  5. Collecting MAC-Adresses: You can choose N
  6. Ip-Adress to MAC: Clients do always get the same IPs (like reservations)
  7. Start of IP-Adress-Range: eg. 1, First IP is then 192.169.0. 1
  8. Max Clients: eg. 20, last IP would be 192.169.0. 20
  9. Diskless Services: Not needed
  10. Type of usage: For our scope 1 is enough
  11. Where to put the images?
  12. You can choose a password for accessing Clonezilla
  13. Bootprompt for Clients: N

 

 

1+

MySQL Backup to a share

  • Create a share on a server
  • Install cifs-utils: apt-get install cifs-utils
  • Create a folder under /mnt for mounting:
    mkdir /mnt/backup
  • Inside of /etc/fstab define the mountpoint:
//backupserver/Linux_Backups   /mnt/backup   cifs    credentials=/etc/cifspw    0       0
  • Create /etc/cifspw with credentials für a „mounting-user“

> Ubuntu 12

username=linuxmountpassword=linuxmountpassworddomain=DOMAIN

< Ubuntu 13

username=DOMAIN\linuxmountpassword=linuxmountpassword
  • Try via mount -a if mounting works and verify output of df or simply go to /mnt/backup (cd /mnt/backup)
  • Create a file called mysqlbackup.sh inside of /usr/sbin and add this content:
#user='root'
#password='youshouldcreateabackupuser'
user=backup
password='password'
for db in 'mysqlshow -u $user -p$password | sed -n -e "s/^| \([^ ]*\)[ ]*|$/\1/p"'  
do mysqldump --opt -u $user -p$password $db > /mnt/backup/ /mysql/$db.sqldone

After creation do chmod a+x mysqlbackup.sh so that the script can be executed

  • To automate the job create a cronjob under /etc/cron.d called mysql_backup (or do it via crontab –e)
00 02 * * *     root    /usr/sbin/mysqlbackup.sh >/dev/null 2>&1
0
1 2 3 6