The mail sent by your server’s cron jobs are refused by the recipient server due to:


"Action: failed
Final-Recipient: user;user@domain.com
Status: 5.0.0
Remote-MTA: dns; inbound.smtp.domain.com
Diagnostic-Code: smtp; 553 5.1.8 ... Domain of sender address root@hostname.domain.com does not exist"

Crontab will by default send from $LINUX_USER@$HOSTNAME. You can change this by connecting to the server via SSH, running “crontab -e”, and adding “MAILFROM=VALID_ADDRESS_HERE”. Ideally, the MAILFROM will be set to a mail account hosted on your server, but if it is a valid domain, the recipient address will accept it.

Basics
rDNS (Reverse DNS)

The Reverse DNS for an IP should be set to the EHLO value that is sent in the outgoing mail header. This is generally the HostName of the computer.

This value should also match the outgoing IP address used to send the mail.

On a multi-IP server, if the sending IP does not match the EHLO domain, you may be sending from Postfix. Switching to Qmail may cause the sending IP to match the primary IP on the server, which should correct any mis-matched IP/EHLO issues.

Read More

  1. cheat_sheet.org
  2. (C) William Hackmore, 2010
  3. The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
  4. Last updated 8/14/2012
  5. Best viewed in emacs org-mode.
  • Command Reference:
    • Basics:
      • Getting help:
  1. View the manual for target command
man [command]
  1. Get help with a target command (probably the same as above, but not always):
[command] -h
  1. In case you forget the name of a command, print possible commands relating to [guess]:
apropos [guess]
  1. View index of help pages:
info
      • Command Line Utilities:
        • Basic File and Directory Operations:
  1. Print current working directory:
pwd
  1. Show files in current directory:
ls
  1. Show maximum information about all files, including hidden:
ls -a
  1. Recurse into subdirectories and list those as well:
ls -r
  1. Move/rename a file or directory (be careful that you don’t move the source over a destination with the same name):
mv [source] [destination]
  1. Delete target forever (be very careful), use -r recursive flag for directories:
rm [target]
  1. Copy file or directory:
cp [source] [destination]
  1. Mount filesytem:
mount /dev/[device name] /media/[device name]
  1. Unmount:
umount /media/[device name]
  1. Forensically clone filesystems and do other low-level operations on files. Very dangerous:
dd
  1. Work with filesystems and partitions. (Easier, still quite dangerous):
fdisk
        • System Administration:
  1. Execute command as an administrator (dangerous, but necessary for system administration tasks):
sudo [command]
  1. Become system administrator:
sudo -s
  1. Quit system administration:
exit
  1. Check distro repositories for software updates:
sudo apt-get update
  1. Download and install updates (update first):
sudo apt-get upgrade
  1. Search for package in the repositories:
apt-cache search [keyword]
  1. Get more detail on one specific package:
apt-cache show [package name]
  1. Download and install a package:
sudo apt-get install [package name]
  1. View the output of a command in a more convenient format:
[command] | less
        • Working With Files:
  1. Print a file in terminal:
cat [file]
  1. Find files matching [filename]:
locate [filename]
  1. Search through [filename] for matches to [phrase]:
grep [phrase] [filename]
  1. Search through output of a command for [phrase]:
[command] | grep [phrase]
        • Working With Processes:
  1. List all running processes:
ps -e
  1. Standard system monitor showing a more extensive view of all processes and system resources:
top
  1. Like top, but with a better, cleaner interface:
htop
  1. Stop a process from using all system resources and lagging computer:
nice [process name]
  1. Kill misbehaving process (use sparingly, last resort, try ‘nice’ command first):
pkill [process name]
        • Compression and Encryption:
  1. Make a simple compressed backup of a file or directory:
tar -cvzf [backup output.tgz] [target file or directory]
  1. Open a compressed .tgz or .tar.gz file:
tar -xvf [target.tgz]
  1. Encrypt a file:
gpg -o [outputfilename.gpg] -c [target file]
  1. Decrypt a file:
gpg -o [outputfilename] -d [target.gpg]
  1. Zip and encrypt a directory simultaneously:
gpg-zip -o encrypted-filename.tgz.gpg -c -s file-to-be-encrypted
      • The Bash shell:
        • File Name expansions:
  1. Current user’s home directory:

~/

  1. Current directory:
./
  1. Parent directory:
../
  1. Or even (Two parent directories down):
../../
  1. All files in target directory. (Be very careful.):
/*
        • Output Redirects:
  1. Redirect output of one command into the input of another with a pipe:
[command 1] | [command 2]
  1. Or even:
[command 1] | [command 2] | [command 3]
  1. Redirect output to a file:
[command] > file
  1. Or:
[file] > [file]
  1. Or even, to redirect in a different direction:
[file] < [file]
  1. Append output rather than writing over the target file:
[file/command] >> [file]
  1. Works like |, but it writes output to both target and terminal:

tee [target]

        • Controlling Execution:
  1. Wait until [command 1] is finished to execute [command 2]
[command 1] ; [command 2]
  1. Or even:
[command 1] ; [command 2] ; [command 3]
        • Wildcards:
  1. Zero or more characters:
*
  1. Matches “phrase” and any number of trailing characters:
phrase*
  1. Matches any incidences of “phrase” with any trailing or leading chars:
*phrase*
  1. Matches any one char:
?
  1. Matches any of the characters listed inside brackets:
[chars]
  1. Matches a range of chars between a-z:
[a-z]
    • Advanced:
      • Command Line Utilities, Continued:
        • Networking:
  1. Configure network interfaces:
ifconfig
  1. Configure wireless network interfaces:
iwconfig
  1. Connect to a remote server.
ssh [username]@[ipaddress]
  1. Forward x from target to current machine (Get a remote desktop. Very obscure and very useful):
ssh -x [username]@[ipaddress]
  1. Copy files over the network from one machine to another:
scp [source filename]:[username]@[ipaddress] [target filename]:[target username]@[target ipaddress]
  1. Copy only changes between files or directories (super efficient way to sync directories, works either locally or with remote servers using username@ipaddress:optionalport, just like ssh):
rsync [source] [target]
  1. Check to see if target is online and responding
ping [ip address]
  1. View network route to target:
traceroute6 [ip address]
  1. Network Monitor
netstat
  1. Manage standard linux firewall (advanced users only)
iptables
  1. Scan this machine to check for open ports:
nmap 127.0.0.1
          • netcat:
  1. Listen for input from network on [recieving port], dump it to a file (possibly insecure):
netcat -l [recieving port] > file_copied
  1. Pipe the output of a command to a target ip and port over the network:
[command] | netcat -w [number of seconds before timeout] [target ip] [target port]
  1. Use tar to compress and output a file as a stream, pipe it to a target ip and port over the network:
sudo tar -czf - [filename] | netcat -w [number of seconds before timeout] [target ip] [target port]
        • Users and Groups:
  1. Change owner of a file or directory:
chown
  1. Change privileges over file or directory:
chmod
  1. Create a new user:
adduser
  1. Change user privileges (be very careful with this one):
usermod
  1. Delete user”
deluser
  1. Print groups:
groups
  1. Create a new group:
groupadd
  1. Change group privileges:
groupmod
  1. Delete group:
delgroup
  1. Temporarily become a different user:
su [username]
  1. Print usernames of logged in users:
users
  1. Write one line to another user from your terminal:
talk
  1. Interactive talk program to talk to other users from terminal:
ytalk
        • Working With Files, Continued:
  1. View what processes are using what files:
lsof
  1. View the differences between two files:
diff [file 1] [file 2]
  1. Output the top -n lines of [file]:
head -n [number of lines] [file]
  1. Like head, but it outputs the last -n lines:
tail
  1. Checksum a file:
md5sum [file]
  1. Checksum every file in a directory:
md5deep [directory]
  1. Checksum a file (safer algorithm with no hash collisions):
sha1sum
  1. Same operation as md5deep, but using sha1:
sha1deep
  1. Call [command] every -n seconds, and display output:
watch -n [number of seconds] [command]
  1. Execute [command], print how long it took:
time [command]
  1. View files in home from largest to smallest:
du -a ~/ | sort -n -r | less
  1. remove spaces from filenames in current directory
rename -n 's/[\s]/<i>/g' *</i>
  1. change capitals to lowercase in filenames in current directory
rename 'y/A-Z/a-z/' *
          • Environment and Hardware:
  1. Print full date and time:
date
  1. Print the hostname of this machine:
echo $HOSTNAME
  1. Print information about current linux distro:
lsb_release -a
  1. Print linux kernel version:
uname -a
  1. Print information about kernel modules:
lsmod
  1. Configure kernel modules (never do this):
modprobe
  1. View Installed packages:
dpkg --get-selections
  1. Print environment variables:
printenv 
  1. List hardware connected via PCI ports:
lspci
  1. List hardware connected via USB ports:
lsusb
  1. Print hardware info stored in BIOS:
sudo dmidecode
  1. Dump captured data off of wireless card:
dumpcap
  1. Dump info about keyboard drivers:
dumpkeys
          • System Administration (Continued):
  1. Add a Personal Package Archive from Ubuntu Launchpad:
add-apt-repository
  1. Install a .deb file from command line:
sudo dpkg -i package.deb
        • Python:
  1. update pip (Python package manager):
pip install -U pip
  1. search pip repos
pip
  1. create a virtual python environment
virtualenv [dirname] --no-site-packages
  1. connect to a virtual python environment
source [dirname]/bin/activate
  1. disconnect from a python environment:
deactivate
  1. install package into virtual python environment from outsie:
pip install [packagename]==[version_number] -E [dirname]
  1. export python virtual environment into a shareable format:
pip freeze -E [dirname] &gt; requirements.txt
  1. import python virtual environment from a requirements.txt file:
pip install -E [dirname] -r requirements.txt
        • git (all commands must be performed in the same directory as .git folder):
  1. Start a new git project:
git init
  1. Clone a git (target can be specified either locally or remotely, via any number of protocols):
git clone [target]
  1. Commit changes to a git:
git commit -m "[message]"
  1. Get info on current repository:
git status
  1. Show change log for current repository:
git log
  1. Update git directory from another repository:
git pull [target]
  1. Push branch to other repository:
git push [target]
  1. Create a new branch:
git branch [branchname]
  1. Switch to target branch:
git checkout [branchname]
  1. Delete a branch:
git branch -d [branchname]
  1. Merge two branches:
git merge [branchname] [branchname]
      • Virtualization:
  1. clone a virtual machine (this works, it’s been tested):
vboxmanage clonehd [virtual machine name].vdi --format VDI ~/[target virtual machine name].vdi
  1. mount a shared virtual folder:
  2. you need to make sure you have the right kernel modules. You can do this with modprobe, but this package works instead in a ubuntu-specific way.
sudo apt-get install virtualbox-ose-guest-utils
sudo mount -t vboxsf [name of Shared folder specified in Virtualbox] [path of mountpoint]
      • mysql:
  1. Get help:
help
  1. Show databases:
show databases;
  1. Choose a database to use:
use [database name here];
  1. Show database schema:
show tables;
  1. Delete database:
DROP DATABASE [databasename];
  1. New database:
CREATE DATABASE [databasename];
  1. Create a new user:
CREATE USER [username@localhost] IDENTIFIED BY '[password]' ;
  1. Show users:
select * from mysql.user;
  1. Delete a user:
delete from mysql.user WHERE User='[user_name]';
  1. Give user access to all tables (make them root). the “%” means that they can sign in remotely, from any machine, not just localhost.:
grant all privileges on *.* to someusr@"%" identified by '[password]';
  1. give certain privileges to a user on a certain database:
grant select,insert,update,delete,create,drop on [somedb].* to [someusr]@["%"] identified by '[password]';
  1. Tell mysql to use new user priv policies:
flush privileges;
  1. change user password:
use mysql;

update user set password='[password]'(‘[newpassword]’) where User='[user_name]’ ;

  1. mysql command line args:
  1. export text file with commands to rebuild all mysql tables:
mysqldump [databasename] &gt; [dumpfilename.txt]
  1. restore from a dump:
mysql -u [username] -p &lt; [dumpfilename.txt]
  1. dump entire database:
mysqldump -u [username] -p --opt [databasename] &gt; [dumpfile.sql]
  1. restore from entire database dump:
mysql -u [username] -p --database=[databasename] &lt; [dumpfile.sql]

Install RPMForge on CentOS 6

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Import RPMForge Repository Key in CentOS 6


# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt

Install Mtop in CentOS 6

Once you’ve installed and enabled RPMForge repository, let’s install MTOP using following YUM command.


# yum install mtop

To start Mtop program, you need to connect to your MySQL Server, using following command.


# mysql -u root -p

Then you need to create separate user called mysqltop and grant privileges to him under your MySQL server. To do, this just run the following commands in mysql shell.


mysql> grant super, reload, process on *.* to mysqltop;
Query OK, 0 rows affected (0.00 sec)

mysql> grant super, reload, process on *.* to mysqltop@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

Let’s start the Mtop program.


# mtop

Sample Output:

load average: 0.03, 0.06, 0.08 mysqld 5.5.44-cll-lve up 4 day(s), 19:08 hrs
12 threads: 1 running, 0 cached. Queries/slow: 5/0 Cache Hit: 100.00%
Opened tables: 0  RRN: 332  TLW: 1  SFJ: 0  SMP: 0  QPS: 0

ID       USER     HOST             DB           TIME   COMMAND STATE        INFO
39965    mysqltop localhost                            Query                show full processlist

Monitor Remote MySQL Server using Mtop


# mtop  –host=remotehost –dbuser=username –password=password –seconds=1

http://serverfault.com/questions/28989/fdisk-l-like-list-of-partitions-and-their-types-for-lvm-logical-volumes

http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/

The fdisk shows a 256GB Drive. 50GB on root and the question is how to resize up to the 256GB drive for more space.

]# fdsik -l
-bash: fdsik: command not found
root@cpanel [~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   27G   21G  56% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/sda1             485M   96M  364M  21% /boot
/dev/mapper/VolGroup-lv_home
                      1.1T   43G  996G   5% /home
/dev/sdc1             917G  200M  871G   1% /backup
root@cpanel [~]# fdisk -l

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bb0e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      121602   976760832   8e  Linux LVM

Disk /dev/sda: 256.1 GB, 256060514304 bytes
255 heads, 63 sectors/track, 31130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062f67

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       31131   249545728   8e  Linux LVM

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
81 heads, 63 sectors/track, 382818 cylinders
Units = cylinders of 5103 * 512 = 2612736 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa9b15e21

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      382818   976760095+  83  Linux

Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_swap: 8355 MB, 8355053568 bytes
255 heads, 63 sectors/track, 1015 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/VolGroup-lv_home: 1193.7 GB, 1193690529792 bytes
255 heads, 63 sectors/track, 145124 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G   27G   21G  56% /
tmpfs                 3.9G     0  3.9G   0% /dev/shm
/dev/sda1             485M   96M  364M  21% /boot
/dev/mapper/VolGroup-lv_home
                      1.1T   43G  996G   5% /home
/dev/sdc1             917G  200M  871G   1% /backup

You can learn information about the volume group itself with ‘lvdisplay’, ‘vgscan’, ‘lvs’ and ‘vgdisplay’.

root@cpanel [~]# lvdisplay --maps
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                TYNmVB-vtiC-Gce6-FAsk-VXxi-CJDA-K4Pg8g
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-08-29 13:01:37 -0400
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Segments ---
  Logical extents 0 to 12799:
    Type                linear
    Physical volume     /dev/sda2
    Physical extents    0 to 12799


  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_home
  LV Name                lv_home
  VG Name                VolGroup
  LV UUID                PojYKo-WnwD-ywxH-6C0V-Ta7U-3sfE-x4szaI
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-08-29 13:01:39 -0400
  LV Status              available
  # open                 1
  LV Size                1.09 TiB
  Current LE             284598
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Segments ---
  Logical extents 0 to 238465:
    Type                linear
    Physical volume     /dev/sdb1
    Physical extents    0 to 238465

  Logical extents 238466 to 284597:
    Type                linear
    Physical volume     /dev/sda2
    Physical extents    12800 to 58931


  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_swap
  LV Name                lv_swap
  VG Name                VolGroup
  LV UUID                g2sdlK-rUv3-visr-NlMW-G3As-SOE2-07RDB1
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2014-08-29 13:04:05 -0400
  LV Status              available
  # open                 1
  LV Size                7.78 GiB
  Current LE             1992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Segments ---
  Logical extents 0 to 1991:
    Type                linear
    Physical volume     /dev/sda2
    Physical extents    58932 to 60923

LVS

lvs
  LV      VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home VolGroup -wi-ao---- 931.71g
  lv_root VolGroup -wi-ao---- 230.00g
  lv_swap VolGroup -wi-ao----   7.78g

Both drives are in an LVM configuration. This allows you to create logical partitions that include either or both drives.

/dev/mapper/VolGroup-lv_root exists on the SDA drive (Physical volume /dev/sda2) and
/dev/mapper/VolGroup-lv_home exists on both the SDA and SDB drive. To remove the LVM configuration, re-installation would be necessary, but we can re-configure the LVM configuration so that /dev/mapper/VolGroup-lv_root is larger.

# mount -t nfs 10.0.0.43:/mnt/vol1 /mnt/nfs
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

Start the rpcbind service and/or the nfs services to mount the NFS share.

# service rpcbind start
#service nfs start