I am one of those that skipped the Microsoft Windows train. I started out using MS-DOS in 1984, UNIX in 1987, and Linux around 1991. I have never liked Windows, everything seem to be hidden away in odd places, not to mention the problems with viruses etc. that have created huge problems during the years. For me the ultimate operating system is Linux. It is fast, you do not need the fastest and latest computer around, safe, it is based on the UNIX model with different users and security between these users, free, you can just download it without being afraid that the police will show up at your doorstep for having illegal copies of software, and open source, you may freely change, or edit the code, this also makes it easy to create safe and sound code as the code will be audited by a huge number of people.
Why use Microsoft Windows when Linux is around?
This is a small collection of different kinds of notes etc. I have written while setting up my computers. It is put here mainly for my own use, to have all information in one place, but may be of some use for others. Please feel free to comment my writings.
By the way, I take no responsibility whatsoever for you hosing your system using the information on this web page. What I have written worked for me, but may not do so for you. If you encounter problems though, and find a solution, please let me know, and I will update this page.
Print a certain field (in this case number 11) delimited by white space
If you only want to ping a certain host, i.e. not use SNMP at all, set "Host Template" to "None" and make sure that "SNMP Community" is blank. Set up the "Unix - Ping Latency" graph template as usual.
To copy a CD/DVD (this works for both data and unencrypted movies)
dd if=/dev/dvd of=dvdcopy.iso cdrecord dev=/dev/dvd dvdcopy.iso
To burn backups on DVD do, for a folder do
and for an iso file do
Create ISO files with
Some more information is available in the evolution tip.
Converts file names from one encoding to another. Quite handy converting file names to/from UTF8 etc.
As mentioned in the man-page "diction - print wordy and commonly misused phrases in sentences".
To check the text in the file textfile.txt, do
This will make diction complain about mistakes typically made by beginners, and suggest better wording, if any. Quite handy for someone who do not have English as first language.
To create a dovecot cert, first configure
/etc/pki/dovecot/certs/ /etc/pki/dovecot/private/
Find all files in or below current directory, .,
modified in the last day, -mtime -1, that are not
directories, \! -type d, and execute the list
function on them, ls -l
Find all pdf's, no matter what case, in or below current
directory and feed them to acroread. -print 0 and
xargs -0 takes care of directories and/or files
containing space etc.
To be able to handle mailto: URL:s go to about:config and
change network.protocol-handler.external.mailto
to true, then add the
network.protocol-handler.app.mailto preference
name (right click in the about:config window, chose
new->string and follow the instructions, for value write
the path and name of your e-mail application,
/usr/bin/thunderbird in my case.)
To split a mailbox into separate text files, do
When using mc (Midnight Commander) in the gnome terminal you will notice that F10 brings up the gnome terminal menu, instead of being sent to mc. To fix this, in the gnome terminal chose the "edit" menu, then "keyboard shortcuts", and in the new window check "Disable menu shortcut key (F10 by default)".
To see the contents of an initrd-file
To extract
mkdir /tmp/initrd cd /tmp/initrd gunzip --to-stdout /boot/initrd-2.6.17-1.2145_FC5.img | cpio -i
From the boot.iso file copy the install kernel and initrd to the boot partition and update grub to start that kernel.
# wget http://download.fedora.redhat.com/pub/fedora/linux/core/5/i386/os/images/boot.iso # mkdir -p /mnt/temp # mount -r -o loop boot.iso /mnt/temp # cp /mnt/temp/isolinux/vmlinuz /boot/vmlinuz-fc5 # cp /mnt/temp/isolinux/initrd.img /boot/initrd-fc5.img # umount /mnt/temp # rmdir /mnt/temp
Added lines to /etc/grub.conf (copy one of the
existing grub entries but change the kernel and initrd lines.)
title Fedora Core 5 install
root (hd0,0)
kernel /vmlinuz-fc5
initrd /initrd-fc5.img
Please note that if do not have your /boot
directory as its own partition, you have to append
/boot to the kernel and initrd images above.
First copy the contents of the old hard-drive to the new one (mounted as /mnt/disk) (note; zeros i.e. 0, not big o's, i.e. O):
find / -xdev -print0 | cpio -pa0V /mnt/disk
(make sure that all partitions are copied, if you have more than one) then halt the computer. Remove the old hard-drive, and install the new one in its place. Start with a live system on a USB-stick, or a DVD. When the live system has started, mount the new hard-drive as /mnt/disk, then mount the following:
mount -t proc none /mnt/disk/proc mount -o bind /dev /mnt/disk/dev
Make sure that the disk UUID:s are correct in /mnt/disk/etc/fstab and /mnt/disk/boot/grub/menu.lst, correct if wrong (you can get the UUID of your new disk by issuing the cammand "blkid").
Now you can install the boot loader (grub) into the MBR by issuing the following command:
chroot /mnt/disk grub-install /dev/sda
Cross your fingers, and restart.
Stop SSH scans with
iptables -A INPUT -i eth0 -p tcp -m tcp --dport 22 -m conntrack \\
--ctstate NEW -m recent --set --name sshscans --rsource
iptables -A INPUT -m recent --rcheck --seconds 60 --hitcount 10 \\
--name sshscans --rsource -j DROP
or
# Then setup the ssh reject trap. $IPTABLES -A INPUT -p tcp --syn --dport 22 -m recent --name sshattack --set $IPTABLES -A INPUT -p tcp --dport 22 --syn -m recent --name sshattack \\ --rcheck --seconds 120 --hitcount 3 -j LOG --log-prefix 'SSH REJECT: ' $IPTABLES -A INPUT -p tcp --dport 22 --syn -m recent --name sshattack \\ --rcheck --seconds 120 --hitcount 3 -j REJECT --reject-with tcp-reset
With the values present a given site gets three tries within a 120 second interval. Once that is exceeded it is locked out until the retry count drops below 3 in 2 minutes. This means ALL attacks get blocked. It also means that if you screw up your password three times you can still get in if you wait a little bit.
To keep the two latest kernels, including the running one, do
# yum install yum-utils # package-cleanup --oldkernels
A guide describing how to rebuild kernels can be found at http://home.swbell.net/kwgow/kernel/steps.html
To find out what ports are open
or, for a certain port
To create a certificate for apache, do
openssl genrsa -out httpd.key 1024 openssl rsa -in httpd.key -pubout openssl req -new -key httpd.key -out httpd.csr openssl x509 -req -days 365 -in httpd.csr -signkey httpd.key -out httpd.crt openssl x509 -text -in httpd.crt mv httpd.crt /etc/httpd/conf/ssl.crt/ mv httpd.key /etc/httpd/conf/ssl.key/
To rename multiple files (*.cpp into *.c)
or try
for file in *.cpp
do mv ${file} ${file%cpp}c
done
Copy a local file or directory to a remote machine using rsync and ssh
To make smartd check SATA discs, add the following to
/etc/smartd.conf
/dev/sda -d ata -H -m root@localhost.localdomain /dev/sdb -d ata -H -m root@localhost.localdomain
And to check status, do
SSH-keys description:
SSH-agent description:
SSH programs for Windows:
To get the file modification date (well, not exactly, but the
commit time of the file) for checkout, update, switch, and
revert, add the following to the
~/.subversion/config file
[miscellany] ### Set use-commit-times to make checkout/update/switch/revert ### put last-committed timestamps on every file touched. use-commit-times = yes
To create a subversion repository, in this case named myprog, and filling it with data from the directory local_copy, and finally taking a look at the repository, do
svnadmin create /usr/local/svn/myprog svn import local_copy file:///usr/local/svn/myprog -m "First Import" svn list --verbose file:///usr/local/svn/myprog