Linux Tips for the System Administrator

Bootup/Shutdown

Starting console in gui mode automatically
/etc/inittab
id:5:initdefault:  --> starts gui console
id:3:initdefault:  -->  starts cli console

reboot
poweroff

Devices

CDROM Burner (CDR/CDRW) Configuration

Configuration of an ATAPI CDR
Burning a CDR
Copying a CD to a file and mounting it as a file/cd on another system:
USB Memory Stick

Command Line Interface

Domain Name Service (DNS)

How do I configure Red Hat Linux 7.2 to be a cache-only DNS server?

To create a cache-only DNS server, all you need to do is install DNS. This is best done during the installation by either selecting all packages (this will install everything), or to do a custom installation and select the DNS Bind package. If you already have Red Hat installed, you add additional packages by using the installation CD and selecting the option to add packages rather than do a full installation.

Why doesn't DNS start after my Red Hat Linux 7.2 installation?

Red Hat Linux 7.2 seems to have a default permissions problem that prevents the named daemon from starting properly. DNS is started by launching the named daemon. This can be done simply by typing "named" at the command prompt when logged in as root. However, as named starts up it tries to create a file in /var/run/named directory. Since it cannot create this file due to a permissions restriction, it fails. The actual error messages can be found in the file /var/log/messages. To correct this problem all that is necessary is to change the permissions to this directory using the linux chmod command. For instance typing "chmod 777 named" from the /var/run directory will give everyone permissions to this directory (probably not the best choice of permissions for security).

How can I get DNS to start automatically during boot up? Using Gnome all that is necessary is to go to Programs->System->Service Configuration and to check the named box.

Filesystems

fdisk -l
Lists the filesystems on the server and their type
fuser -km /dir/file
The fuser command is used to see what processes are using a directory.  Most often this is used to identify what the umount command doesn't work.  By using the "-km" switches with fuser, then any process that is using the device, for any reason will be killed.  This is very useful for umount stubborn devices that insist they are busy.

rm -Rf
Recursively removes files and directories without prompting whether it is ok.  BE CAREFUL!!!

lsof 
Lists open files (Redhat only??)
-i  ipaddress  --> lists files whose internet address matches
-n  --> convert the ip address to name
-P   -->  does not convert portnumbers to portnames - used to increase performance

File Transfer Protocol (FTP)

Enabling FTP

Red Hat Linux 7.2 and 7.3 uses wu-ftp.  This is enabled by looking at it's configuration file located in /etc/xinetd.d.  In that directory are many configuration files.  Edit the file /etc/xinetd.d/wu-ftpd and change the value of disable=yes to disable=no.  Also make sure that server_args are set to "-1 -a".  Make sure that neither of those lines are commented out (line begins with #).

After these changes have been made you must stop and restart the xinetd daemon using the service command:

/sbin/service xinetd stop
/sbin/service xinetd start

IPCHAINS

Turn on routing

Routing is enabled under Red Hat Linux 7.2 in a file called ip_forward. This file is located in the /proc/sys/net/ipv4 directory. If it is disabled the contents will be a 0, if it is enabled then it will contain a 1. You can manually force the contents of this file by typeing the command "echo 1 > /proc/sys/net/ipv4/ip_forward. Finally there is third method to turn it on. In the file /etc/sysconfig/network add the line "FORWARD_IPV4=true".

Clear all pre-existing IPCHAIN rules

Clearing your existing IPCHAINs firewall rules is done by the -F option which "flushes" the rules. You can selectively choose which chain or chains to flush by choosing from these 3 commands which you must type from the command prompt:

ipchains -F input
ipchains -F output
ipchains -F forward

or you can clear all the rules on all of the chains with a single command:

ipchains -F

Allow unrestricted access

Although this is not a recommended final configuration for your firewall, it is necessary to do this before you start adding restrictions. Allowing unrestricted access requires first that you flush all rules (see question above). After flushing any existing rules, issue these 3 commands from the command prompt to configure the fire wall to accept traffic:

ipchains -P input ACCEPT
ipchains -P output ACCEPT
ipchains -P forward ACCEPT

IP Masquerading (Network Address Translation - NAT)

IP Masquerading must be configured for a range of address. Basically you are going to replace a range of internal addresses with the address of the firewall's public interface. For example, let's assume that we are using 192.168.1.0 - 192.168.1.255 as the internal addresses. To Masquerade these addresses issue the following 2 commands from the prompt:

ipchains -F forward
ipchains -A forward -s 192.168.1.0/24 -d ! 192.168.1.0/24 -j MASQ

List rules

Issue this command from the command prompt:

ipchains -L -n

Log Files

/var/log/messages  --> main system log

Networking

Network Configuration can be done manually, or with the CLI utility - netconfig, or by using the gui --> system tools --> networking

IP Address/Subnet mask/Default Gatway information goes in:  /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.212.1.139
NETMASK=255.255.255.0
GATEWAY=10.212.1.254
TYPE=Ethernet
USERCTL=no
PEERDNS=no

Host Name goes in:  /etc/hosts and in /etc/sysconfig/network

/etc/hosts:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       NUSALES2        localhost.localdomain   localhost

/etc/sysconfig/network
NETWORKING=yes
HOSTNAME=NUSALES2

DNS goes in:  /etc/resolv.conf
search corporate.vox.net vox.net
nameserver 10.212.1.150

To verify network configuration:

ifconfig -a  --> this will list all of the interfaces and how they are configured
ping <host> or ping <ipaddress>  --> doing this from a different machine will verify that this host is visi
mii-tool - ->  view and change media independent interface unit on nic
mii-tool -F 100baseTx-FD eth0  --> forces eth0 to 100MBS Full Duplex  (no autonegotiation)
ethtool  --> display or change ethernet settings on linux 2.4 or later kernels

To view the speed of a NIC:
[root@SERVER1 root]# mii-tool
eth0: negotiated 100baseTx-FD, link ok

Testing whether a port is open or closed using nmap

Network Time Protocol (NTP)


Performance Monitoring

free  --> memory
top
vmstat

Processes


R Commands (rsh, rlogin, etc)

How to setup .rhosts
rsync - updated copying fucntionality, beyond rcp.

Security

chroot <dir> <command>  - executes command with <dir> as the root directory.

Services

service <service> status
This command tells you if a particular service is running or not.  If it is running, it will give you additional details such as pids and configuration.

service --status-all

This gives the status of all services on the system, whether they are running or not.

/etc/rc.d/init.d/xinetd reload
This causes the xinetd daemon to reload in order to start services.

chkconfig
/etc/init.d/<service> stop|start|restart


Software/Packages

How to tell what packages are installed
RPMs (NOT source rpms)

Installing Source RPMs (src.rpm)
apt - Advanced Package Tool

/etc/aps/sources.list

System Information

hostid

The hostid generates a unique host id number.  This is often used for software licensing.  This number is actually taken from the /etc/hosts file.  It takes the ip address of the hostname and reverses the digits and converts the result to hexadecimal.  For instance a host with an ip address of 192.168.1.253 will have its address digits switched to 168.192.253.1.  Then these digits will be converted to hexadecimal, and the resulting hostid is:  a8c0fd01.

How to determine version of  Red Hat (often works for other versions of linux also)
cat /etc/redhat-release

How to determine the version of Linux
cat /proc/version

Hardware Information

Swap Space

Adding swap space to a running system


Telnet

Enabling Telnet

Tuning Parameters

User/Group Management

Process to add a user
Process to add a group

Layout of the entries in /etc/passwd

Layout of the entries in /etc/group
Identifying idle/active user sessions
Killing idle sessions

XWindows

startx --> starts xwindows from the command prompt

<Ctrl> <Alt> <Backspace>  -->  kills xwindows gui and returns to cli

switchdesk -->  changes the default desktop
switchdesk kde
switchdesk gnome
switchdesk configuration:
/usr/share/apps/switchdesk/Xclients.XXXX   <-- XXXX is the name of a gui

XFree86 -configure   --> when run as root this causes re-detection of hardware and reconfiguration xwindows

xdpyinfo --> displays configuration information about an X windows server

X -configure   --> reprobs for video devices and creates a configuration file (may be better than the default provided by distribution??)

Switching from gui to terminal

Change the resolution of XWindows
Starting X Windows Server








Back To Main Page For List Of Other Documents