Gentoo

From Indie IT Wiki

HOWTO: Run Script On System Start And System Shutdown

/etc/local.d/
├── README
├── booted.start
├── fixups.start
├── rebooted.stop
└── screen.stop
su - root

nano /etc/local.d/booted.start
#!/bin/sh
touch /booted

nano /etc/local.d/rebooted.stop
#!/bin/sh
touch /rebooted

HOWTO: Disable Keyboard CTRL+ALT+DEL Reboot

Comment out the line with ctrlaltdel in this file...

su - root
nano /etc/inittab
# What to do at the "Three Finger Salute".
# ca:12345:ctrlaltdel:/sbin/shutdown -r now

HOWTO: Ebuild Manual Install Process Steps

ebuild /path/to/ebuild fetch
ebuild /path/to/ebuild digest
ebuild /path/to/ebuild unpack   (and edit .c source code files if needed)
ebuild /path/to/ebuild compile
ebuild /path/to/ebuild test
ebuild /path/to/ebuild install
ebuild /path/to/ebuild qmerge
ebuild /path/to/ebuild clean

Thanks - https://www.gentoo.org/doc/en/handbook/2004.2/handbook-x86.xml?part=3&chap=6&style=printable

HOWTO: Reset The Manifest For An Ebuild On Checksum Failure

ebuild --force /usr/portage/dev-libs/geoip/geoip-1.4.8-r3.ebuild manifest

HOWTO: Reset Lost Root User Password

  1. Try Webmin. If not, then...
  2. Grub, e, init=bash at end of kernel line, b

Single user mode on Gentoo does prompt for username and password, so this is not the answer for a lost root password. If you do need to reset your root password try appending 'init=/bin/bash' instead and then 'mount -o remount,rw /' to give you a writable file system. Don't forget to 'sync' any changes to disk before rebooting.

How to Set up Dual Monitors for Intel Graphics with RandR 1.2

There are 2 modes for dual-head display: clone and extend. This command will give you an extended desktop to the right of the main display.

xrandr --output VGA1 --right-of HDMI1

https://01.org/linuxgraphics/documentation/how-set-dual-head-intel-graphics-randr-1.2

Installing The ClearType Microsoft Fonts

http://www.microsoft.com/typography/ClearTypeFonts.mspx

These fonts are really nice, especially Calibri.

To get them, follow these instructions:-

  1. Install the package 'cabextract'.
  2. Download the free PowerPointViewer from the Microsoft web site.
  3. cabextract -F ppviewer.cab PowerPointViewer.exe
  4. cabextract -F '*.TT?' -d /usr/share/fonts/vista /path/to/folder/with/ppviewer.cab
  5. fc-cache -fv

Enjoy.

Thanks to: http://www.oooninja.com/2008/01/calibri-linux-vista-fonts-download.html

ERROR: Failed WHIRLPOOL Verification

If you cannot emerge BASH because it fails the new WHIRLPOOL Verification checks on source files, then do the following...

Switch to Python 2.7 (which has some internal whirlpool verification)

eselect python list

 Available Python interpreters:
 [1]   python2.6 *
 [2]   python2.7
 [3]   python3.1

eselect python set 2

Edit out the line in /usr/portage/metadata/layout.conf...

nano /usr/portage/metadata/layout.conf
# manifest-hashes = SHA256 SHA512 WHIRLPOOL
manifest-hashes = SHA256 SHA512
cd /usr/portage/app-shells/bash
mv Manifest Manifest.old
ebuild bash-4.2_p37.ebuild digest
emerge -1uv =app-shells/bash-4.2_p37

ERROR: !!! ParseError: Profile contains unsupported EAPI '5':

!!! Unable to parse profile: '/etc/make.profile'
!!! ParseError: Profile contains unsupported EAPI '5': '/usr/portage/profiles/default/linux/x86/13.0/eapi'
!!! Your current profile is invalid. If you have just changed your profile
!!! configuration, you should revert back to the previous configuration.
!!! Allowed actions are limited to --help, --info, --search, --sync, and
!!! --version.

Fix...

eselect profile list

Available profile symlink targets:

 [1]   default/linux/x86/13.0
 [2]   default/linux/x86/13.0/selinux
 [3]   default/linux/x86/13.0/desktop
 [4]   default/linux/x86/13.0/desktop/gnome
 [5]   default/linux/x86/13.0/desktop/kde
 [6]   default/linux/x86/13.0/developer
 [7]   hardened/linux/x86
 [8]   hardened/linux/x86/selinux
 [9]   hardened/linux/uclibc/x86

Select hardened...

eselect profile set 7

Available profile symlink targets:

 [1]   default/linux/x86/13.0
 [2]   default/linux/x86/13.0/selinux
 [3]   default/linux/x86/13.0/desktop
 [4]   default/linux/x86/13.0/desktop/gnome
 [5]   default/linux/x86/13.0/desktop/kde
 [6]   default/linux/x86/13.0/developer
 [7]   hardened/linux/x86 *
 [8]   hardened/linux/x86/selinux
 [9]   hardened/linux/uclibc/x86

OR

Select 0 as the target...

eselect profile set 0

Now update portage...

emerge -upv portage

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild     U  ] app-shells/bash-4.2_p37 [4.1_p9] USE="net nls (readline%*) -afs -bashlogger -examples -mem-scramble -plugins -vanilla" 95 kB
[ebuild  N     ] app-crypt/mhash-0.9.9.9-r1  USE="-static-libs" 910 kB
[ebuild  N     ] dev-python/python-mhash-1.4  17 kB
[ebuild     U  ] sys-apps/portage-2.1.11.50 [2.1.10.41] USE="(ipc) -build -doc -epydoc (-pypy2_0) -python2 -python3 (-selinux) -xattr%" 875 kB

Total: 4 packages (2 upgrades, 2 new), Size of downloads: 1,896 kB

* IMPORTANT: 5 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.

Installation

http://en.gentoo-wiki.com/wiki/Safe_Cflags

http://www.gentoo.org/doc/en/gentoo-x86-quickinstall.xml

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml

http://en.gentoo-wiki.com/wiki/RAID/Software

http://en.gentoo-wiki.com/wiki/Software_RAID_Install

http://en.gentoo-wiki.com/wiki/Custom_Stage4

# cat /root/misc/stage4.excl 
/dev/*
/home/*
/mnt/*
/proc/*
/sys/*
/tmp/*
/usr/portage/distfiles/*
/var/tmp/*
$ cat /boot/grub/grub.conf 
default 0
timeout 3
title Gentoo Linux 2.6.37-r4
root (hd0,0)
kernel /boot/kernel-2.6.37-gentoo-r4 root=/dev/md3
# /etc/fstab: static file system information.
# <fs>			<mountpoint>	<type>		<opts>		<dump/pass>
/dev/md1		/boot		ext3		noauto,noatime	1 2
/dev/md2		none		swap		sw		0 0
/dev/md3		/		ext3		noatime		0 1
/dev/md4		/home		ext3		noatime		0 1
$ cat /etc/portage/package.use
sys-libs/glibc userlocales
sys-power/nut -usb
sys-apps/iproute2 -minimal
net-nds/openldap -minimal ssl
dev-lang/php apache2 ctype curl gd hash ldap mysql nls pcre pdo session simplexml unicode xml
net-misc/dhcp -minimal
media-libs/gd jpeg png
dev-perl/GD jpeg png
net-dialup/mgetty -fax
mail-mta/sendmail sasl
mail-client/mutt -crypt imap
dev-db/mysql -minimal
net-analyzer/rrdtool -python perl
sys-apps/smartmontools -minimal
mail-filter/MailScanner f-prot spamassassin
net-nds/openldap -ssl
app-editors/nano -minimal
x11-libs/cairo svg
$ cat /etc/portage/package.keywords
sys-libs/pam ~amd64
net-nds/phpldapadmin ~amd64
sci-misc/boinc ~amd64
net-proxy/squid ~amd64
net-analyzer/squidsites ~amd64
net-firewall/fwanalog ~* *
net-misc/hylafax ~amd64
net-dialup/mgetty ~amd64
net-analyzer/calamaris ~amd64
mail-filter/spamassassin ~amd64
mail-filter/MailScanner ~amd64
net-mail/tnef ~amd64
dev-perl/Filesys-Df ~amd64
app-admin/webmin ~amd64
net-firewall/shorewall-common ~amd64
net-firewall/shorewall-perl ~amd64

Kernel Config Files

config-server-x86_64-2.6.37-gentoo-r4

config-desktop-i686-2.6.38-gentoo-r6

http://kernel.xc.net/

http://how-to.wikia.com/wiki/How_to_configure_the_Linux_kernel

Favourite Kernel Config Options (Just For Fun)

B.A.T.M.A.N. Advanced Meshing Protocol (CONFIG_BATMAN_ADV)
VMware Balloon Driver (CONFIG_VMWARE_BALLOON)

/dev files

Make a few basic device nodes needed for booting

mknod -m 660 /mnt/gentoo/dev/console c 5 1
mknod -m 660 /mnt/gentoo/dev/null c 1 3
mknod -m 600 /mnt/gentoo/dev/initctl p
mknod -m 660 /mnt/gentoo/dev/tty1 c 4 1

Chrooting

mount -t proc none /mnt/gentoo/proc
mount -o bind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash 
env-update
source /etc/profile
touch /etc/mtab

Server Administration

Logging In

ssh username@ipaddress
(type in your ssh passphrase)
su - root
(type in the root password)
screen -r

Logging Out

Ctrl+A D
Ctrl+D
Ctrl+D

Rebooting The Server

reboot

Power Off The Server

poweroff

How Do I Check Something Has Started On Boot?

rc-status --all

How Do I Test Something Before I Make It Start On Boot?

/etc/init.d/<script-name> start

How Do I Make Something Start On Boot?

ls -lah /etc/init.d/    (to find out scriptname)
rc-update add <script-name> default

How Do I Stop Something Starting On Boot?

ls -lah /etc/init.d/    (to find out scriptname)
rc-update del <script-name> default

Links

http://www.littlefield.info/linux/gentoo_linux_faqs.txt

Determine Filesystem Formatting Type

blkid /dev/sda4
/dev/sda4: UUID="be475869-5637-447b-a3cf-6a744cd813ce" TYPE="ext4"

blkid /dev/sdb1
/dev/sdb1: LABEL="4GB-USB" UUID="17D0-8533" TYPE="vfat"

Turn Off Hardware Beep Sound For Terminal

http://www.cyberciti.biz/faq/how-to-linux-disable-or-turn-off-beep-sound-for-terminal/

CUPS Print Server

Error - lpstat: Unable to connect to server

Edit the file /etc/cups/client.conf and change the ServerName line to your full hostname...

echo "ServerName `hostname -f`" > /etc/cups/client.conf

Fixing Various RAID Devices Error

If you see this error when starting up:-

* Starting up RAID devices ...                      [ !! ]

And you see this error when shutting down:-

mdadm: fail to stop array /dev/md0: Device or resource busy

...then remove the word raid from the RC_VOLUME_ORDER variable in /etc/conf.d/rc

RC_VOLUME_ORDER="evms lvm dm"


Change Preferred Minor MD Superblock On Software RAID Hard Disk

A hard disk drive failure on one of my servers prompted a manual software RAID 1 check and resync. Using good old SystemRescueCD, this was done but in doing so it inadvertently changed the preferred minor md superblock number on the array's hard disk drives from 3 to 124.

mdadm --misc --examine /dev/sda3 |grep 'Preferred Minor'
Preferred Minor : 124

To fix this, stop the array and reassemble it again but update the superblock as it runs. Make sure you declare which hard disk drive partitions you are using as you assemble:-

mdadm --verbose --misc --stop /dev/md124
mdadm --verbose --assemble --update=super-minor --run /dev/md3 /dev/sda3 /dev/sdb3

To check it has worked, run the following 2 commands:-

mdadm --misc --examine /dev/sda3 |grep 'Preferred Minor'
Preferred Minor : 3
cat /proc/mdstat
md3 : active raid1 sdb3[0] sda3[1]
     10490368 blocks [2/2] [UU]

How to Quickly Find and Replace Text Across Multiple Files with One Command

perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt

[RFC/RFT PATCH v3] sched: automated per tty task groups

This patch gives you the much talked about peformance boost... and yes, wow. :-)

You have to install the very latest kernel sources, then follow the instructions at http://forums.gentoo.org/viewtopic-t-852922.html

Here are my notes...

vaio-sabayon ~ # emerge =sys-kernel/vanilla-sources-2.6.37_rc2

vaio-sabayon ~ # eselect kernel list
Available kernel symlink targets:
  [1]   linux-2.6.34-gentoo-r1 *
  [2]   linux-2.6.35-gentoo-r10
  [3]   linux-2.6.36-gentoo
  [4]   linux-2.6.37-rc2

vaio-sabayon ~ # eselect kernel set 4

vaio-sabayon ~ # cd /usr/src/

vaio-sabayon /usr/src # ll
total 88K
drwxr-xr-x  7 root root 4.0K 2010-11-17 23:08 .
drwxr-xr-x 18 root root 4.0K 2010-06-17 04:35 ..
-rw-r--r--  1 root root  59K 2006-01-03 22:33 .config
-rw-r--r--  1 root root    0 2005-11-15 18:26 .keep
lrwxrwxrwx  1 root root   16 2010-11-17 23:08 linux -> linux-2.6.37-rc2
drwxr-xr-x 24 root root 4.0K 2010-06-25 12:55 linux-2.6.34-gentoo-r1
drwxr-xr-x 24 root root 4.0K 2010-10-19 10:51 linux-2.6.35-gentoo-r10
drwxr-xr-x 23 root root 4.0K 2010-10-22 20:47 linux-2.6.36-gentoo
drwxr-xr-x 23 root root 4.0K 2010-11-17 23:05 linux-2.6.37-rc2
drwxr-xr-x  7 root root 4.0K 2009-10-07 16:24 rpm

vaio-sabayon /usr/src # cd linux

vaio-sabayon /usr/src/linux # ll
total 484K
drwxr-xr-x 23 root root 4.0K 2010-11-17 23:05 .
drwxr-xr-x  7 root root 4.0K 2010-11-17 23:08 ..
drwxr-xr-x 26 root root 4.0K 2010-11-17 23:05 arch
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 block
-rw-r--r--  1 root root  19K 2010-10-20 21:30 COPYING
-rw-r--r--  1 root root  92K 2010-10-20 21:30 CREDITS
drwxr-xr-x  3 root root 4.0K 2010-11-17 23:05 crypto
drwxr-xr-x 87 root root  12K 2010-11-17 23:05 Documentation
drwxr-xr-x 89 root root 4.0K 2010-11-17 23:05 drivers
drwxr-xr-x 37 root root 4.0K 2010-11-17 23:05 firmware
drwxr-xr-x 70 root root 4.0K 2010-11-17 23:05 fs
-rw-r--r--  1 root root  936 2010-10-20 21:30 .gitignore
drwxr-xr-x 20 root root 4.0K 2010-11-17 23:05 include
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 init
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 ipc
-rw-r--r--  1 root root 2.5K 2010-11-17 23:04 Kbuild
-rw-r--r--  1 root root  252 2010-11-17 23:04 Kconfig
drwxr-xr-x  8 root root 4.0K 2010-11-17 23:05 kernel
drwxr-xr-x  7 root root 4.0K 2010-11-17 23:05 lib
-rw-r--r--  1 root root 4.0K 2010-10-20 21:30 .mailmap
-rw-r--r--  1 root root 179K 2010-11-17 23:04 MAINTAINERS
-rw-r--r--  1 root root  51K 2010-11-17 23:04 Makefile
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 mm
drwxr-xr-x 52 root root 4.0K 2010-11-17 23:05 net
-rw-r--r--  1 root root  18K 2010-11-17 23:04 README
-rw-r--r--  1 root root 3.3K 2010-10-20 21:30 REPORTING-BUGS
drwxr-xr-x  9 root root 4.0K 2010-11-17 23:05 samples
drwxr-xr-x 13 root root 4.0K 2010-11-17 23:05 scripts
drwxr-xr-x  8 root root 4.0K 2010-11-17 23:05 security
drwxr-xr-x 21 root root 4.0K 2010-11-17 23:05 sound
drwxr-xr-x  5 root root 4.0K 2010-11-17 23:05 tools
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 usr
drwxr-xr-x  3 root root 4.0K 2010-11-17 23:05 virt

vaio-sabayon /usr/src/linux # cp /home/paully/Desktop/sched.patch .
`/home/paully/Desktop/sched.patch' -> `./sched.patch'

vaio-sabayon /usr/src/linux # ll
total 496K
drwxr-xr-x 23 root root 4.0K 2010-11-17 23:08 .
drwxr-xr-x  7 root root 4.0K 2010-11-17 23:08 ..
drwxr-xr-x 26 root root 4.0K 2010-11-17 23:05 arch
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 block
-rw-r--r--  1 root root  19K 2010-10-20 21:30 COPYING
-rw-r--r--  1 root root  92K 2010-10-20 21:30 CREDITS
drwxr-xr-x  3 root root 4.0K 2010-11-17 23:05 crypto
drwxr-xr-x 87 root root  12K 2010-11-17 23:05 Documentation
drwxr-xr-x 89 root root 4.0K 2010-11-17 23:05 drivers
drwxr-xr-x 37 root root 4.0K 2010-11-17 23:05 firmware
drwxr-xr-x 70 root root 4.0K 2010-11-17 23:05 fs
-rw-r--r--  1 root root  936 2010-10-20 21:30 .gitignore
drwxr-xr-x 20 root root 4.0K 2010-11-17 23:05 include
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 init
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 ipc
-rw-r--r--  1 root root 2.5K 2010-11-17 23:04 Kbuild
-rw-r--r--  1 root root  252 2010-11-17 23:04 Kconfig
drwxr-xr-x  8 root root 4.0K 2010-11-17 23:05 kernel
drwxr-xr-x  7 root root 4.0K 2010-11-17 23:05 lib
-rw-r--r--  1 root root 4.0K 2010-10-20 21:30 .mailmap
-rw-r--r--  1 root root 179K 2010-11-17 23:04 MAINTAINERS
-rw-r--r--  1 root root  51K 2010-11-17 23:04 Makefile
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 mm
drwxr-xr-x 52 root root 4.0K 2010-11-17 23:05 net
-rw-r--r--  1 root root  18K 2010-11-17 23:04 README
-rw-r--r--  1 root root 3.3K 2010-10-20 21:30 REPORTING-BUGS
drwxr-xr-x  9 root root 4.0K 2010-11-17 23:05 samples
-rw-r--r--  1 root root  11K 2010-11-17 23:08 sched.patch
drwxr-xr-x 13 root root 4.0K 2010-11-17 23:05 scripts
drwxr-xr-x  8 root root 4.0K 2010-11-17 23:05 security
drwxr-xr-x 21 root root 4.0K 2010-11-17 23:05 sound
drwxr-xr-x  5 root root 4.0K 2010-11-17 23:05 tools
drwxr-xr-x  2 root root 4.0K 2010-11-17 23:05 usr
drwxr-xr-x  3 root root 4.0K 2010-11-17 23:05 virt

vaio-sabayon /usr/src/linux # cat sched.patch | patch -p1
patching file include/linux/sched.h
Hunk #3 succeeded at 1935 (offset -1 lines).
patching file kernel/sched.c
Hunk #2 succeeded at 616 (offset 10 lines).
Hunk #3 succeeded at 2020 (offset 10 lines).
Hunk #4 succeeded at 7967 (offset -17 lines).
Hunk #5 succeeded at 8497 (offset -17 lines).
Hunk #6 succeeded at 8522 (offset -17 lines).
patching file kernel/fork.c
patching file drivers/tty/tty_io.c
patching file kernel/sched_autogroup.h
patching file kernel/sched_autogroup.c
patching file kernel/sysctl.c
patching file init/Kconfig
patching file Documentation/kernel-parameters.txt

vaio-sabayon /usr/src/linux # make && make modules_install

vaio-sabayon ~ # cp arch/x86/boot/bzImage /boot/kernel-2.6.37-rc2

vaio-sabayon ~ # cp System.map /boot/System.map-2.6.37-rc2

vaio-sabayon ~ # cp .config /boot/config-2.6.37-rc2

vaio-sabayon ~ # reboot

vaio-sabayon ~ # cat /proc/sys/kernel/sched_autogroup_enabled
1

vaio-sabayon ~ # uname -r
2.6.37-rc2

Oh yeah... very nice - much faster and smoother - seriously :-)

Bluetooth Headset With Skype

echo "net-wireless/bluez test-programs" >> /etc/portage/package.use 
emerge -pv net-wireless/bluez
emerge -q net-wireless/gnome-bluetooth

http://en.gentoo-wiki.com/wiki/Bluetooth_headset

ERROR: Gnome: DBus error org.gtk.Private

Open gconf-editor, go to apps>nautilus>preferences and uncheck media_automount and media_automount_open

Manually Fixing Broken Portage

http://www.gentoo.org/proj/en/portage/doc/manually-fixing-portage.xml

Tinderbox Precompiled Packages

http://tinderbox.dev.gentoo.org/default-linux/amd64/sys-apps/

Getting Beautiful Fonts

http://www.kev009.com/wp/2009/12/getting-beautiful-fonts-in-gentoo-linux/

Verbose Check A Disk Drive

fsck.ext3 -f -v -C0 -p /dev/sdc1

Shoreline Firewall (Shorewall) Tips

To list the connections from an IP address.

conntrack -L -s 192.168.0.103

To drop all the connections from an IP address.

conntrack -D -s 192.168.1.102

It can take up to 1 minute to drop all of them, so be patient. You can then restart shorewall and be certain any NEW connections (not ESTABLISHED ones) will be accounted for.

How To Read IPTables Logs

Jul 22 20:43:22 fw kernel: IN=eth2 OUT= MAC=xxx SRC=srcip DST=dstip LEN=40 TOS=0x00
PREC=0x00 TTL=52 ID=21125 PROTO=TCP SPT=5653 DPT=3513 WINDOW=1400 RES=0x00 ACK URGP=0

IN = Input interface
OUT = Output interface
MAC = Ethernet hardware address (aka MAC address)
SRC = Source IP address
DST = Destination IP address
LEN = Packet length
TOS = Type of Service (for packet prioritization)
PREC = Precedent bits
TTL = Time to Live
ID = Packet identifier
PROTO = Protocol (eg. TCP, UDP)
SPT = Source port
DPT = Destination port
WINDOW = Size of TCP window
RES = Reserved bits
ACK = Acknowledge bit set
URGP = Urgent packet


Apr  4 12:30:02 gateway klogd: Shorewall:net_dnat:DNAT:IN=eth2 OUT= MAC=14:d6:4d:52
SRC=123.456.789.0 DST=10.0.0.2 LEN=60 TOS=0x00 PREC=0x00 TTL=50 ID=32698 DF PROTO=TCP
SPT=57674 DPT=11350 WINDOW=5840 RES=0x00 SYN URGP=0

Rsync From Linux EXT Filesystem To Windows / MS-DOS VFAT Filesystem

You will get various errors when copying from a Linux to a Windows filesystem.

2012/04/30 00:00:11 [14252] building file list
2012/04/30 00:00:11 [14252] .d...pog... home/
2012/04/30 00:00:11 [14252] rsync: chown "/media/sda1/home/" failed: Permission denied (13)

Add the following options to stop the errors.

rsync -a --no-o --no-p --no-g --safe-links --modify-window 1 --stats /home/ /media/sda1/home/

http://www.monperrus.net/martin/backup+from+ext3+to+vfat+with+rsync

How to speed up X11 forwarding in SSH

http://xmodulo.com/2013/07/how-to-speed-up-x11-forwarding-in-ssh.html

cat ~/.ssh/config
 Host remote_host.com
   Compression yes
   ForwardX11 yes
   Ciphers blowfish-cbc,arcfour

SSH Login Without Password Using ssh-keygen & ssh-copy-id

ssh-keygen -t rsa      (and choose no password)
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-host
ssh user@remote-host

SSH Login With 1 Password Using Keychain

As root...

emerge keychain

As normal user...

keychain ~/.ssh/id_rsa
. ~/.keychain/$HOSTNAME-sh
. ~/.keychain/$HOSTNAME-sh-gpg

Add the above 3 lines to your BASH shell startup file...

nano ~/.bashrc

Now when you login to a server, it will not ask you for your key passphrase...

ssh user@server.name

Rsync Over SSH

Copy from remote (on a non-standard port) to local, just 1 file...

/usr/bin/rsync -v -h -a --include=filename.ext --exclude=* -e "ssh -p 2222" user@123.456.789.0:~/remotedir/ ~/localdir/

Copy from local to remote

/usr/bin/rsync -a -e ssh ~/my/local/folder/ username@192.168.0.x:~/path/to/folder/

Copy from local to remote, with extra options (e.g. disable host checking) wrapped with ' single quotes

/usr/bin/rsync -a -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' ~/my/local/folder/ username@192.168.0.x:~/path/to/folder/

Copy from remote to local

/usr/bin/rsync -a -e ssh username@192.168.0.x:~/path/to/folder/ ~/my/local/folder/

See Limit Bandwidth below...

Spaces In File Or Folder Name

If you want to rsync a file or folder with spaces in the file name, you have to escape and put double-quotes around both the local and remote shell parts of the command.

e.g.

/usr/bin/rsync -a -e ssh "username@192.168.0.x:\"~/path/to/folder/with spaces\"" ~/my/local/folder/

e.g.

rsync -v -a --exclude='*FLAC*' -e ssh "username@server:\"Music/Dream Theater\"" /home/username/Music/

Limit Bandwidth

Option 1 - use the rsync option to limit I/O bandwidth, in KB per second...

/usr/bin/rsync --bwlimit=2000 -a -e ssh ~/my/local/folder/ user@remote:~/path/to/folder/

https://www.dalemacartney.com/2012/09/08/bandwidth-throttling-with-rsync/

Option 2 - use the lightweight userspace bandwidth shaper trickle, also in KB per second...

/usr/bin/rsync -a -e trickle -d 2000 ssh ~/my/local/folder/ user@remote:~/path/to/folder/

Option 3 - use both rsync and trickle maybe, just remember that trickle has up and down limits...

/usr/bin/rsync --bwlimit=2000 -a -e trickle -d 2000 ssh ~/my/local/folder/ user@remote:~/path/to/folder/

How to disable SSH host key checking

ssh -o LogLevel=quiet -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no peter@192.168.0.100

http://linuxcommando.blogspot.co.uk/2008/10/how-to-disable-ssh-host-key-checking.html

Overlay Names

If you have a local overlay, you can name it so that eix uses it properly in results. Just create the file repo_name in a sub-directory called 'profiles'.

mkdir -p /usr/local/portage/profiles
echo "local" > /usr/local/portage/profiles/repo_name

Now when you run eix-update, it shows the local overlay name.

eix-update

Reading Portage settings ..
Building database (/var/cache/eix) ..
[0] "gentoo" /usr/portage/ (cache: metadata-md5-or-flat)
     Reading category 154|154 (100%) Finished             
[1] "local" /usr/local/portage (cache: parse|ebuild*#metadata-md5#metadata-flat#assign)
     Reading category 154|154 (100%) EMPTY!
Applying masks ..
Calculating hash tables ..
Writing database file /var/cache/eix ..
Database contains 15543 packages in 154 categories.

Intel i915 Video Kernel Mode Setting - KMS

How To Disable

i915.modeset=0

Use IPTables Firewall To Block An IP Address

/sbin/iptables -I INPUT -s {IP-HERE} -j DROP