Linux Tips

Disclaimer: This list is AS IS and may contain all kinds of mistakes and misinformation. Use it at your own risk. Don't try something here on something important and then come to me if it screws up. I accept no responsibility. There is no warranty, express or implied. If you disagree with these terms, do not read on and exit now.

A

Apache start/stop/restart

Issuing:
/etc/rc.d/init.d/httpd (stop) (start) (restart) (status) (reload) (graceful) will do it.

Take a look a /etc/rc.d/init.d/http and you'll see the possibilities listed.

(Apache 1.3.27)
usage: /usr/sbin/apachectl (start|stop|restart|fullstatus|status|graceful|configtest|help)

start - start httpd
startssl - start httpd with SSL enabled
stop - stop httpd
restart - restart httpd if running by sending a SIGHUP or start if
not running
fullstatus - dump a full status screen; requires lynx and mod_status enabled
status - dump a short status screen; requires lynx and mod_status enabled
graceful - do a graceful restart by sending a SIGUSR1 or start if not running
configtest - do a configuration syntax test
help (or no argument) - the above info

I was able to add a virtual host www.pentium.cxm using IP 192.168.1.2 by adding this to /etc/httpd/conf/httpd.conf:

NameVirtualHost 192.168.1.2

<VirtualHost 192.168.1.2>
ServerName www.pentium.cxm

DocumentRoot /home/httpd/html

ErrorLog logs/www.pentium.cxm-errorlog

</VirtualHost>

Restart Apache to reread the config file when you're done. Of course you'll need a DNS or line in the HOSTS file to reference it.

config file - You can find apache's config file by issuing httpd -V. The combination of SERVER_ROOT and SERVER_CONFIG_FILE will lead you to it.

Redirect - If you have changed domains and want the old domain to redirect to the new one:

apropos - apropos keyword is the same as man -k keyword.. Use it when you don't know the command to do something. It will search the man database for the keyword. If the manpage is in man 5, type man 5 command.

apt - kpackage has disappeared and redhat-config-packages sucks, but it doesn't matter since apt has been ported to rpm-based distros.

B

bashrc - After making changes to .bashrc or .bash_profile, you can either log out and back in or run the "source" command e.g. source .bashrc.

alias rm='rm -i'
alias cp='cp -i'

alias mv='mv -i'

alias ping='ping -c 4'

alias du='du -shc'
alias df='df -h'
alias ls='ls -Fa'

alias x='startx'

alias sd='shutdown -h now'

alias rb='shutdown -r now'

alias nic0='kwrite /etc/sysconfig/network-scripts/ifcfg-eth0'
alias nic1='kwrite /etc/sysconfig/network-scripts/ifcfg-eth1'
alias untar='tar -xzvf'

alias p1='ping -c 4 192.168.1.1'

alias p2='ping -c 4 192.168.1.2'

alias p3='ping -c 4 192.168.1.3'
alias mntc='mount -v /mnt/cdrom'

alias mntf='mount -v /mnt/floppy'

alias umntc='umount -v /mnt/cdrom'

alias umntf='umount -v /mnt/floppy'

alias kd='kedit'
alias mf='mount -t ext2 /dev/fd0 /mnt/floppy'

alias mntf='mount -v /mnt/floppy'
alias cgi='cd /home/httpd/cgi-bin'

alias httpdrestart='/etc/rc.d/init.d/httpd restart'

alias namedrestart='/etc/rc.d/init.d/named restart'

alias httpdreload='/etc/rc.d/init.d/httpd reload'

alias namedreload='/etc/rc.d/init.d/named reload'
alias mysqldstart='/usr/bin/mysql_safe &'

alias gonamed='cd /var/named'

alias gofloppy='cd /mnt/floppy'
alias gocd='cd /mnt/cdrom'
alias gocdrom='cd /mnt/cdrom'

alias gorpm='cd /mnt/cdrom/RedHat/RPMS'
alias nocomments='grep -E '^[^#]' $1'
alias nocomment='grep -E '^[^#]' $1'
alias win2k='mount -t smbfs -o username=glenn,password=usual,ip=192.168.x.x //computername/sharename /win2k'

alias smbrestart='/etc/rc.d/init.d/smb restart'

alias sambarestart='/etc/rc.d/init.d/smb restart'

alias dmesg='dmesg | less'
alias ifconf='ifconfig | less'
alias ifc='ifconfig | less'
alias services='service --status-all | less'
alias messages='tail -n 50 /var/log/messages'

alias bashreload='source /root/.bashrc'
alias new='source /root/.bashrc'
alias inittabrestart='telinit q'

alias xinetdrestart='/etc/rc.d/xinetd restart'
alias sendmailrestart='service sendmail restart'

ejcd()
{
cd ; eject
}

lc()
{
cd $1 ; ls
}

cat /root/.signature > /root/.sig

/usr/games/fortune >> /root/.sig
/usr/games/fortune > /etc/motd

bigmail - A command line check for large mailboxes

find /var/spool/mail -size +6500 -print

Boot disk for the current system - make one

At the prompt, type #mkbootdisk --device /dev/fd0 2.2.9-19 (for my system; you'll have to enter the kernel info for yours)
Run uname -a for the kernel info.
Floppy should not be mounted when this command is run.

C

cat commands

cat writes out a file
cat -n numbers all lines

cat -s squeeze multiple blank lines into one

cat -v display all characters, including invisible ones, except for tabs and newlines

cat -A display all characters

You can make a simple document by typing at the command line:

cat - > filename

Then you finish it by entering Ctrl - d

CD - Burn one

  1. Put everything you want on the CD in a folder named cdimage
  2. Change the folder's contents into an iso image with this command:

  3. mkisofs -r -o cdimage.iso cdimage
  4. Try mounting the image to make sure it's OK:

  5. mount -r -t iso9660 -o loop cdimage.iso /mnt
  6. 4. If everything looks OK, burn with:

  7. cdrecord -eject -v -isosize speed=2 dev=4,0 cdimage.iso
dev4,0 stand for SCSI ID and bus in that order. My cd burner happens to be on ID 4. You can check the SCSI information by looking at dmesg:

#dmesg | less

For IDE CD burners that appear as SCSIs (don't ask), you can fine the target by running

#cdrecord --scanbus

The following about burning downloaded .iso files comes from the Red Hat list:

The .iso files are image files, a snapshot if you will, of the directory tree that has the
files, in packages, that you want to burn. In linux:

chkconfig - runlevel editor

Compiling and installing downloads

When you download a tar file from the net untar it with this command:
tar -xzvf /(path to file)/(filename.tar.gz) [enter]

then

./configure [enter]
make [enter]

make install [enter]

Crontab - Editing

If you don't want to use vi, run

export EDITOR=pico

RH7.3 wouldn't let root make a crontab. I had to create /etc/cron.allow and put the one word "root" in it. /etc/cron.deny will disallow any users listed from making crontabs.

Actual crontab files are in /var/spool/cron named for their creator. Root's crontabs will be /var/spool/cron/root.

"crontab -e" will start a crontab for you. They follow this pattern:

minute hour dayofmonth month dayofweek

1 1 * * * /usr/bin/fullback #This will run fullback at 1:01am every day
11,2,3 * * * /usr/bin/fullback #This will run fullback at 1:01, 2:01, 3:01am every day
11 * 1-15 * /usr/bin/fullback #This will run fullback at 1:01am on the first 15 days of the month

If you get mail to root saying permission denied, you may have to do a chmod on the script. 700 worked for me.

Look at your crontabs with crontab -l (el)

D

dd bootsector of current Linux system to Windows partition (to add to NT bootloader by editing boot.ini)

dd if=/dev/(hda8) bs=512 count=1 of=/mnt/win/bootsect.lin

Desktop - set preferred

/etc/sysconfig/desktop make it say DESKTOP="KDE"

DHCP server set up (Many thanks to Steve Litt of troubleshooters.com for the skinny on this)

1. Find out if it's already installed by running /etc/rc.d/init.d/dhcpd status
2. If it's not, install it by mounting the RPMS directory on the CD and issuing rpm -ivh dhcp*.rpm

3. Create /etc/dhcpd.conf. Make it say:

#Set global options
option domain-name mydomain.cxm; (or whatever your domain name)

option domain-name-servers 143.90.130.22, 143.90.130.38, 192.168.1.1; (or whatever)

option netbios-neme-servers 192.168.1.2; (put your WINS server's IP here)

option netbios-node-type 8; (8 is WINS then broadcast, I think)

option nis-domain 'mynisdomain'; (never tried it; they say it works)

#Set up a subnet
subnet 192.168.1.0 subnet 255.255.255.0 {

range 192.168.1.100 192.168.1.200; (or whatever range you prefer)

default-lease-time 604800; (604800 seconds=1 week)

max-lease-time 604800:

option subnet-mask 255.255.255.0;

option broadcast-address 192.168.1.255;

option routers 192.168.1.254 (or wherever your router is)

}

#fixed IP host
host myprinter {

hardware ethernet 00:80:C7:16:48:A6; (ping the IP and then run arp -a to see the MAC address, at least on NT)

fixed-address 192.168.1.x (put in your host (printer's, etc.) address

4. touch /etc/dhcp.leases Leave it empty.(In Mandrake 7.x this is /var/dhcpd/dhcpd.leases)
5.Run /etc/rc.d/init.d/dhcpd start. It should start up like so.

Starting dhcpd: [OK]

6. To make it start up every time at boot-up at runlevel 3 (add 5 also for GUI runlevel)

ln -s /etc/rc.d/init.d/dhcpd /etc/rc.d/rc3.d/S65dhcpd (that's a space after the first dhcpd, of course)

7. There needs to be an empty file /var/dhcpd/dchpd.leases. Touch one of it isn't there. To see current leases after it's all running, cat the file cat /var/dhcpd/dchpd.leases, and you'll see see when the lease started and ends, what machine has the lease, the hardware address of the card, and of course the IP that was given out.

Directory

cd /
du -sh *

dmesg is in /var/log/dmesg

DNS

Setup for DNS is done in two places in Red Hat Linux - in /etc/ and in /var/named/. The /etc files are /etc/resolv.conf and /etc/named.conf. Let's look at them in turn.

DNS has, of course, two sides, the client (called the resolver) and the server. On Windows you can set the resolver in TCP/IP properties -> DNS; in Linux you put it in /etc/resolv.conf.

cat /etc/resolv.conf - Has only two lines:

search mydomain.cxm #because the server was set to mydomain.cxm at install time

nameserver 192.168.1.1 # the server's IP, of course, meaning your box (not your ISP's).

There's more, but that's probably about all you need. Any changes to /etc/resolv.conf will happen without restarting any services.

The /etc/named.conf points to the records in /var/named/. It will probably point to:

1. a hints file (named.ca) that lists the root servers for the Internet. This is the same as \winnt\system32\dns\cache.dns in Windows. I won't print it here; it's too long.
2. a local host file This just resolves the loopback address to localhost. It's like the first line of a /etc/hosts file.

3. zone files These have most of the information of the zone.

4. reverse zone files The in-addr.arpa PTR files
Let's look at a working /etc/named.conf file:
cat /etc/named.conf

options {
directory "/var/named"; (Could be anywhere)

};

zone "." {
type hint;

file "named.ca"; (The Internet name servers)

};

zone "0.0.127.in-addr.arpa"{ (Loopback for localhost)
type master; file "named.local";

};

zone "1.168.192.in-addr.arpa"{ (Reverse DNS file for the non-public network)
type master;

file "192.rev.hosts";

};

zone "mydomain.cxm" { (The "main" domain I've set up. Hostnames are real.)
type master;

file "mydomain.cxm.hosts";

};

zone "pentium.cxm" { (This exists only in cyberspace)
type master;

file "pentium.cxm.hosts";

};

/var/named/named.local looks like this:
@ IN SOA localhost. root.localhost. (

1997022700 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

IN NS localhost.

1 IN PTR localhost.

/var/named/192.rev.hosts (in W2K, 1.168.192.in-addr.arpa.dns)

@ IN SOA linux.mydomain.cxm. root.localhost. (
  2001060201 ; serial
10800 ; refresh
3600 ; retry
2419200 ; expire
38400 ; default_ttl
)

@
2.1.168.192.in-addr.arpa
11
1

IN
IN
IN
IN
NS
PTR
PTR
PTR
linux.mydomain.cxm
pentium.mydomain.cxm.
linux.mydomain.cxm.
linux.mydomain.cxm.

@ IN NS linux.mydomain.cxm
2.1.168.192.in-addr.arpa IN PTR pentium.mydomain.cxm.
11 IN PTR linux.mydomain.cxm.
1 IN PTR linux.mydomain.cxm.

/var/named/mydomain.cxm.hosts (in W2K, mydomain.cxm.dns)

$TTL 1d

mydomain.cxm. IN SOA linux.mydomain.cxm. root.localhost. (

  988532945
10800 

3600 

432000 

38400 ) 
mydomain.cxm. IN NS linux.mydomain.cxm.
linux.mydomain.cxm. IN A 192.168.1.1

pentium.mydomain.cxm. IN A 192.168.1.2

The book shows a @ instead of the initial mydomain.cxm, but I don't know why.

/var/named/pentium.cxm.hosts
$TTL 1d

pentium.cxm. IN SOA linux.mydomain.cxm. root.linux.mydomain.cxm. (
 
  988532945
10800 

3600 

432000 

38400 ) 
  IN NS linux.mydomain.cxm. 

www<-- No period! IN CNAME linux.mydomain.cxm. <-- Period! (As it is up above)

It seems that CNAMEs don't have trailing periods before the IN, but A records do.

www.pentium.cxm.<-- Period! IN A 192.168.1.1

Make sure your other boxes have 192.168.1.2 as the DNS.

Successful DNS with virtuals on Linux on a private network
1. After doing the above, put a new directory "pentium" with an index page inside of the original document root so that you have /home/httpd/html/pentium/index.html, and make it say "Welcome to wwwpentium.cxm."
2. Leave the original index.html inside /home/httpd/html

3. Add this to /etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.1.1
<VirtualHost 192.168.1.1>

ServerName www.mydomain.cxm

DocumentRoot /home/httpd/html

ErrorLog logs/www.mydomain.cxm-errorlog

</VirtualHost>

<VirtualHost 192.168.1.1>
ServerName www.pentium.cxm

DocumentRoot /home/httpd/html/pentium

ErrorLog logs/www.pentium.cxm-errorlog

</VirtualHost>

DNS tools

You can look at a PTR record with the command nslookup -query=ptr

> nslookup -query=ptr 1.1.168.192.in-addr.arpa

Server: linux.mydomain.cxm
Address: 202.217.95.121

You can use nslookup interactively:

> nslookup
> help

(A bunch of options are displayed)

> set type=MX (for example, to see mail servers)
>
mydomain.cxm

Server: linux.mydomain.cxm
Address: 202.217.95.121

With dig you don't have to put reverse lookup queries in reverse order:

> dig -x 140.90.141.131

;; ANSWER SECTION
131.141.90.140.in-addr.arpa

host command:

> host -t ptr 161.203.16.2
2.16.203.161.IN-ADDR.ARPA domain name pointer www.gao.gov

> host -t cname www.ee.umd.edu
www.ee.umd.edu is a nickname for server.ee.umd.edu

E

Remove a folder recursively

rm -rf (directory) "r" is recursive and "f" is force

environment - use set | less to see environment variables

echo $PATH, echo $HOME, echo $USRENAME etc. will show you selected parts of your environment.

export variablename=value such as export $PATH=/sbin

F

favicon ( the little non-generic icons in from of URLs on websites)

File filename tells you if a file's binary or text.

Find - some useful find commands

Format a partition as ext3

fdisk /dev/hdxx will make a new partition for you.
mke2fs /dev/hdxx will format it in ext2.
tune2fs -j /dev/hdxx will change if from ext2 t ext3..
mkfs.ext3 /dev/hdxx will format it ext3 the first time.

Format a floppy from the command line:

ftp

FTP default directories (from Red Hat mailing list)- Just add a user named, for example, backupetc. Then go in and edit the home directory entry in the passwd file to /etc. When you connect to the system, you will be plunked into that directory by default.

G

grep - You can look at the real text of a config file without the clutter of the #comment lines by issuing this command:

grep -E '^[^#]' filename .Yes, those are 2 circumflexes between singlequotes

grep -i -l myserver.com /etc
You can get a listing of all the files in /etc/ that contain the string myserver.com with this command.

grub - (Great Universal Bootloader) - Grub was designed to make it easy to boot among multiple OSes installed on multiple partitions or HDs. Grub can be on a floppy or on the MBR. I've never been able to change the boot choices on a boot floppy with LILO installed, but it's easy to do with grub. Setup:

H

hdparm -i /dev/hda will give info on the first hard disk, including chs info.

Home pages - Add user home pages

/etc/htpd/conf/srm.conf has a line in it that allows you to define a UserDir, the default folder for the web browser. Out of the box, Red Hat is configured for a directory called public_html. Put a folder in each user's folder by that name. Inside, the default home page is index.html. MAKE SURE THE FOLDERS AND FILES HAVE READ AND EXECUTE PERMISSIONS FOR ALL DIRECTORIES!

By default, Red Hat gives you the html source and not the formatted page if the page is named *.htm. Add htm to /etc/mime.types to remedy this. Afterward, run

kill -HUP `cat /var/run/httpd.pid` #I'm getting this from /home/httpd/html/manual/FAQ.html (#57)

 

Hostname - Type hostname by itself to get the hostname of the machine. This info is stored in:

HTML Forms

Here, FORM /FORM should be in brackets, and INPUT TYPE TO name" should also, nested inside.

FORM
METHOD="POST/GET" ACTION="path/cgi-bin/script"

INPUT TYPE="SUBMIT/TEXT/RADIO/CHECK/PASSWD/RESET" NAME="some_name" VALUE="some_value" (Adding a VALUE="some_value" puts default text in a text box.)

SELECT by itself (not as part of an input tag) gives a pop-up menu.

/FORM

With TYPE="text" you can add SIZE="n" and MAXSIZE="n' within the brackets. The default size is 20.
For RADIO, you should make with the same NAME but different VALUEs. Add CHECKED to the one of them to be the default.

I

IlohaMail

1) Download and unpack the tar ball, cd into the IlohaMail directory.
e.g.
$tar xzf IlohaMail-version.tar.gz
$cd IlohaMail-version

2) Inside the dir created, there's another one called IlohaMail. Move the IlohaMail directory to any location on your hard drive. It is recommended that you place all files outside the document root, however, with version 0.7.10, it is safe to install inside the document root.
e.g.
$mv IlohaMail /www/IlohaMail

3) Add an "Alias" directive in your httpd.conf file, and point it to the
IlohaMail/source directory.
e.g.
Alias /webmail /var/www/html/IlohaMail/source (or wherever it is)

you also need to add:

<Directory "/var/www/html/IlohaMail/source/"> (or wherever you put it)
options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

to get it to work.

3b. If you do not have access to the httpd.conf file, you may also create
a symbolic link in your document root.
e.g.
$ln -s /www/IlohaMail/source {$DOCUMENT_ROOT}/webmail

4) Create necessary directoriesand change permissions. Here's a script you inside IlohaMail/. Just make it executable.

#!/bin/bash

mkdir users sessions uploads cache

chmod 700 users sessions uploads cache

chown apache:apache users sessions uploads cache

You have to look in httpd.conf to see what user apache runs as. SME runs as www:www.

7) Find this in httpd.conf:

<IfModule mod_dir.c
DirectoryIndex index.html --> add index.php
</IfModule>

and add index.php so that Iloha will open automatically.

8) Restart Apache

9) Start ipop3d by going into /etc/xinetd.d/ipop3 and changing disable = yes to
disable = no

10) Start imap by going into /etc/xinetd.d/imap and changing disable = yes to
disable = no

11) Apache will keep telling you you don't have permissions to access /webmail if ipop3d isn't running, so to get xinetd to reread its config
# /etc/init.d/xinetd reload

12) IlohaMail/conf/login.inc is where you can hard code the server name for convenience and hide any login fields you want to hide. There is also a setting for the default language if one is not specified and set the auto-append to only the domain in case it's putting the server hostname and domain after the @. Of course, this is set in the prefs anyway.
Try:

$default_host = "localhost"
$hide_host = 1;
$hide_protocol = 1;
$hide_rootdir = 1;
$hide_lang = 0;

13) MySQL backend - IlohaMail/conf/mysqlrc.php is where you put in the info for your mysql tables. You can see what the names of the backend tables are there.

Use this script to set them up automatically. Change the database-specific info to yours, upload it to the DocumentRoot, change it from .html to .php, and make it executable. These tables can be found in IlohaMail-0.x.x/MySQL/sql.

14) Go to IlohaMail/conf/mysqlrc.php and set
$mysql_host="";

$mysql_user="";
$mysql_password="";
$mysql_db="";
to your information.

Also uncomment $mysql_log = "user_log";
while in mysqlrc.php.

15) IlohaMail/conf/conf.inc is where you set IlohaMail to actually use the MySQL backend instead of files. Change the

$backend = "FS";   to  $backend = "MySQL";

16) IlohaMail/conf/defaults.generic.inc is where you set user@hostname.domainname.com to user@domainname.com.

17) IlohaMail/conf/login_title.inc is where GOL set the fancy login page.

Inittab

Change default init level by hand

edit /etc/inittab
original line- id:3:initdefault:

edit to- id:5:initdefault:

Reread after editing

Run /sbin/telinit q to reread inittab after editing

IPCHAINS - (from Redhat-install-list) To block a particular URL using IPCHAINS you need to use input and output rules. This will block from within and from outside as well:

/sbin/ipchains -A input -i $your_interface -p tcp -s $ip_addr_source -d $ip_addr_dest -j DENY
/sbin/ipchains -A output -i $your_interface -p tcp -s $ip_addr_source -d $ip_addr_dest -j DENY

The downside to this is that you will be adding alot of IP's in future needs as the number of sites you want to restrict access too grows... I would use a script that builds the rule set from a file that holds the restricted site access.

read the man pages on ipchains for further details. To check a rule use:

ipchains -C input -p tcp -s $source $port_num -d $dest $port_dest -i
$your_interface

IPs - private ones

IPchains -

ipchains -L -v to get a verbose listing of your firewall

IPtables -

To block a whole subnet from accessing your box:

iptables -A INPUT -s 221.218.105.0/24 -j DROP

IP Masqerading

#!/bin/sh

depmod -a
modprobe ip_masq_ftp

modprobe ip_masq_raudio

echo "1" > /proc/sys/net/ipv4/ip_forward

echo "1" > /proc/sys/net/ipv4/ip_dynaddr #for ppp connections

echo "1" > /proc/sys/net/ipv4/always_defrag

ipchains -P forward DENY

ipchains -A forward -s 192.168.1.0/24 -j MASQ

Make sure your clients have your Linux box as their gateway.

(RH7.3) /etc/sysctl.conf has a line in it

net.ipv4.ip_forward = 1 ...that turns on IP forwarding. It just does this:

echo "1" > /proc/sys/net/ipv4/ip_forward ... which you can also do manually.

ipop3d is in the imap rpm

J

NFS mount - howto

Client /etc/fstab

/pentium:/ /mnt/pent nfs soft,bg 0 0

(pentium was the server's name - change to your situation)

Server /etc/exports

/ pentium2 (rw,no_root_squash)

(pentium2 was the client's name - change to your situation)

On the command line

mount pentium:/ /mnt/pent
 
 

After adding new fonts to Linux

After adding free fonts and sharefonts to my system then added the following to my startup file, .bashrc

xset fp+ /usr/X11R6/lib/X11/fonts/freefont
xset fp+ /usr/X11R6/lib/X11/fonts/sharefont

xset fp rehash

Japanese on Linux (Linux list)

You should install freewnn and kinput2.
Then do 'export LC_ALL=ja_JP" in your shell before running the desired application. You should be able to input japanese into netscape, mozilla (some builds don't work for me), gnome, kde, kterm, and so on.

You should also read the manpages, some relevant howtos and the tlug archieves if things don't work.

LC_ALL=ja_JP.eucJP is better than that.

And on rh 7.x, canna and skk are also available.

K

kedit is in the kdeutils rpm.

Kernel info from uname

uname -n will echo the machine name
uname -r prints out the kernel version

uname -a prints out everything

source code is in /usr/source/linux
Read step by step how to do a kernel on page 171 on The Magic Decoder Ring

Kmail - Move Kmail mailboxes


All your Kmail stuff is in /root/Mail If you want to put the mail from two different systems together, try cat /mnt/hda8/root/Mail/inbox >> /root/Mail/inbox for example.

Kmenuedit

You can edit the menus with kmenuedit

L

Labeling - partition labeling

SME changes the partition labels on reinstalls, and can fail to boot if the label in /etc/fstab doesn't fit reality.

LILO - Multiple flavors of Linux on the same disk. (from Steve Litt's site)

Linux does not read the /etc/lilo.conf file at boot-up. It only reads the MBR. LILO's job is to write the lilo.conf file and write it to the MBR.

To boot multiple flavors or installations of Linux from the same HD:

  1. Make a /boot partition as hda1, if the HD goes beyond 1024 cylinders.
  2. Install Windows if necessary.
  3. Install your favorite distro. Be sure to make a boot disk.
  4. Install the other distros on other partitions.
  5. Boot back into your main distro. Use the boot disk if you must.
  6. Mount the partitions containing the other distros and cut and paste the info pointing to themselves from their lilo.conf files into the lilo.conf of your main distro. Edit their labels if you like. Be sure to get the specific names and numbers of their kernels. Look in their /boot partitions if you must.
  7. Steve recommends even making the image line of lilo.conf a link going through the /mnt folder of your main distro, e.g. image=/mnt/cald/boot/vmlinuz-2.2.5-modular
  8. Run /sbin/lilo with no arguments.
  9. Reboot and see if it worked.

LinNeighborhood - (on RH8)

[share]
path = /share
read only = No
guest ok = Yes

[html]
comment = Apache document root
path = /var/www/html
read only = No
guest ok = Yes

Logon message - It's probably best to just write it on the outside of the hard disk, but if you want to write a message to yourself about a system you're testing at logon just put it in /etc/motd.

/etc/issue is where the message that is displayed at the start of a telnet logon is kept. It doesn't replace the "Red Hat x.x on an i686" message but rather comes up after logon.

ls - some things you can do with ls

M

Macintosh - Change Server Name in Macintosh Chooser

You can change the name of the server that shows up in the Macintosh chooser by changing the line

ATALK_NAME=$HOSTNAME to ATALK_NAME="To your folder" or something like that.

Mail

Mirroring- Get a partition ready for mirroring

fdisk /dev/hdx Then make the partition. Format it with
mke2fs /dev/hdxx
It automagically figures everything for you.

Mount hdxx in /backup

tar -cf - /$1 | (cd mnt/backup ; tar -xvpf -) with each directory as /$1 will mirror them over.


Meaning: using Tar, Create File named - out of /$1 and |pipe it to /backup, unpacking it with tar Xtract Verbosely keeping same Permissions the file named -.

Modules - location

/lib/modules/2.0.35(kernel number)/net/

lsmod - lists modules
insmod module - installs a module

modprobe
module - is a better installer, as it checks for dependencies
rmmod module - removes a module

Mouse - This /etc/sysconfig/mouse makes a USB mouse scroll on RH8 (vmware, at least)

FULLNAME="Generic - 3 Button Mouse (PS/2)"
MOUSETYPE="ps/2"
XEMU3="no"
XMOUSETYPE="PS/2"

This /etc/sysconfig/mouse makes a PS/2 wheel mouse scroll on RH8

FULLNAME="Generic - Wheel Mouse (PS/2)"
MOUSETYPE="imps2"
XEMU3="no"
XMOUSETYPE="genericwheelps/2" (XMOUSETYPE="IMPS/2" worked on RH9)

Dot notation

If two tables have columns with the same name, you can differentiate them by using dot notation, i.e.
table1.samecolmnname, table2. samecolumnname

MySQL- Setting up with PHP on a Linux box (RH5.2, 6.0, Man 5.3, 6.0)

1. Download and install mysql from http://mysql.com. At the very least install the latest server, client, and development rpms.
2. Query Apache. You need rpm -i apache-1.3.6-7.i386.rpm

rpm -i apache-devel-1.3.6-7.i386.rpm
(This contains /usr/sbin/apxs)
rpm -i freetype-devel-1.2.6.i386.rpm

With Mandrake 6.0 the only thing I needed to put in was the freetype.

3. Try out MySQL by doing the following:

At the command prompt, type mysqladmin create databasename (enter)

mysql databasename (enter). If you get a welcome, you're OK. Get out by entering "quit.".

4. Download, gunzip, and untar the PHP tarball from http://php.net.

5. CD into the PHP directory and build it with:

./configure --with-apxs=/usr/sbin/apxs --with-mysql --with-ldap (those are double hyphens)
the ldap part errored out, so I had to delete it and try again. With Apache 1.3.9 or later you can add --with-xml

6. Type: make (enter)
make install

After 'make install' you get:

/usr/sbin/apxs -i -n php3 libphp3.so
cp libphp3.so /usr/lib/apache/libphp3.so

chmod 755 /usr/lib/apache/libphp3.so

6. Go to /etc/httpd/conf/httpd.conf and uncomment these two lines:
LoadModule php3_module libexec/libphp3.so

AddModule mod_php3.c

7. Check to make sure that in /etc/httpd/conf/srm.conf the lines

Addtype application/x-httpd-php3 .php3

Addtype application/x-httpd-php3-source .phps

are not commented out.

8. Restart Apache with: /etc/rc.d/init.d/httpd restart

9. Test it. Put a file in your document root directory /home/httpd/html with the single line:

<?phpinfo()?>

and name it info.php3. Then load it up in your browser: http://your.machine/info.php3 You should see a nice summary page showing all sorts of information about your setup.
The data base files go in /var/lib/mysql.

The executables are in /usr/bin.

MySQL - Installing it as a binary - Never tried this but got it somewhere...

Use the mysql.tar.gz file on the MYSQL_PHP CD
Untar it into /usr/local. It will make its own folder
The basic commands you must execute to install and use a *MySQL* binarydistribution are:

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db
shell> chown -R root /usr/local/mysql
shell> chown -R mysql /usr/local/mysql/var
shell> chgrp -R mysql /usr/local/mysql
shell> chown -R root /usr/local/mysql/bin/
shell> bin/safe_mysqld --user=mysql &

You can add new users using the `bin/mysql_setpermission' script if you
install the `DBI' and `Msql-Mysql-modules' Perl modules.

Install php4 and MySQL from rpms - Just slop in the mysql and php rpms. It's no big deal. Then to get it to work, I had to put these in /httpd.conf flush left:

Near the top:

AddModule mod_php4.c

Farther down:

AddType application/x-httpd-php .php4 .php3 .phtml .php
AddType application/x-httpd-php-source .phps

I know it looks like they're already there as contingencies, but put these lines in anyway.

Common commands and tasks in MySQL 3.23.35

In the install directory:

./safe_mysqld & (installs some default databases) That's a dot-slash at the beginning.

mysqladmin -u root password 'new-password' (changes password)
mysql -u root -p
<enter> (starts it then add password)
show databases; (does just that)
create database <database -name>; (does just that)
use <database-name>; (enters a database)
create table <table-name> (then you need to describe it)
describe <table-name>; (shows need info about table)
In /usr/bin you can issue ./mysqlshow -u root -ppassword databasename and it will show you all the tables without ever logging in.

 

Common mysqladmin commands

mysqladmin status
mysqladmin version

mysqladmin drop db1 - deletes a database named db1


Create a table

mysql db1 - enter the data base for editing
mysql> CREATE TABLE tb1( - creates table named "table1." One space between each element.

-> columnname1VARCHAR(25) [not null], - creates the columns to accept up to 25 variable characters. "not null" disallows empty cells.

-> columnname1VARCHAR(25) - in length. There is one space between elements.

> );

Query OK, 0 rows affected (0.00 sec)

Quit MySQL Just type quit

Create a table from a file (Thanks to Graeme Merrall at Webmonkey)

1. Create data base with mysql admin
mysqladmin -u root create mydb

2. Put all the sql commands into a text file, such as:

CREATE TABLE tablename( id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id));

INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager');

3. Save this file to /var/lib/mysql/somefilename

4. On the command line, issue: mysql -u root mydb < somefilename

 

To see the table you've created type:

show tables;

Insert statements - to put data in a table:

mysql> insert into employee
-> (columnname1, columnname2)

-> values ('Luke', 'Duke');

Query OK, 1 row affected (0.00 sec)

Change data in tables

Substitute data with "update"
update tablename set columnname = 'somethingdifferent' where othercolmn = 'someidentifier';

Relational operators
 
Equal
<> or != Not equal
< Less than
Greater than
<= Less than or equal
>= Greater than or equal


Join data from two tables

To add a column from one table to another table:
select distinct table1.*, table2.columnname from table1, table2 where table1.columnname = table2.columnname

 
 

% is a wildcard for several characters in WHERE statements.
_ is a wildcard for one character in WHERE statements.

"like" could also be "="

 

N

Name - computer name The computer keeps its name in:

netstat

netstat -r gives you routing info. Netstat -i shows you the received and transmitted stuff that you can get from KPPPload.

(Man 7.1, RH 6.2) Networking setup - Your networking in set up in these main files:

1) /etc/conf.modules lists the modules for the net cards. If you want to know what drivers are loaded for eth0, eth1, etc, look in /etc/conf.modules:


alias eth0 3c509 tells you that eth0 is a 3 Com card.
alias eth1 epic100 - SMC card
alias eth2 tulip - the Netgear card
alias eth3 via-rhine

Of course, the modules have got to really be there, though. You will find the modules themselves in /lib/modules/kernelname/net/ so if you're not sure what to call them, look in there.

2) If you want toassign IP numbers to netcards by hand, put them in /etc/sysconfig/network-scripts/ifcfg-ethx

Here's an example of ifcfg-eth0:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes

3) /etc/sysconfig/network has this info:

NETWORKING=yes
FORWARD_IPV4=yes
HOSTNAME=linux.mydomain.cxm
DOMAINNAME=mydomain.com
GATEWAY=192.168.1.254
GATEWAYDEV=eth0

If you want to add IP, network, and routing info by hand on the command line, you can enter:

route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0

To add the router address, enter:

route add default gw 192.168.1.254

4) What you're doing, though, is editing /etc/sysconfig/static-routes. You can just add:

eth0 net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254

there by hand and it will survive a reboot.

Hostname

To add a hostname on the fly, enter:

hostname linux.mydomain.cxm

5) To have it survive a reboot, put in /etc/hosts:

192.168.1.2 linux.mydomain.cxm linux

6) Put the name(s) of your nameserver(s) in /etc/resolv.conf:

search mydomain.cxm
nameserver 192.168.1.2 #the linux box itself
nameserver 143.90.130.22

NICs - You can set up a network card on the command line using ifconfig:

 

NTFS mount - you can mount ntfs partitions with mount -t ntfs /dev/hdxx /mnt/xx. They will be read only, though.

ntsysv runlevel editor

Run nysysv --level 35 to edit edit which services start in which renlevels. If you don't do the second part, it just edits the runlevel you are currently at.

P

Partitions

Path - You can add a directory to your path in /root/.bashrc

Add PWD to your path

You can add something (a dot for the PWD or any other path) by typing: PATH=$PATH:. (note the trailing dot)
export PATH

This will only be affective for this session. To make it permanent:

For one user, edit the user's .bash_.profile file
Make it say: PATH=$PATH:$HOME/bin:. <- note the colon and period on the end
For all users edit /etc/profile

phpMyAdmin

Quick Install:

1.Untar or unzip the distribution (be sure to unzip the subdirectories): tar xzvf phpMyAdmin_x.x.x.tar.gz
2.Open the file config.inc.php3 in your favorite editor and change the values for host, user and password to fit your environment. Have a look at Configuration section for an explanation of all values.
I just did:

$cfgPmaAbsoluteUri = 'http://linux.mydomain.cxm/phpMyAdmin-2.2.3/';

$cfgServers[1]['host'] = 'localhost'; // MySQL hostname
$cfgServers[1]['user'] = 'root'; // MySQL user
$cfgServers[1]['password'] = '*******'; // MySQL password (onlyneeded with 'config' auth)

3.It is recommended that you protect the directory in which you installed
phpMyAdmin (unless it's on a closed intranet, or you wish to use http or
cookie authentication), for example with HTTP-AUTH (in a .htaccess file). See
the FAQ section for additional information.
4.Open the file
http://linux.mydomain.cxm/phpMyAdmin-2.2.3/index.php in your browser. phpMyAdmin
should now display a welcome screen and your databases, or a login dialog if
using http or cookie authentication mode.

ping - disable You can disable a box's responding to ICMP pings with

/bin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

Ports - Some of the more famous ports. You can find a more complete list under Windows \winnt\system32\drivers\etc\services.

service port
icmp
ftp 21/tcp
ssh 22/tcp
telnet 23/tcp
smtp 25/tcp
http 80/tcp
pop3 110/tcp
ldap 389/tcp
netbios-ns 137/tcp
netbios-ns 137/udp
netbios-dgm 138/udp
https 443/tcp
https 443/udp
pptp 1723/tcp


Predefined Ports under Linux

Predefined ports are listed in /etc/services

See what ports are currently being used by what daemons -

netstat -nape

pppoe - PPP Over Ethernet is what you use to connect to the 'Net with ADSL.

printing

  1. Go to http://hpinkjet.sourceforge.net/install.php and download hpijs-x.x.x.tar.gz
  2. ./configure ; make ; make install
  3. Verify with hpjis -h
  4. Use printtool to and edit to select the hpijs driver for the hp930c and other settings

    (Later I discovered that hpijis is an rpm)

processes

ktop

ktop at the command line will give you the graphic representation of the top processes

kill a process

Say a program called gFTP is not responding. To find its pid, issue:
ps ax | grep gFTP

It will tell you its pid. If it's, for example, 879, issue:

kill 879

If that doesn't do it, issue:

kill -9 879

Start a process with & after it to start it in the background.
fg will bring it to the foreground.
CTRL-C will stop it in the foreground but not int he background.
CTRL-Z will stop it temporarily.
bg will send it to the background.

R

rc.d - add S symlinks to start services (from Jim Titsler's reply on-line)

 
The easiest way to create appropriate symlinks in rcx.d is to use 'chkconfig':

checkconfig httpd on (which will create an S85httpd symlink, based on the magic line

at the top of /etc/rc.d/init.d/httpd).

Or, for a GUI, by using 'ntsysv' to control which services are automatically started.

register_globals = on

mkdir -p /etc/e-smith/templates-custom/etc/php.ini/
cd /etc/e-smith/templates-custom/etc/php.ini/
cp /etc/e-smith/templates/etc/php.ini/40DataHandling .

edit 40DataHandling and change register_globals = off to on

expand-template /etc/php.ini
/etc/rc7.d/S86httpd-e-smith restart

Repair a damaged file system

Run fsck -t ext2 /dev/hdxx

RealPlayer8 (Live365) - After installing the RealPlayer8 rpm in the usual way, you have to find it for Live365. It the location of the executable is /usr/lib/RealPlayer8/realplay.

Rescue disk - Make one

The boot disk you created during the installation is not a root disk, meaning there's no root filesystem for the kernel to mount at boot. The boot disk only contains a Linux kernel, which allows you to boot into your system if anything unfortunate ever happens with your kernel but not your filesystem. The boot disk works if you just hit enter at the boot prompt.

To use a rescue disk, you must make one from the rescue.img in the /images directory of your first CD (or from a copy on the net somewhere).
Under Linux, put a blank floppy in the drive and as root issue:

# dd if=rescue.img of=/dev/fd0 bs=1440k -or-
# cat rescue.img >/dev/fd0

Then you can try a rescue boot by typing 'rescue' at the boot prompt of the boot diskette and inserting the rescue diskette when it asks for it.

route - Type "route" by itself to see the routing table

If you want to add IP, network, and routing info by hand on the command line, you can enter:

route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0

To add the router address, enter:

route add default gw 192.168.1.254

4) What you're doing, though, is editing /etc/sysconfig/static-routes on older systems. You can just add:

eth0 net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.254

there by hand and it will survive a reboot.

On RH8, /etc/sysconfig/network should say

NETWORKING=yes
HOSTNAME=rh8
GATEWAY= 192.168.1.254

RPM - If you you want to see all the options spewed to STDOUT, just type rpm.

Queries

Verify messages - rpm -Va checks to see that all rpms are installed correctly
The format of the output is a string of 8 characters, a possible "c" denoting a configuration file, and then the file nane. Each of the 8 characters denotes the result of a comparison of one attribute of the file to the value of that attribule recorded in the RPM database. A single "." means the test passed. The following characters denote failure of certain tests:

rpmverify (script) - This script will go through and check all your rpms. It will then create a file /tmp/rpmverify.out telling which ones have been changed. Uses rpm -V.

#!/bin/bash

for rpmlist in `rpm -qa | sort`

do
echo " =========== $rpmlist ============"
rpm -V $rpmlist

done > /tmp/rpmverify.out

Runlevel changes

You can change the levels that services run at by dragging them over using ksysv.

/etc/rc.d/rc.local is the last script to run at bootup. If you want anything to run last, put it here. If you want it to set the hostname to linux.mydomain.cxm, put hostname linux.mydomain.cxm in there.

S

Samba printing (from Redhat-install-list)

(Problem):I have got Samba up and running and can connect drives both ways between my Win98 and RH6.0 boxes and connect a printer to the RH that is physically attached to the Win98 box. Everything looks Ok except I can't see anything in my Network Neighbourhood. Below is a copy of my /etc/smb.conf.

# Samba config file created using SWAT
# from aragorn.home (192.168.1.2)

# Date: 1999/12/04 08:34:04

# Global parameters

workgroup = LOTR

netbios name = ARAGORN

encrypt passwords = Yes

log file = /var/log/samba/log.%m

max log size = 50

socket options = TCP_NODELAY

printcap name = /etc/printcap

dns proxy = No

[homes]
comment = Home Directories

read only = No

browseable = No

[printers]
comment = All Printers

path = /var/spool/samba

print ok = Yes

browseable = No

[Root]
comment = Root directory

path = /

read only = No

ANSWER:"Seeing" the shares is dependent upon your samba.conf file. You need to assign a browse master to control this. In turn it should be Linux/Samba as I indicated in my message to you. In my case I opted out for using Samba as a domain LOGIN server, which simplifies things if you are not using NT as a PDC. Samba then controls what the users see...

Shell scripting in Bash shell

Double quotes remove white space, but the dollar sign $, backslash \, and back quotation marks ` retain their shell meaning:

greeting="hello there $LOGNAME" still takes LOGNAME from the environment variable.

\ will also remove white spaces, e.g. greeting=hello\ there will also assign "hello there" to variable "greeting." The \ removes the special meaning from the character it precedes.

Single quotes will remove the special meaning of the $.
greeting='hello there $LOGNAME' will echo the dollar sign.

Multiple command line commands separated by a semi-colon are executed in sequence. Separated by an ampersand, they are run concurrently.

Curly braces: echo Hello $LOGNAMEski gives you only Hello , because it can't find a variable ending in ski. You can end the variable by using curly braces:

# echo Hello ${LOGNAME}

Hello Glennski.

Set a variable by putting a value to the right of the equal sign:

# BIGBOY=Glenn
# echo Hello $BIGBOY

Hello Glenn

Unset the variable with the unset command

# unset BIGBOY
#echo Hello $BIGBOY

#

Want to test a script without the hassle of making it executable and in your path? Just type

sh thescriptname
 

The test command's file operators
 
Operator Meaning (Copied from Linux Unleashed)
-d filename Returns true if "filename" is a directory
-f filename Returns true if "filename" is an ordinary file
-r filename Returns true if "filename" can be read by the process
-s filename Returns true if "filename" has a non-zero length
-w filename Returns true if "filename" can be written by the process
-x filename Returns true if "filename" is executable

 
 
 
Command Meaning (Copied from Linux Unleashed)
! expr Returns true if expr is not true
Expr1 -a expr2 Returns true if expr1 and expr2 are true
Espr1 -o expr2 Returns true if expr1 or expr2 is true

 
 
 
Variable Use (Copied from Linux Unleashed)
$# Stores the number of command line arguments that were passes to the Shell program
$? Stores the exit value of the last command that was executed
$0 Stores the first word of the entered command (the name of the shell program)
$* Stores all the arguments that were entered on the command line ($1 $2 . . . )
"$@" Stores all the arguments that were entered on the command line, individually quoted ("$1", "$2" . . .)

 
 
 
Plain English
Script line
If the last command was successful if [ $? = 0 ] ; then
If there is such a file named testfile if [ -f testfile ] ; then
If there is such a directory named dir if [ -d dir ] ; then
If the file exists and contains something if [ -s testfile ] ; then
If the thing you typed on the command line as an argument is not a directory if [ ! -d "$1" ]; then 
If the last command was successful, carry on. Otherwise, echo ". . . ." if [ $? -eq 0 ]; then 
:

else

echo " . . . "
   


A shell script to add users automatically from a list in the same directory.

users=`cat ./users`

for u in $users

do

echo "adding User .... ${u}"

useradd ${u}

passwd ${u}

done

A script to remove users and their files one by one from the command line

#!/bin/sh

echo -n "Enter username to be deleted: "

read user #What comes after the read becomes the variable for what was entered

if [ -z "$user" ];then #I think -z means "=0"

echo "No name entered. Exiting."

exit 0

else

echo "Removing user $user ..."

userdel $user

rm -rf /home/$user

rm -f /var/spool/mail/$user

echo "ok"

fi

Remove viruses from a directory

#!/bin/bash

virii=`cat ./virii`
for v in $virii

do

rm -rf $v

done

 

Server Side Includes on Apache - Enable

1. In /etc/httpd/conf/access.conf, enable includes in a directory of your choice:
<directory /some/path/directory_for_shtml>

options includes followSymLinks indexes

</directory>

2. In /etc/httpd/conf/srm.conf, add the line

Add type text/x-server-parsed-html .shtml

If you can afford to have Apache parse every document, just make it .html

Signatures in Kmail with fortune - If you want to have a signature line in Kmail with a rotating cute phrase:

1. Make a /root/.signature file and put what you want in it
2. Touch another file called /root/.sig
3. Put this in your /root/.bashrc file:

cat /root/.signature > /root/.sig (This puts the signature file into another one so fortune doesn't overwrite it)
/usr/games/fortune >> /root/.sig (This appends the fortune cookie.
)

-Optional-
/usr/games/fortune > /etc/motd (Message Of The Day gives the logon message)

echo $PATH|grep -q /sbin || export PATH=$PATH:/sbin:/usr/sbin

# Source global definitions

if [ -f /etc/bashrc ]; then

. /etc/bashrc

fi

You can see the aliases in .bashrc by typing alias at a shell prompt.

 

SMB password (from the old days)

cat /etc/passwd | mksmbpasswd.sh > /etc/smbpasswd

chmod 600 /etc/smbpasswd

Then: smbpasswd (username) Give the user a new password

  Start / Stop / Restart samba

/etc/rc.d/init.d/smb start (stop) (start) (restart) will do it

Access Windows NT shares from a Linux box:

A SIMPLE samba example with no security:

interfaces = 192.168.1.1/255.255.255.0
bind interfaces only = yes

socket address = 192.168.1.1

allow hosts = 192.168.2.0/255.255.255.0 192.168.1.0/255.255.255.0

SWAT

Sendmail (additional info is in /usr/share/docs/sendmail/ after you install the sendmail-docs rpm). You can also check http://www.sendmail.org/faq/ )

Here's an almost ready to use sendmail.mc file

/etc/sysconfig/sendmail should have it run as a daemon. If you put it in from source you'll have to enable it. Mine said:

DAEMON=yes
QUEUE=1h (don't know which is more powerful, this one or the one in sendmail.mc)

1. Make sure the sendmail, sendmail-cf, and sendmail-doc RPMs are all in. The first two are on disk 1 and the docs on 3 (RH7.3)
2. Make sure pop3 is in. Pop3 is ipop3d. run which ipop3d.
It is installed with the imap rpm.
3. Make sure ipop3d is good to go by checking /etc/xinetd.d/ipop3 and making sure that
disable = yes is changed to disable = no.
You can do the same with /etc/xinet.d/imap and imaps if you have the SSL module in.
4. You can restart with /etc/rc.d/init.d/xinetd restart service sendmail start will start sendmail.
5. Put MX records in your zone files for your DNS zone files. I added

IN MX 1 linux.mydomain.cxm. <- 1 is the pecking order of the mail and there is a trailing dot. There is a space before IN.

redhat-config-bind made it look like this, with an @ mark first.

@    IN      MX    1    hostname.domainname.xx.

6. /etc/sendmail.cf has the line
Cwlocalhost in it by default. Change it to Cwyourdomain. I made mine

Cwmydomain.cxm -and-

Cwpentium.cxm ---Also add

DMmydomain.cxm
(couldn't find this on RH8's Sendmail)

Marcel, however, says to change the line DjSw.Foo.COM to DJmydomain.cxm
7. Next, he says to change /etc/mail/local-host-names and add aliases for your machine, such as

mail
mail.mydomain.cxm
mydomain.cxm
localhost


8. After restarting (/etc/rc.d/init.d/sendmail restart) it should work.

9. If you want to alias some email accounts, just edit /etc/mail/aliases

If you add:

glenne: glenn

glennski: glenn --Then email addresses to those will go to user glenn, too.

10. run newaliases on the comand line to add them.

11. You can test your configuration by running:

sendmail -bt <enter>

3,0 username

Ctrl-d gets you out.

sendmail.mc is in /etc/mail/. It is the file used to produce /etc/mail/sendmail.cf.(In < RH8 it was /etc/sendmail.cf)

- Use sendmail.mc to produce sendmail.rc by running it through the m4 processor.

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.rc

- anything in sendmail.mc with a dnl (delete to new line) in front of it is a comment. If you want to add that, take off the dnl and run it through m4.

- define(`something', `somethingelse') means "print the second one in the sendmail.cf," so define(`confTO_QUEUEWARN', `4h')dnl
means to set the TO_QUEUEWARN value to 4 hours in sendmail.cf. Actually 4 hours is the default, though. You've seen the "I haven't been able to send your mail for 4 hours" message.

Mick Bauer in "Hardening Sendmail" lists these steps:

Stuff in blue recommended by Mick Bauer for security

1. Enable needed features in sendmail.mc. This is a big step.

divert(-1)
include(`/usr/share/sendmail-cf/m4/cf.m4')
VERSIONID(`linux setup for Red Hat Linux')dnl
OSTYPE(`linux')
dnl 8:12 is the user:group number for user "mail" in /etc/passwd.
define(`confDEF_USER_ID',``8:12'')dnl
dnl Definitions have to come before the FEATURES associated with them
dnl The next one will let sendmail autorebuild needed databases

define(`confAUTO_REBUILD')dnl
define(`confTO_CONNECT', `1m')dnl
define(`confTRY_NULL_MX_LIST',true)dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
dnl This goes with feature redirect
define(`ALIAS_FILE', `/etc/aliases')dnl
define(`UUCP_MAILER_MAX', `2000000')dnl
define(`confUSERDB_SPEC', `/etc/mail/userdb.db')dnl
define(`confPRIVACY_FLAGS', `authwarnings,novrfy,noexpn,restrictqrun')dnl
define(`confAUTH_OPTIONS', `A')dnl
FEATURE(`no_default_msa',`dnl')dnl
dnl SendMailRestrictedShell restricts the .forward files users can put in their $HOME
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
dnl define(`confSAFE_FILE_ENV',`/var/mailjail')dnl
FEATURE(`mailertable',`hash -o /etc/mail/mailertable.db')dnl
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable.db')dnl

dnl redirect lets you define aliases in /etc/alias
FEATURE(redirect)dnl
FEATURE(always_add_domain)dnl
dnl use cw_file makes sendmail read local_host_names file
FEATURE(use_cw_file)dnl
dnl use_ct_file makes sendmail read trusted_users_file
FEATURE(use_ct_file)dnl
dnl The '-t' option will retry delivery if e.g. the user runs over his quota.
FEATURE(local_procmail,`',`procmail -t -Y -a $h -d $u')dnl
dnl /etc/access.db is a list of who can relay through this machine.
dnl Try makemap -C sendmail.cf -v hash access.db < access to see what it's doing.

FEATURE(`access_db',` -T<TMPF> hash -o /etc/mail/access.db')dnl
dnl blacklist restricts some users who shouldn't get mail from getting it, like "nobody"
FEATURE(`blacklist_recipients')dnl
dnl By default, sendmail won't relay (potentially fake) domains it can't resolve. The feature below that lets you do it should be commented out.
dnl FEATURE(`accept_unresolvable_domains')dnl
FEATURE(`relay_based_on_MX')dnl

<Masquerading stuff goes here.>

MAILER(smtp)dnl
MAILER(procmail)dnl
Cwdomainname.cxm

2. Set up domain-name masquerading, if needed, in sendmail.mc.

MASQUERADE_AS(`domainname.cxm')
MASQUERADE_DOMAIN(`mail.domainname.cxm')

dnl The above could be (`.domainname.cxm') -dot comes first in a big
dnl setup with multiple servers or just (`domainname.cxm')
dnl exposed user means that even if a whole domain is masqueraded, messages
dnl root show the host they came from

EXPOSED_USER(`root')dnl
dnl All hostnames will be stripped with the following
FEATURE(masquerade_entire_domain)
dnl Not only the header files but also the envelope will be masqueraded
dnl But you won't see this unless you send mail with low level stuff like
dnl command line mail.

FEATURE(masquerade_envelope)

Be careful with FEATURE(relay_based_on_MX). If you use it, it will subsitute the MX hostname for your hostname. If mail.mydomain.cxm is the MX, mail sent from host.mydomain.cxm will also be sent as from mail.mydomain.cxm. Can't imagine why you would want this.

Addtionally, Mick recommends this line, which is commented out in above:

define(`confSAFE_FILE_ENV', `/var/mail/mailjail')dnl

If you use it, you must do this to set up a type of chroot environment for sendmail

mkdir -p /var/mailjail/spool/mail     /var/mailjail/var/spool/mqueue
cd /var/mailjail
chown -R mail:mail *
chmod -R 700 *

3. Run m4 to generate sendmail.cf from sendmail.mc


m4 sendmail.mc > sendmail.cf

4. Configure delivery rules by editing mailertable.

The mailer table lets you route messages addressed a specific host or domain to a particular mail server. You can use the mailertable to address mail to a virtual domain to your mail server.

.mydomain.com      smtp:mail.mydomain.cxm

Sendmail doesn't read the test file mailertable; it reads the database. Make it with
Make mailertable.db - run in the /etc/mail directory.

5. /etc/mail/access Configure relay rules by editing access.
Again, /etc/mail/access is a list of allowed relayers. This is pretty important stuff. It should say:

localhost.localdomain  RELAY
localhost RELAY
127.0.0.1 RELAY
192.168.1 RELAY

It's dangerous to put real names in there, because they're so easily forged.

Mick says to make it with: make  access.db This uses the included Makefile.
You can also do: makemap -C sendmail.cf -v hash access.db < access
to call the makemap program.
In RH 9 I had to do this:

chown root access.db
make access.db
chown smmsp access.db
as permission was denied otherwise.

6. /etc/aliases Configure local user-aliases by editing /etc/aliases
These take the form
fakename: realname
If you add:

glenne: glenn

glennski: glenn

Then email addresses to those will go to user glenn, too. Run newaliases on the comand line to add them.

7. /etc/mail/local-host-name. Define all local hostnames in local-host-names.

local-host-names contains synonyms of the smtp gateway, the local server in small setups.

mail
mydomain.cxm
mail.mydomain.cxm
localhost

192.168.1.1

8. service sendmail restart



Shell - No shell by default

/etc/default/useradd has the default shell for new users.
Change to:

SHELL=/bin/noshell
to give new users no shell by default.

services -

start/stop You can make services start and stop automatically by using chkconfig. chkconfig --list httpd will tell you at which of the 6 runlevels httpd is to run. Make it start or not run with chkconfig --level <runlevel> <service> off/on. See page 473 of Using Linux.

Ex. chkconfig --level 35 smbd on # This makes samba run at levels 3 and 5

chkconfig telnet on # This starts telnet at the default runlevels
 
start/stop in RH 7.1 inetd.conf has become /etc/xinet.d and the services are inside. If you change the disable=yes to disable=no and then issue xinetd --restart things should change.

ntsysv - In Red Hat 6+ you can get the screen in which you decide what services start on bootup by issuing ntsysv. Run ntsysv --level 35 to effect changes at both run levels.

setuid - Find setuid files on server with this command:

find / -type f \( -perm -4000 -o -perm 2000 \) -ls > /danger.txt

SME server (e-smith)

Qmail doublebounce to devnull (from sme.swerts-knudsen.com)

mkdir -p /etc/e-smith/templates-custom/var/qmail/control
echo devnull > /etc/e-smith/templates-custom/var/qmail/control/doublebounceto
/sbin/e-smith/signal-event email-update
/etc/init.d/qmail restart

6.x and 7.x mailboxes

/home/e-smith/files/users/<username>/Maildir on 6.x and 7.x:

6.x 7.x This renaming and missing dir has made tarring up and over impossible to move mail from one machine to the other. However, expiramentation tells me that ;Inbox/cur mail tarred over to .Inbox/cur on 7.x will open and read just fine.
cur cur
;Inbox .Inbox
;junkmail .junkmail
new new
;sent-mail
tmp tmp


To get IlohaMail to work on e-smith:

If you cat /etc/httpd/conf/httpd.conf, you will find that there are Aliases. These seem to come from /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/30WebmailAliases

I added: $OUT .= " Alias /webmail2 /home/e-smith/files/primary/html/ilohamail/source\n ";
I added: $OUT .= " Alias /webmail3 /home/e-smith/files/primary/html/webmail3\n ";

and they showed up in /etc/httpd/conf/httpd.conf on reboot.

In /etc/e-smith/templates/etc/httpd/conf/httpd.conf/90e-smithAccess10primary I added:

Alias /webmail2   "/home/e-smith/files/primary/html/ilohamail/source"

<Directory "/home/e-smith/files/primary/html/ilohamail/source">
Options Indexes MultiViews
AllowOverride none
Order allow,deny
Allow from all
</Directory>

That didn't work either. The logs say that no symlinks are allowed to be followed from the document_root. Don't know how to allow it. (Worked on RH8)

Smoothwall (release .98)

Sort - Use "sort" command to alphabetize lines in a file. Very useful for putting users in password file in order.

source code for kernel is in /usr/source/linux

Control Panel

On the command line, type "control-panel."

SSL

Start / Stop eth0 (or whatever)

ifconfig eth0 up (down) will do it

Successful DMZ setup - I set up Smoothwall in a very standard way, nothing special. One thing you need to know is that Smoothwall did not have any DNS or Gateway configured at the time. At IEC I guess the gateway would be the Yamaha router and the DNS would be the AIO and the ISP.

sudo - (from http://www.dungog.net/sme/admin.php) Sudo access allows users to execute commands with the permissions of the root account without knowing the root password. This is more desirable than passing around the root password. sudo gives a user root privileges by prefixing the command with sudo

eg. sudo tail /var/log/messages

Swap - add another

Symlink/shortcut/alias - how to make one
ln -s file1 file2 creates a shortcut to file1 named file2

 

  Network - To configure the network use netcfg

ipconfig in NT

script writes macros. Type script and then follow with anything. It records your keystrokes. End with ctrl-D.

 

T

tar - the basic syntax for creating tar files is

telnet - You can install old-fashioned telnet on a machine by installing the telnet-server rpm. Then you've got to emable it in /etc/xinetd.d/telnet and restart the xinetd daemon.

  Users and Groups

VESA mode values - To get these different resolutions in the framebuffer, replace the

vga=normal line with vga=769 (for example) in /etc/lilo.conf

Resolution ----------------- Vesa mode values

8 bpp 16 bpp 24/32 bpp
640 x 480 769 785 786
800 x 600 771 788 789
1024 x 768 773 791 792
1280 x 1024 775 794 795

Using vi

To begin, type vi plus filename
vi + filename opens file at end of file
vi + /string opens file at first instance of the string
i inserts text before cursor

a inserts text after cursor

I inserts text at the beginning of current line

A inserts text at the end of current line

w tab forward

b tab backward

dw (delete word) deletes the word to the right of the cursor

6dw deletes the next 6 words

dd deletes current line

6dd deletes the next 6 lines

d deletes from the cursor to the end of the current line

d$ deletes from the cursor to the end of the line.

x deletes the character above the cursor

u undoes the last command

U undoes all the changes on a line

CTRL-R undoes the undo's on a line

r next letter you type will replace the letter above the cursor.

cw erases to the end of the word, and then replaces with what you type.

ZZ saves and quits. It's the same as :wq
:w saves but doesn't quit
:w! saves overwriting the present file
:w newfilename saves to a new name

Moving around
$ jumps to the end of the line
0 jumps to the beginning of the line
w jump ahead one word
b jump back one word
B jumps backward one word at a time, ignoring punctuation
z. If you don't like typing at the bottom of the screen, type z. to move everything up half a screen
H moves cursor to the top of the screen
M moves the cursor to the middle of the screen
L moves the cursor to the last line of the screen
e moves to the end of a word.
E moves to the period at the end of the word
( moves to the beginning of the sentence
) moves to the end of the sentence. Also moves you to the beginning of the next line to start typing
{ moves to the top of the current paragraph
} moves to the beginning of the next paragraph
G moves to the end of the file
1G moves to the beginning of the file


/string searches forward for the string
?string searches backward for the string

cw deletes to the end of the word and puts you in insert mode to overwrite
c$ deletes to the end of the line and puts you in insert mode to overwrite
x deletes the letter above the cursor
5x deletes the next 5 letters
r replace the letter above the cursor
s deletes the letter above the cursor and puts you in insert mode to start typing
dw deletes a word. 2dw deletes 2.
dd deletes whole line. 2dd deletes 2.
p pastes text in the buffer after the cursor and on the line below
P pastes before the cursor
xp means "transpose" Type it under 2 letters to transpose them.
yy copies the current line to the clipboard. 4yy does it for 4.
. repeats what you just did, like CTL + y
o opens a blank line below the cursor
O opens a blank line above the cursor

n searches forward for the next instance of a search
N searches backward for the next instance of a search

Cutting and pasting

yy "yanks" the text into an unnamed buffer (6yy yanks 6 lines)
:$ moves the cursor to the end of the file

p pastes the line

"ay) yank from cursor to the end of the paragraph and name "a"
"ayG yank from curor to the end of the page and name "a"
"ap paste buffer "a" on the next line down

VMware -How to install VMware Tools for Linux Guests (from the web site)

  1. Power on the virtual machine.

    After the guest operating system has started, prepare your virtual machine to install VMware Tools.

  2. Choose Settings > VMware Tools Install.

    The remaining steps take place inside the virtual machine.

  3. As root, open a terminal, mount the VMware Tools virtual CD-ROM image, copy its contents to /tmp, then unmount it.

    Note: You do not use an actual CD-ROM to install VMware Tools, nor do you need to download the CD-ROM image or burn a physical CD-ROM of this image file. The VMware Workstation software contains an ISO image that looks like a CD-ROM to your guest operating system. This image contains all the files needed to install VMware Tools in your guest operating system.

    Note: Some Linux distributions use different device names or organize the /dev directory differently. If your CD-ROM drive is not /dev/cdrom, modify the following commands to reflect the conventions used by your distribution.

  4. mount -t iso9660 /dev/cdrom /mnt
    cp /mnt/vmware-linux-tools.tar.gz /tmp
    umount /dev/cdrom


  5. Untar the VMware Tools tar file in /tmp, and install it.

    cd /tmp
    tar zxf vmware-linux-tools.tar.gz
    cd vmware-linux-tools
    ./install.pl

  6. Start X and your graphical environment if they are not started yet.
  7. In an X terminal, launch the VMware Tools background application.

    vmware-toolbox &

  8. You may run VMware Tools as root or as a normal user. To shrink virtual disks, you must run VMware Tools as root (su).

Webmin

Webmin is a graphical Admin tool that works over SSL at https://yourbox.whatever:10000. It does all kinds of things on screen using a web interface. Install it from the RPMs on your disk :

wvdial - a modem setup and dialer program

xcdroast launches the cd burn software

Xinetd - You can restart Xinetd with service xinetd restart.

X mouse pointer - Replace the "X" mouse pointer with an arrow

The various types of cursor available in X are defined in X11/cursorfont.h. You can change it using xsetroot -cursor_name name_of_cursor . For example, I have the following in my .Xclients:

xsetroot -cursor_name left_ptr

This will create the common left-angled pointer. To see other alternatives, type xfd -fn cursor. And of course, do not forget that man xsetroot is your friend.

Y

Yum - Yum is something like apt in that it keeps a database of rpms installed and resolves dependencies for you when you want to install something.

Say you wanted to enable the repository at dungog.net for smeserver. As root, you should run the following (can cut and past if using ssh in Linux shell):

db yum_repositories set dungog repository \
BaseURL http://sme.dungog.net/packages/smeserver/7.0/i386/dungog/ \
EnableGroups yes \
GPGCheck no \
Name 'SME Server 7 - dungog' \
Visible yes \
status disabled

Then to enable this change, you need to run:

/sbin/e-smith/expand-template /etc/yum.conf

(Needs a reboot after this.)

This adds dungog to the list of possibilities, but does not download their stuff automatically, as some stuff could clash if you don't know what you're doing.

If you want to install something from dungog using yum, run:

yum --enablerepo=dungog install smeserver-packagename-x.x-x.noarch.rpm

for example and it will fetch everything and let you know when it's ready. Don't forget to

signal-event post-upgrade ; signal event reboot afterward.

/var/cache/yum - This is where yum caches all the rpms it downloads. You can just copy it from one machine to another if you like.

Read man yum here