linux_commands

Document Sample
linux_commands Powered By Docstoc
					Quick and Simple Intro Linux Commands
This document is for people who want a quick and simple list of some common commands, and some concepts described used in Linux.
Certainly, this file is absolutely no match for the countless technical arcticles you can find on the Internet.


Compiled by: Albert van der Sel - Antapex Technologies - Version 0.1 - 30 september 2008


Contents:
1.    Just Show Me The "total/free/used" Memory
2.    Traditional Disk Management
3.    Disk Management with a Logical Volume Manager LVM
4.    Kernel and tunable parameters
5.    Network files and related commands
6.    Some very handy shell tools/commands
7.    Filemodes and permissions
8.    Backup / recovery commands
9.    Bootloaders, booting the system, creating bootdisks
10.   Proctools and Tracing the system (for troubleshooting purposes)
11.   Performance tools/measurements, profiling, resource management.


1. Just Show Me The "total/free/used" Memory

>>> Just Show memory (total, free, used etc..)
There are quite a few commands that you can use to see the available and used memory, like:

# free -m
                             [root@starboss~] # free -m
                                                  total                 used        free     shared
                             Mem:                   249                  247           2          0
                             -/+ buffers/cache
                             Swap:                 1027                      0      1027
                             [root@starboss~] #


# /usr/sbin/dmesg | grep "Physical"

# cat /proc/meminfo

                             [root@starboss~] # cat /proc/meminfo
                             MemTotal:        255928 kB
                             MemFree:            3240 kB
                             Buffers:           13100 kB
                             Cached:          137856 kB
                             …
                             (much more output)
                             …
                             [root@starboss~] #

There might also be "utilities" on your system, which shows "real-time" cpu-, disk, and memory u
# top
# nmon

But there is much more to see. You might try "vmstat" which can be used with serveral parameters
Also, the command "sar" is available on most systems, which can give you numerous performance in
usage, use:

# sar -r                                 # gives you "quick" info on swap and memory utilization
# vmstat 1 10                     # note 10 is a ten second interval where measurement is taken.

You could see output like:
  procs                      memory         swap           io     system              cpu
 r b w     swpd   free   buff cache        si so      bi    bo   in    cs   us   sy     id
 2 0 0 111304     9728   7036 107204        0    0     6    10 120     24   10    2     89
 2 0 0 111304     9728   7036 107204        0    0     0      0 526 1653    96    4       0
 1 0 0 111304     9616   7036 107204        0    0     0      0 552 2219    94    5       1
 1 0 0 111304     9616   7036 107204        0    0     0      0 624   699   98    2       0
 2 0 0 111304     9616   7052 107204        0    0     0    48 603 1466     95    5       0
 3 0 0 111304     9620   7052 107204        0    0     0      0 768   932   90    4       6
 3 0 0 111304     9440   7076 107360       92    0   244      0 820 1230    85    9       6
 2 0 0 111304     9276   7076 107368        0    0     0      0 832 1060    87    6       7
 3 0 0 111304     9624   7092 107372        0    0    16      0 813 1655    93    5       2
 2 0 2 111304     9624   7108 107372        0    0     0   972 1189 1165    68    9     23

Now take it as an exercise to investigate what "free", "si" and "so" will tell you. (See also Se
Note: please observe that cpu statistics are also listed in vmstat's output.




Section 2. "Traditional" Disk Management (no use of Logical Volume Ma
WARNING: BE CAREFULL IN USING FDISK (or comparable utility), UNLESS YOU WORK WITH JUST A
CARELESS USE OF FDISK COULD WIPE OUT AN ENTIRE DISK.

On any system, you should be able to add (and remove) harddisks. If you add a disk, you should o
be able to manipulate the disk in such a way, so that your system can use it.

Actually, there are 3 "mainstreams" to distinquish here:

- Partitioning and formatting a disk in the (old) and traditional way with "fdisk", and
- Working with a Logical Volume Manager
- Extra steps needed if you need a Clustered File System.

First, we discuss the "traditional" way of handling a new disk in your system.

>>> Entire harddisks are listed as devices without numbers, such as "/dev/hda" or "/dev/

- IDE:
/dev/hda     is   the   primary IDE master drive,
/dev/hdb     is   the   primary IDE slave drive,
/dev/hdc     is   the   secondary IDE master,
/dev/hdd     is   the   secondary IDE slave,

- SCSI:
/dev/sda    is the first SCSI interface and 1st device id number
/dev/sdb
etc..

>>> Partitions on a disk are referred to with a number such as "/dev/hda1"
/dev/hda1
/dev/sda1

So, suppose we have a (new) disk (device /dev/sdb) we want to take into use. Do the following:
We will use "fdisk" to create a partition. Note: on some distros "parted" is a "fdisk" lookalik
Use the n command to create a partition.
Use the p command to list the partition table of the device.
After you have created the required partitions on this device, use the w command to write the mo
The following example uses fdisk to create a 256 MB partition on the raw device, /dev/sdb.
# /sbin/fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 1073 MB, 107341824 bytes
34 heads, 61 sectors/track, 1011 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes

   Device boot            Start         End   Blocks      ID   System

Command (m for help): n
Command action
  e extended
  p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1011, default 1):
Using default value 1
Last cylinder of +size or +sizeM or +sizeK (1-1011, default 1011): +256M

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#

Ok, so now we have a small partition, but we still need to create a filesystem on that partition

        Note: suppose you did not see the "/dev/sdb" (and other devices). Now what?
        Tip 1:
        If you cannot find the device files /dev/sda in /dev, you might
        create it (on some distros) with the /dev/MAKEDEV script:

        # cd /dev
        # ./MAKEDEV sda

        Tip 2:
        If there are none you can create them by doing (as root, indicated by the hash).
                     # mknod /dev/sda b 8 0
                     # mknod /dev/sda1 b 8 1
                     # mknod /dev/sda2 b 8 2
        etc, up to /dev/sda15 if necessary. The device as a whole is mapped to /dev/sda, while
        represent the various partitions of the device.

>>> What common filesystems can we create?

Linux supports a huge number of filesystems, including FAT (vfat), JFS, NTFS etc.. But the most
For the "native" filesystems, we take a look at the following FS's:

- ReiserFS
A journaled filesystem

- Ext2
The most popular filesystem for years. But it does not use a log/jounal,
so gradually it becomes less important.

- Ext3
Very related to Ext2, but this one supports journaling.
An Ext2 filesystem can easily be upgraded to Ext3.
There are also "shared Clustered filesystems" possible, which are needed in clustered systems.
Here you might think of OCFS2 (from Oracle) or RedHat GFS.

>>> Now we need to create a filesystem on our new partition

Here are just a bunch of examples on creating a File System on a new partition:

#   mkdosfs -F 32 /dev/sda1                                       #   Create   an ms-dos filesystem
#   mke2fs /dev/sda1 2048256                                      #   Create   a ext2 filesystem
#   mkfs -t ext2 -b 4096 /dev/sda1                                #   Create   a ext2 filesystem
#   mkfs.ocfs2 -b 4K -C 32K -N 4 -L /u03 /dev/sdc1                #   create   a clustered OCFS2 fi
#   mkfs -t ext3 /dev/hda1                                        #   Create   a ext3 filesystem
#   mkfs.ext3 /dev/sda5                                           #   Create   a ext3 filesystem
mkfs is some sort of Primordial "make filesystem" UNIX command.
You can call type specific "methods" with:

mke2fs
mkfs.ext3
mkfs.msdos
mkfs.vfat

In section 3, we will look at disk management if we have a Logical Volume Manager (LVM) at our d




Section 3. Disk Management with a Logical Volume Manager LVM

WARNING:             BE CAREFULL IN USING THE TOOLS LISTED IN THIS SECTION, UNLESS YOU WORK WITH
                     OR IF YOU KNOW EXACTLY WHAT YOU ARE DOING.

Logical volume management provides a higher-level view of the disk storage on a computer system
If you are able to use a LVM, you do not talk any more about single (formattable) diskpartitions
on a single disk, like we have seen in Section 1, but these are the items you will deal with:

Volume Group (VG):   one or more disks grouped together in an administrative entity "Volume Grou
Logical Volume (LV): An entity that will become a filesystem. The LV is created on a Volume Grou
                     and it's possible to implement a RAID level, such as RAID 1 (which is mirro
Physical Volume (PV): In most cases, this is synonym to a single disk, but it could also refer

Lets take a look on some examples on how to create a "Volume Group", which will make things much

# vgcreate my_volume_group /dev/hda1 /dev/hdb1
# vgcreate my_volume_group /dev/ide/host0/bus0/target0/lun0/part1 \
                           /dev/ide/host0/bus0/target1/lun0/part1
# vgcreate -s 16M my_vol_grp /dev/hda1 /dev/hda2
# vgcreate test_vg /dev/sd[k-m]1
You can check the result of your work at this stage by entering the command:

# vgdisplay
Note: its worth thinking a bout the desired "extend size". In most implementations, the default
65534 so that could have effect on the max size of usable storage in this VG

Ok, so its relatively easy to create a VG, but now what? Well, on a VG you can create a LV which
This way, you might be able to create really large filesystems, or mirror a filesystem (to be sa
        1. Step that might be needed before you can use vgcreate, lvcreate:
        Maybe, before we could create a VG from just a number of real partitions (/dev/hda1) or
        we might just need to do a step beforehand.

        Our first step in setting up LVM involves properly initializing these partitions so tha
        by the LVM system.
        the pvcreate command.

        # pvcreate /dev/hda1 /dev/hda2 /dev/hda3
        # pvscan

        The above step creates a physical volumes from 3 partitions which I want to initialize
        in a volume group.

        Or, initialize a whole disk as a PV:   # pvcreate /dev/hdb

        Step Two : Creating a volume group. You can think of a volume group as a pool of storag
        or more physical volumes. While LVM is running, we can add physical volumes to the volu

        First initialize the /etc/lvmtab and /etc/lvmtab.d files by running the following comma

        # vgscan

        Now you can create a volume group and assign one or more physical volumes to the volume

        # vgcreate my_vol_grp /dev/hda1 /dev/hda2


Now that we have VG's, we want to create LV's (possibly spanning multiple disks, or maybe we wan
lets take a look at an example:

# lvcreate -l 50 -n my_logical_vol my_vol_grp
The above command allocates 50 extents of space in my_vol_grp to the newly created my_logical_vo
The -n switch specifies the name of the logical volume we are creating.

Now you can check if you got the desired results by using the command :

# lvdisplay
Once a logical volume is created, we can go ahead and put a filesystem on it, mount it, and star
the volume to store our files. For creating a filesystem, we do the following:

# mke2fs -j /dev/my_vol_grp/my_logical_vol
The -j signifies journaling support for the ext3 filesystem we are creating.
Mount the newly created file system :

# mount /dev/my_vol_grp/my_logical_vol /data
Also do not forget to append the corresponding line in the /etc/fstab file

>>> Other examples:

# lvcreate -i 3 -I 8 -L 100 vg00
# lvcreate --size 100m --snapshot --name snap /dev/vg00/lvol1
>>> Other Info

The operational state of active volume groups with their physical and logical volumes can be fou
 /proc/lvm/global contains a summary of all available information regarding all VGs, LVs and PVs
Section 4. Kernel and tunable parameters
Some people say: Unix and Linux are simple OS'ses. There is a kernel, (loadable) device drivers,
filesystems, important libraries (for user programs), and a shell (actually a number of shells).

At the time of writing, the latest stable version of the Linux kernel is:   2.6.26.5
The latest 2.4 version of the Linux kernel is: 2.4.36.7

This is typical of Linux. You get a kernel, and if you want all supporting "stuff" (to get a usa
or get in another way, a "complete" system, which is called a distribution.
So, you could for example obtain "OpenSuse 10.2", with a kernelversion of 2.6.18.8.


>>> Where on the filesystem sits the kernel?

On Linux, if you browse around a bit on the filesystems, you could find on many systems
/boot/vmlinux-<version>
where <version> stands for that particular kernelversion like 2.6.18.8-0.10

But it could also be the file /vmlinuz, or /vmlinux, or /boot/vmlinux or /boot/vmlinuz.
In some installations, /vmlinuz or /vmlinux are a soft link to the actual kernel, so you may nee
the kernel by following the links. To find the kernel being used
look in "/etc/lilo.conf" or "/boot/grub/grub.conf". Both LILO and GRUB are well known bootloader
and they use their associated ".conf" file to locate the kernel.
But there are other bootloaders as well.

>>> What does the kernel do?

The Linux kernel's primary functions are to control access to physical devices on the computer a
processes interact with these devices. The /proc directory contains hierarchy of virtual folders
the current state of the kernel. Viewing files within /proc allows the user to peer into the ker
In addition, the user can use these virtual files to communicate configuration changes to the ke

Or more precise:
The kernel "reacts" to a number of events, like "hardware interrupts", and "system calls" from o
The kernel "offers" an API, that programs can use "to get things done". Those are "system calls"
or coding in ASM, most programs uses "libaries", like glibc type of libaries, in such a way, tha
a call to fopen() which a C program might use, in fact then uses a standard library which does t
as required by the kernel and generating the system call.


>>> How to manage the kernel so it will work with resources (tunable limits in RAM, disk

This is where the main Linux distro's can differ a little bit. First we take a look on how Redha
with the tunable kernel params.

1. sysctl and /etc/sysctl.conf

The kernel will take the values in "/etc/sysctl.conf" as rules on how to arrange and deal with c
such as the size of a shared memory segment, the number of threads the operating system will use
or the maximum number of processes on the system, or security related tunables.
The primary Administrative interface is the utility "/sbin/sysctl" with which you can change the
tunable kernel parameters.

sysctl is used to modify kernel parameters at runtime. The parameters available are those listed
Procfs is required for sysctl(8) support in Linux. You can use sysctl(8) to both read and write
What this means is, that what you see in the virtual filesystem "/proc", under the sys subdirect
are the kernel params you can alter with the sysctl command.

Examples:

/sbin/sysctl -a                                                 # -a means "show all current va
/sbin/sysctl -w kernel.domainname="example.com"                 # -w means "change the value"
/sbin/sysctl -p /etc/sysctl.conf                                # Load in sysctl settings from
Now, if you must configure the parameters for some application, you might enter statements like

# sysctl -w kernel.shmmax=100000000
# sysctl -w fs.file-max=65536
But you can also use:

# echo "kernel.shmmax = 100000000" >> /etc/sysctl.conf
# echo "kernel.shmmax = 2147483648" >> /etc/sysctl.conf
or you can try someyhing like:

cat >> /etc/sysctl.conf << EOF
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 658576
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 1048536
net.core.wmem_max = 1048536
EOF
/sbin/sysctl -p
Another Example:

Suppose, before installing some application, you are instructed to run

# ipcs -l
This command shows how the system will handle Semaphores, limits in Shared memory, and message q
(whatever that all maybe, but that’s not the issue here).

Suppose you see this output:

------   Shared Memory Limits --------
   max   number of segments = 4096                       // SHMMNI
   max   seg size (kbytes) = 32768
   max   total shared memory (kbytes) = 8388608
   min   seg size (bytes) = 1

   ------ Semaphore Limits --------
   max number of arrays = 1024                          // SEMMNI
   max semaphores per array = 250
   max semaphores system wide = 256000
   max ops per semop call = 32
   semaphore max value = 32767

   ------ Messages: Limits --------
   max queues system wide = 1024                        // MSGMNI
   max size of message (bytes) = 65536
   default max size of queue (bytes) = 16384            // MSGMAX

Now you are instructed to modify the kernel parameters by adding the following entries to the de
system control configuration file, /etc/sysctl.conf:

kernel.msgmni = 1024
kernel.sem = 250 256000    32 1024

Run sysctl with -p parameter to load in sysctl settings from the default file /etc/sysctl.conf.
Another example:

Suppose you want to check some tunable parameters, you could do that via a command like:

# /sbin/sysctl -a | egrep 'sem|shm|file-max|ip_local'
net.ipv4.ip_local_port_range = 1024      65000
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.shmmax = 2147483648
fs.file-max = 65536



2. Modules:

Or "Loadable Kernel Modules", LKM

Without loadable kernel modules, an operating system would have to have all possible anticipated
into the base kernel. Much of that functionality would reside in memory without being used, wast
and reboot the base kernel every time new functionality is desired. Most operating systems suppo
will include modules to support most desired functionality.

LKM's could be:

Device drivers.
Filesystem drivers
Additional System calls
Network drivers
TTY line disciplines
Other

You control the LKM's with:

lsmod - list loaded modules.
rmmod - unload loadable modules
insmod - install loadable kernel module
modprobe - used to load or unload modules
modinfo - shows module information.

How do you use it?

Inserting a module "could" be a simple as:

# insmod serial.o
But…, in general however, you could easily receive messages about a module/kernel version mismat

If you have loaded an LKM, you can verify that via /proc/modules. But how do you know it's worki
and varies according to what kind of LKM it is, but here are some of the more common actions of
The first thing a device driver LKM does after loading (which is what the module would do at boo
the base kernel) is usually to search the system for a device it knows how to drive. Just how it
from one driver to the next, and can usually be controlled by module parameters. But in any case, if the dr
capable of driving, it causes the load to fail. Otherwise, the driver registers itself as the dr
nd you can start using the device it found via a device special file that specifies that major n
or the interrupt level that the device uses. It may also send setup commands to the device, so y

You can see that a device driver has registered itself in the file /proc/devices.
You can see that the device driver is handling the device's interrupts in /proc/interrupts.

Use modprobe:

The modprobe command does a "intelligent" upload of modules, and can resolve all dependencies be
# modprobe msdos
This performs an insmod of msdos.o, but before that does an insmod of fat.o, since you have to h

Examples:
# modprobe scsi_mod

>>> Note about /proc

The /proc/ directory contains a hierarchy of special files which represent the current state of
and users to peer into the kernel's view of the system.

Within the /proc/ directory, one can find much information about the system hardware and any pro
some of the files within the /proc/ directory tree can be manipulated by users and applications
configuration changes to the kernel. Above, we have seen some examples of this effect.

A Virtual File System
Under Linux, all data are stored as files. Most users are familiar with the two primary types of
But the /proc/ directory contains another type of file called a virtual file. It is for this rea
referred to as a virtual file system.
These virtual files have unique qualities. Most of them are listed as zero bytes in size and yet
it can contain a large amount of information. In addition, most of the time and date settings on
current time and date, indicative of the fact they constantly changing.
Virtual files such as interrupts, /proc/meminfo, /proc/mounts, and /proc/partitions provide an u
of the system's hardware. Others, like /proc/filesystems and the /proc/sys/ directory provide sy
configuration information and interfaces.
For organizational purposes, files containing information on a similar topic are grouped into vi
For instance, /proc/ide/ contains information for all physical IDE devices. Likewise, process di
each running process on the system.

As a general rule, most virtual files within the /proc/ directory are read only. However, some c
adjust settings in the kernel. This is especially true for files in the /proc/sys/ subdirectory.
We already have seen how we can use "sysctl" to do that. But there are even simpler way to chang
To change the value of a virtual file, use the echo command and a > symbol to redirect
the new value to the file. For instance, to change your hostname on the fly, you can type:

echo starboss.com > /proc/sys/kernel/hostname
Other files act as binary or boolean switches. For instance, if you type cat /proc/sys/net/ipv4/
you will see either a 0 or a 1. A 0 indicates the kernel is not forwarding network packets. By u
to change the value of the ip_forward file to 1, you can immediately turn packet forwarding on.




Section 5. Network files and related commands

Most Linux distributions are quite similar when we talk about network configuration files and co
though differences exists, especially in the graphical interface that you can use in displaying
Some important items though, like the primordial unix files "/etc/hosts" file, or "/etc/resolv.c
are ofcourse the same everywhere.
Let's see how this all works in RedHat and Suse, two well known distributions.

The "/etc/hosts" file.
This file lists mappings of Hostnames to IP addresses.
Especially client workstations will likely use DNS for Hostname/IP address resolving.
In case of server machines, even if nameservers are used (DNS), this file usually list certain
Hostnames/IP addresses to which communication is vital.

Example:
# IPAddress           Hostname         Alias
127.0.0.1           localhost            starboss.antapex.org
218.164.1.20        srv1.antapex.org     srv1
218.164.1.20        srv2.antapex.org     srv2

The "/etc/resolv.conf" file.
This file is another text file, used by the resolver that determines the IP addresses for the DN
Here you tell the system three things:

 What domain we're in
 Specify any additional search domains
 What the nameservers are (it will use them in the order you put them in the file)

# cat /etc/resolv.conf
domain yourdomain.com
nameserver 192.168.0.9
nameserver 192.168.0.11



5.1 Some network config files and commands in RedHat.
You can do most network configuration from the "Redhat Network Configuration" tool. This is a gr
From a terminal, enter
# redhat-config-network                         # if you don’t run X, a textbased version will s

>>> Network Device Configuration Files "/etc/sysconfig/network-scripts/ifcfg-ethX":

Your network device configuration files are located in "/etc/sysconfig/network-scripts/"
directory, and are called "ifcfg-eth0" for your 1st adapter, "ifcfg-eth1" for your second adapte
But it could also be that such a file is called "ifcfg-eth0-mac_address, where "mac_address"
indeed is the real mac address of the adapter.

Below is an example content of for example, "ifcfg-eth0":
           DEVICE=eth0
           IPADDR=192.168.1.50
           NETMASK=255.255.255.0
           NETWORK=192.168.1.0
           BROADCAST=192.168.1.255
           ONBOOT=yes
           BOOTPROTO=none
           USERCTL=no



>>> The "/etc/sysconfig/network" file.
This file specifies routing and host information for all network interfaces.
The /etc/sysconfig/network file is used to specify information about the desired network configu
Example:

           NETWORKING=yes
           FORWARD_IPV4=yes
           HOSTNAME=starboss.antapex.org
           GATEWAY=0.0.0.0
           GATEWAYDEV=




>>> The "Network Administration Tool".

To use the Network Administration Tool, you must have root privileges.
To start the application, go to the Main Menu Button (on the Panel) =>
 System Settings => Network, or type the command
# redhat-config-network

at a shell prompt (for example, in an XTerm or a GNOME terminal).
If you type the command, the graphical version is displayed if X is running,
otherwise, the text-based version is displayed. To force the text-based version to run,
use the redhat-config-network-tui command.


>>> /etc/sysctl.conf
We already have seen that many tuneable kernel params are written in
"/etc/sysctl.conf" and which you can set with the sysctl utility.
Also a number of network params are collected here, as for example:

net.ipv4.ip_forward = 1

And, ofcourse, the config files we already have seen
in the beginning of section 5.
>>> /etc/hosts
>>> /etc/resolv.conf
>>> /etc/services


>>> If you have done your reconfiguring:
Use "network restart"
# /etc/rc.d/init.d/network restart
            Setting network parameters             [   OK   ]
            Bringing up interface lo               [   OK   ]
            Bringing up interface eth0             [   OK   ]
            Bringing up interface eth1             [   OK   ]



5.2 Some network config files and commands in Suse.
In OpenSuse 9, 10.x, you can configure your system, and thus also your networkdevices, with "Yas

If you look at what configfiles gets configured, its quite similar to RedHat (section 5.1).

Main Configuration files

>>> /etc/sysconfig/network/ifcfg-ethN
Here too, we have the "/etc/sysconfig/network/ifcfg-ethN" files for your network interfaces.
Again these are the systems's configuration files for every network interface where "EthN" can b
(eth0, eth1, lo, ppp0...), or indicate what hardware is used (usb, pcmcia).
But it could also be that such a file is called "ifcfg-eth0-mac_address, where "mac_address"
indeed is the real mac address of the adapter.

See section 5.1 for an example content.
The main parameters used in these files are:
BOOTPROTO=           - Can be static (IP configured manually), dhcp (IP oubtained through DHCP)
IPADDR =             - fill in the IP address
BROADCAST=           - fill in the networks broadcast address (for example 192.168.1.255)
NETMASK=             - fill in the subnet mask used in your subnet
NETWORK=             - fill in the networkaddress of your subnet (for example 192.168.1.0)
MTU=                 - Defines the Maximum Transfer Unit (the size of every IP packet). Default on ethern
STARTMODE=           - Indicates the time/event to activate the interface: onboot (at system's boot), hot
Other parameters can be used and can vary according to the interface type.

>>> /etc/sysconfig/network/config
There are some general settings in the file /etc/sysconfig/network/config. You can also set ever
in the ifcfg-* files we have seen above. So the ifcfg-ethN files allow for more granular control
>>> /etc/sysconfig/network/dhcp
Obviously, this sets parameters related to dhcp use (logging, lease time, timouts, modification
wait time at boot etc..).

>>> /etc/sysconfig/network/wireless
Lists the various parameters that can be applied to wireless devices (essid, frequency, sensibil
the associated ifcfg file of the wireless device.


/etc/sysconfig/network/routes
Defines all the (general) static routes. It's possible to specify routes exclusively related to
The format of this file is:
DESTINATION GATEWAY NETMASK|PREFIX INTERFACE [TYPE] [OPTIONS]

>>> /etc/hosts
>>> /etc/resolv.conf
>>> /etc/services

These files we have already seen in the begin of section 5.

>>> /etc/HOSTNAME
Contains the hostname of the system. Some scripts might refer to this file..


>>> If you have done your reconfiguring:
Use "network restart"
# /etc/rc.d/init.d/network restart
            Setting network parameters
            Bringing up interface lo
            Bringing up interface eth0
            Bringing up interface eth1

Or use:

# /sbin/rcnetwork restart




Section 6. Some very handy shell tools/commands.

I will not "bore you to death" with an intro on how to navigate through te filesystems (with "cd
Its assumed that you have a general idea about the hierarchical filesystems of Linux,
how to retrieve listings of files and directories ("ls command"), and how to move around ("cd"),
to copy files ("cp") or move files ("mv").

If you work with linux, you machine will probably start up to a graphical environment.
But you can always start up a "terminal", which shows you a "$ prompt" for ordinary users,
and (traditionally) a "# prompt" if you are the boss, that is, the root user.


>>> The "find" command.

1. Example: Simple use of the find command:

Suppose you are in the /usr filesystem, and you are sure that "somewhere" in all those subdirs,
"dsm.opt" exists, but you don't know where exactly its located. Searching manually through all t
Use the find command:

#   find . -name "dsm.opt" -print
will show you that the file is located in

/usr/tivoli/tsm/client/ba/bin

Now take a look at the statement above. The "." designates to "find", that it should search from
directory, which in this example is /usr.
The "-name" tells "find" the name of the file. In the example, I have put dsm.opt within quotes
short simple filename, but in general it can't hurt to use the quotes all the time.
Especially if you use wildcards in the filename, like "*", which is also possible.
So you could also have done:

#   find . -name "*.opt" -print

which would return a listing of all *.opt files, located in all subdirs within /usr

So "find" is really a terrific search command. But you can do much more with "find"


2. Example: More advanced use of the find command:

The number of "arguments" you can pass to "find" are quite huge.
Note: technically, one should speak of "options", "expressions" and stuff like that when one pa
However, I keep it simple, and just will talk about "arguments" (which is not correct).

Suppose that you want "find" to search all directories for certain filetypes (like logfiles *.lo
by some criteria (like older than 30 days) do "something" with those files (who have met the cri
So you could for example delete all old logfiles, that are older than, for example, 30 days.
Or you could change the filemode (permissions: the rwxrwxrwx stuff) of all those files in one sw

So take a look at the following command:

# find . -type f -mtime +30 -name "*.log" -exec rm {} \;

What are we doing here? We ask "find" to produce a list of all files (-type f) with a filename l
which are older than 30 days (-mtime +30), in all subdirs as from the current position.
Then we ask "find" to process the list of files as follows:
It should execute (-exec) the "rm" command, where "rm" gets the list of files which "find" has f
The argument '{}' inserts each found file into the "rm" command line.
The \; argument indicates the exec command line has ended.

So, we have deleted all *.log files older than 30 days, starting from the current directory.

Needless to say, especially when using "find" in combination with "-exec rm {}",
that you NEED TO BE CAREFULL, AND ALWAYS TEST YOUR COMMANDS ON A HARMLESS TESTSYSTEM.


3. Other Examples:

If you are new to the find command, you can take a look at some of the following examples
to get inspiration.

# find . -name "rc.conf" -print

This command will search in the current directory and all sub directories for a file named rc.co
Note: The -print option will print out the path of any file that is found with that name. In gen
print out the path of any file that meets the find criteria.

# find . -name "rc.conf" -exec chmod o+r '{}' \;

This command will search in the current directory and all sub directories. All files named rc.co
by the chmod -o+r command. The argument '{}' inserts each found file into the chmod command line
The \; argument indicates the exec command line has ended.
The end results of this command is all rc.conf files have the other permissions set to read acce
(if the operator is the owner of the file).
# find . -exec grep "www.athabasca" '{}' \; -print

This command will search in the current directory and all sub directories.
All files that contain the string will have their path printed to standard output.

# find / -xdev -size +2048 -ls | sort -r +6

This command will find all files in the root directory larger than 1 MB.

# find .    -exec grep "CI_ADJ_TYPE" {} \; -print

This command search all subdirs all files to find text CI_ADJ_TYPE


Now Just A Bunch Of Other find Examples:

# find . -name file -print
# find / -name $1 -exec ls -l {} \;

# find / -user nep -exec ls -l {} \; >nepfiles.txt
In English: search from the root directory for any files owned by nep
and execute an ls -l on the file when any are found.
Capture all output in nepfiles.txt.

# find $HOME -name \*.txt -print
In order to protect the asterisk from being expanded by the shell,
it is necessary to use a backslash to escape the asterisk as in:

# find / -atime +30 -print
This prints files that have not been accessed in the last 30 days

# find / -atime +100 -size +500000c -print
The find search criteria can be combined. This command will locate and list all files
that were last accessed more than 100 days ago, and whose size exceeds 500,000 bytes.

# find /opt/bene/process/logs -name 'ALBRACHT*'     -mtime +90 -exec rm {} \;

#   find /example /new/example -exec grep -l 'Where are you' {} \;
#   find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;
#   find . -name '*.trc' -mtime +3 -exec rm {} \;
#   find / -fsonly hfs -print
#   cd /; find . ! -path ./Disk -only -print | cpio -pdxm /Disk
#   cd /; find . -path ./Disk -prune -o -print | cpio -pdxm /Disk
#   cd /; find . -xdev -print | cpio -pdm /Disk
#   find -type f -print | xargs chmod 444
#   find -type d -print | xargs chmod 555
#   find . -atime +1 -name '*' -exec rm -f {} \;
#   find /tmp -atime +1 -name '*' -exec rm -f {} \;
#   find /usr/tmp -atime +1 -name '*' -exec rm -f {} \;
#   find / -name core -exec rm -f {} \;
#   find . -name "*.dbf" -mtime -2 -exec ls {} \;


* Search and list all files from current directory and down for the string ABC:
find ./ -name "*" -exec grep -H ABC {} \;
find ./ -type f -print | xargs grep -H "ABC" /dev/null
egrep -r ABC *
* Find all files of a given type from current directory on down:
find ./ -name "*.conf" -print
* Find all user files larger than 5Mb:
find /home -size +5000000c -print
* Find all files owned by a user (defined by user id number. see /etc/passwd) on the system: (co
find / -user 501 -print
* Find all files created or updated in the last five minutes: (Great for finding effects of make
find /   -cmin -5
* Find   all users in group 20 and change them to group 102: (execute as root)
find /   -group 20 -exec chown :102 {} \;
* Find   all suid and setgid executables:
find /   \( -perm -4000 -o -perm -2000 \) -type f -exec ls -ldb {} \;
find /   -type f -perm +6000 -ls



Note: whats the difference between mtime, atime, and ctime?

In using the find command where you want to delete files older than a certain date, you can use
commands like
find . -name "*.log" -mtime +30 -exec rm {} \;   or
find . -name "*.dbf" -atime +30 -exec rm {} \;

Why should you choose, or not choose, between atime and mtime?

It is important to distinguish between a file or directory's change time (ctime), access time (a
and modify time (mtime).

ctime -- In UNIX, it is not possible to tell the actual creation time of a file. The ctime--chan
         is the time when changes were made to the file or directory's inode (owner, permissions
         The ctime is also updated when the contents of a file change. It is needed by the dump
         to determine if the file needs to be backed up. You can view the ctime with the ls -lc

atime -- The atime--access time--is the time when the data of a file was last accessed. Displayi
         of a file or executing a shell script will update a file's atime, for example.

mtime -- The mtime--modify time--is the time when the actual contents of a file was last modifie
         This is the time displayed in a long directoring listing (ls -l).

Thats why backup utilities use the mtime when performing incremental backups:
When the utility reads the data for a file that is to be included in a backup, it does not
affect the file's modification time, but it does affect the file's access time.

So for most practical reasons, if you want to delete logfiles (or other files) older than a cert
date, its best to use the mtime attribute.


>>> Viewing the contents of a txt/ascii file: "cat", "pg", "more", "tail", "head"

There are a few usefull commands to view the contents of a txt (ascii) file, among which are:
cat, pg, tail, head, and a lot of other commands are available.
What I mean here is: quickly open the file for viewing the content. If you want to edit the file
you must use an editor (like "vi" which is present on any Unix/Linux system).

Note: there a number of filetypes on your system, like executables, libraries, plain text ascii
This section deals on the subject of "how to view the content of a plain ascii file".
If you are not sure about the filetype of a file, you might use the "file" command,
which will tell you what sort of file your dealing with.
Use "file" as follows:
# file <file_name>
like for example:

# file /etc/inetd.conf

will show you that this file is a readable ascii/txt file.

cat:

Actually cat is really ment to "concatonate" files, but it can also be used to view the content.
Use it as in the following example, where the file "oratab" is located in "/etc":
# cat /etc/oratab

will show you the contents of the txt file "/etc/oratab".
If the contents of the file is "more than one screen", you will only see the "last part", so in
of larger files, pipe the command to more, so you will be able to browse through the entire file

# cat /etc/oratab | more

pg:

This command will show you the contents of a file "one screen at the time". Press enter to go to

# pg /etc/oratab

more:

If you want to walk through the file, line by line, you can use "more" as in the following examp

# more /etc/oratab

tail:

If you want to view only the last "n" lines of a very large txt file, you can use the "tail -n <
For example, say that the logfile "/appl/was/server1/log/SystemOut.log"
contains over a million lines, and you are only interested in the last (most recent) lines in th
you could do this:
# cd /appl/was/server1/log/                     # first lets go to that directory
# tail -50 SystemOut.log                        # only show the last 50 lines of SystemOut.log
or, for example,
# tail -100 SystemOut.log                       # only show the last 100 lines of SystemOut.log

Some handy combinations:

Suppose again, that the logfile "SystemOut.log" contains very many lines, like WARNING messages,
kinds of other messages, and also a few ERROR messages. Now, suppose you are only interrested
in the ERROR messages. Browsing through a file that contains over a million lines, is no fun at
You could try something like this:

# cd /appl/was/server1/log/
# cat SystemOut.log | grep ERROR > /tmp/was_error.txt                 # or use grep -e to let gr

If you would "analyze" this command, you would say:
"cat SystemOut.log" just dumps the contents to "grep", because of the pipe "|" to grep.
The utility "grep" is a search utility. You can tell "grep" to search for as string,
in this case the string "ERROR".
Whatever "grep" will find, will be "redirected" to (by use of the ">" symbol), to
a new textfile, namely "/tmp/was_error.txt".
Now you can inspect that new txt file, which is a lot easier to do than SystemOut.log,
which in our example contains over a million lines.


>>> the "tr", "sed", "awk" and "grep" commands


If you are new to the Linux shell (mostly "bash", the bourne again shell), then you will get fo
new friends in no time. Those new friends are the "tr", "sed", "awk" and "grep" utilities.
You can use them interactively from the commandline, or use them in scripts.
I believe that nobody working with Linux or Unix, can live without them.

In this document, we keep everything simple, so I will illustrate the four utilities
with some simple, but good, examples.

1. The tr command:

The "tr" command is mostly used to translating characters, or a string, in a file (or interactiv
Just take a look at the following examples:

Example 1:
Suppose we have uploaded the file "test.txt", with Putty's pscp, from a PC to a Linux machine in
Now this file has the "^M" (cariage return \r ) at the "end" of each line, because it is a DOS/W
We want to get rid of that.

# cd /tmp
# tr -d '\r' < test.txt > test_new.txt

Here we tell "tr" to "translate to nothing" (=removing) with the "-d" option, the '\r' the retur
and as input it should take test.txt (via "< test.txt") and write the results to the output test

Note 1: why if you use (ftp in ascii mode) from PC to UNIX, or the other way around, you do not
FTP in ASCII mode translates these "\r" and "\n" for you, in the "right way". FTP in binary mode
such as pscp (putty scp), leave the file unaltered.

Note 2: about the "<" ">" syntax.
What you have seen here, is very typical for Unix/Linux commands that take an inputfile, and sho
Just tell the command to do so with "command < inputfile > outputfile".

Example 2:
Suppose you have a file (test.txt), where it contains at various locations, the characters "{" a
This example is actually quite similar to example 1.
Suppose you want the {} characters to be replaced by (). Just use:

# tr '{}' '()' < test.txt > test_new.txt

Sometimes, you need to "escape" a certain character with the "\" symbol. This is so, because tha
has a special meaning to the shell.
When we "escape" the character, for example \[, we tell the shell not to regard the "[" as it wo
but now take it litterally.


2. The sed command:

What's possible with the "sed" command, is enormous. Again, this is a very simplified document,
will only demonstrate some features of "sed" which you will probably use in scripts.

substitution:
One of the most common uses of the sed utility, and any similar editor, is to substitute (hence
To accomplish this, the syntax for the command portion of the operation is:
# sed s/oldvalue/new value/ file_name

Here the "/" is a delimiter. But you might also use another symbol like "!". You might use anohe
the "/" might be part of the string you want to substitue (e.g. with pathnames).

Suppose in "/tmp" we have the txt file "people.old", which contains:

# cat people.old
Alwin Hope
Sally Brown
Mark Winters
Sally Fox
Brad Brown

If we want to substitute all occurences of "Brown" to "White", we could do this:
# sed s/Brown/White/ people.old > people.new                   # this works too:   sed s/Brown/Wh

# cat people.new
Alwin Hope
Sally White
Mark Winters
Sally Fox
Brad White
Now suppose that we would like to change all occurences of "Sally Brown" to "Sally White"
# sed s/Sally Brown/Sally White people.old > people.new
This would fail, and quotes would help us here:
# sed 's/Sally Brown/Sally White/' people.old > people.new
That would work.

the ^ and $ symbols
Up to now, you are not thrilled by those examples. We are working on it, please read further.




7. Filemodes and permissions




8. Backup / Restore commands




9. Bootloaders and booting the system




10. Tracing the system (for troubleshooting)
ands, and some concepts described used in Linux.




                      blue:       is there
                      red:        still to do




oting purposes)
rce management.




able and used memory, like:

                                              # -m : Show in Megabyte

                       buffers       cached
                            12          134




ws "real-time" cpu-, disk, and memory usage, like:



ch can be used with serveral parameters, or play around with "ps -aux" command.
ch can give you numerous performance info. For a quick memory


swap and memory utilization
nterval where measurement is taken.


   system              cpu
  in    cs   us   sy     id
 120    24   10    2     89
 526 1653    96    4       0
 552 2219    94    5       1
 624   699   98    2       0
 603 1466    95    5       0
 768   932   90    4       6
 820 1230    85    9       6
 832 1060    87    6       7
 813 1655    93    5       2
1189 1165    68    9     23

i" and "so" will tell you. (See also Section 10)
in vmstat's output.




(no use of Logical Volume Manager, no Cluster)
tility), UNLESS YOU WORK WITH JUST A TEST SYSTEM.


ddisks. If you add a disk, you should ofcourse
r system can use it.



ditional way with "fdisk", and



 disk in your system.

umbers, such as "/dev/hda" or "/dev/sda".




er such as "/dev/hda1"


t to take into use. Do the following:
distros "parted" is a "fdisk" lookalike.


vice, use the w command to write the modified partition table to the device.
tion on the raw device, /dev/sdb.
Sun, SGI or OSF disklabel
ry only, until you decide to write them. After that, of course, the previous content won't be recoverable.

 corrected by w(rite)




o create a filesystem on that partition.

d other devices). Now what?




as root, indicated by the hash).



s a whole is mapped to /dev/sda, while /dev/sdax (x = 1 ... 15)




T (vfat), JFS, NTFS etc.. But the most common are ext2 and ext3.
hich are needed in clustered systems.




em on a new partition:

       #   Create   an ms-dos filesystem, FAT-size 32, on the partition /dev/sda1
       #   Create   a ext2 filesystem
       #   Create   a ext2 filesystem
       #   create   a clustered OCFS2 filesystem
       #   Create   a ext3 filesystem
       #   Create   a ext3 filesystem




a Logical Volume Manager (LVM) at our disposal.




l Volume Manager LVM

D IN THIS SECTION, UNLESS YOU WORK WITH JUST A TEST SYSTEM,


 the disk storage on a computer system than the traditional view of disks and partitions.
out single (formattable) diskpartitions (with "fdisk"),
se are the items you will deal with:

n an administrative entity "Volume Group" in which we can create Logical Volumes.
tem. The LV is created on a Volume Group. It can span multiple disks,
D level, such as RAID 1 (which is mirroring).
a single disk, but it could also refer to a "piece" / "set" of partitions on some storage.

ume Group", which will make things much clearer:

                # LVM2 implementation

t0/lun0/part1 \                   #LVM1 implementation   - devfs


                          # if you want a different extent size from the default (-s switch)



tering the command:



. In most implementations, the default is 4M and the max # of extends is
 storage in this VG

Well, on a VG you can create a LV which will later become a filesystem.
stems, or mirror a filesystem (to be safe for crashes).
vgcreate, lvcreate:
umber of real partitions (/dev/hda1) or disks (like /dev/hda)


ly initializing these partitions so that they can be recognized




 partitions which I want to initialize for inclusion




k of a volume group as a pool of storage that consists of one
we can add physical volumes to the volume group or even remove them.

.d files by running the following command:



 or more physical volumes to the volume group.




panning multiple disks, or maybe we want to implement mirroring).




_grp to the newly created my_logical_vol.




 a filesystem on it, mount it, and start using
 we do the following:



em we are creating.



e /etc/fstab file



                        # tries to create a striped logical volume with 3 stripes, a stripesize of 8KB and a si

                        # creates a snapshot logical volume named /dev/vg00/snap which has access to the conten



physical and logical volumes can be found in the /proc/lvm/ directory.
ormation regarding all VGs, LVs and PVs.
is a kernel, (loadable) device drivers,
 a shell (actually a number of shells).

Linux kernel is:     2.6.26.5


nt all supporting "stuff" (to get a usable system), you buy, or download,
ed a distribution.
kernelversion of 2.6.18.8.




you could find on many systems

like 2.6.18.8-0.10

boot/vmlinux or /boot/vmlinuz.
nk to the actual kernel, so you may need to track down

LILO and GRUB are well known bootloaders,




s to physical devices on the computer and to schedule when and how
y contains hierarchy of virtual folders and files which represent
oc allows the user to peer into the kernel's view of the system.
unicate configuration changes to the kernel.


 interrupts", and "system calls" from other programs.
 things done". Those are "system calls". Except for very lowlevel operations,
bc type of libaries, in such a way, that for example,
en uses a standard library which does the ugly job of formatting arguments



sources (tunable limits in RAM, diskIO, security, etc..) in a certain way.

 bit. First we take a look on how Redhat (and lookalikes) deal




rules on how to arrange and deal with certain Resources,
f threads the operating system will use as an NFS client,
rity related tunables.
n/sysctl" with which you can change the socalled


e parameters available are those listed under /proc/sys/.
n use sysctl(8) to both read and write sysctl data.
system "/proc", under the sys subdirectory,




       # -a means "show all current values"
       # -w means "change the value"
       # Load in sysctl settings from the file specified or /etc/sysctl.conf if none given. Specifying - as fil
ation, you might enter statements like the following examples:




 limits in Shared memory, and message queues.




 adding the following entries to the default




rom the default file /etc/sysctl.conf.
uld do that via a command like:




d have to have all possible anticipated functionality already compiled directly
side in memory without being used, wasting memory, and would require that users rebuild
s desired. Most operating systems supporting loadable kernel modules




es about a module/kernel version mismatch or a pile of unresolved symbols.

modules. But how do you know it's working? That's up to the LKM,
are some of the more common actions of an LKM upon being loaded.
hich is what the module would do at boot time if it were bound into
vice it knows how to drive. Just how it does this search varies
dule parameters. But in any case, if the driver doesn't find any device it is
, the driver registers itself as the driver for a particular major number a
pecial file that specifies that major number. It may also register itself as the handler f
send setup commands to the device, so you may see lights blink or something like that.

 the file /proc/devices.
's interrupts in /proc/interrupts.



es, and can resolve all dependencies between LKM's.
an insmod of fat.o, since you have to have fat.o loaded before you can load msdos.o.




s which represent the current state of the kernel — allowing applications


n about the system hardware and any processes currently running. In addition,
 manipulated by users and applications to communicate
 some examples of this effect.


 familiar with the two primary types of files: text and binary.
lled a virtual file. It is for this reason that /proc/ is often

re listed as zero bytes in size and yet when one is viewed,
, most of the time and date settings on virtual files reflect the

unts, and /proc/partitions provide an up-to-the-moment glimpse
and the /proc/sys/ directory provide system

 on a similar topic are grouped into virtual directories and sub-directories.
sical IDE devices. Likewise, process directories contain information about


irectory are read only. However, some can be used to
r files in the /proc/sys/ subdirectory.
But there are even simpler way to change (some) values.
nd and a > symbol to redirect
ostname on the fly, you can type:



ce, if you type cat /proc/sys/net/ipv4/ip_forward,
is not forwarding network packets. By using the echo command
immediately turn packet forwarding on.




bout network configuration files and commands,
terface that you can use in displaying and setting the network config.
es "/etc/hosts" file, or "/etc/resolv.conf",

 known distributions.




stname/IP address resolving.
(DNS), this file usually list certain
 determines the IP addresses for the DNS Servers:




you put them in the file)




twork Configuration" tool. This is a graphical tool you can run from X.

don’t run X, a textbased version will startup.

twork-scripts/ifcfg-ethX":

etc/sysconfig/network-scripts/"
er, "ifcfg-eth1" for your second adapter, etc..
h0-mac_address, where "mac_address"




network interfaces.
ation about the desired network configuration.




                                        RedHat Network Administration tool:
ed if X is running,
the text-based version to run,




hus also your networkdevices, with "Yast", a graphical tool.

e similar to RedHat (section 5.1).




  files for your network interfaces.
ry network interface where "EthN" can be the name of the inteface
sed (usb, pcmcia).
h0-mac_address, where "mac_address"




, dhcp (IP oubtained through DHCP)

 (for example 192.168.1.255)

net (for example 192.168.1.0)
 size of every IP packet). Default on ethernet devices is 1500.
he interface: onboot (at system's boot), hotplug, manual (manually).
e interface type.


g/network/config. You can also set every general variable as an individual variable
N files allow for more granular control.
ing, lease time, timouts, modification of system's settings,



ess devices (essid, frequency, sensibility, encryption key etc..). You can also put them




 specify routes exclusively related to the activation of single interfaces with the files /etc/sysconfig/networ




efer to this file..




vigate through te filesystems (with "cd" and "ls" commands).
chical filesystems of Linux,
mmand"), and how to move around ("cd"), and elementary commands like how


p to a graphical environment.
 a "$ prompt" for ordinary users,
t is, the root user.




that "somewhere" in all those subdirs, a file with the name
cated. Searching manually through all the subdirs, is really no option.
s to "find", that it should search from the current

ample, I have put dsm.opt within quotes, which was not necessary for this
e the quotes all the time.
, which is also possible.




in all subdirs within /usr

n do much more with "find"




sions" and stuff like that when one pass that stuff to a command.
ments" (which is not correct).

r certain filetypes (like logfiles *.log), and
 with those files (who have met the criteria).
e older than, for example, 30 days.
rwx stuff) of all those files in one swoop.




f all files (-type f) with a filename like "*.log" (-name "*.log")
 as from the current position.

ts the list of files which "find" has found.



tarting from the current directory.

ion with "-exec rm {}",
DS ON A HARMLESS TESTSYSTEM.




t some of the following examples




 sub directories for a file named rc.conf.
le that is found with that name. In general -print wil




 sub directories. All files named rc.conf will be processed
 found file into the chmod command line.

 the other permissions set to read access
 sub directories.
inted to standard output.




ll locate and list all files
 size exceeds 500,000 bytes.

90 -exec rm {} \;




wn for the string ABC:




er. see /etc/passwd) on the system: (could take a very long time)

tes: (Great for finding effects of make install)
: (execute as root)




older than a certain date, you can use




y's change time (ctime), access time (atime),


reation time of a file. The ctime--change time--
r directory's inode (owner, permissions, etc.).
 file change. It is needed by the dump command
You can view the ctime with the ls -lc command.

a of a file was last accessed. Displaying the contents
e a file's atime, for example.

ual contents of a file was last modified.
 listing (ls -l).

incremental backups:
included in a backup, it does not
he file's access time.

iles (or other files) older than a certain



"pg", "more", "tail", "head"

a txt (ascii) file, among which are:

e content. If you want to edit the file (and thus also viewing it),
 Unix/Linux system).

ecutables, libraries, plain text ascii files etc..
tent of a plain ascii file".
ht use the "file" command,




t can also be used to view the content.
b" is located in "/etc":
u will only see the "last part", so in case
 able to browse through the entire file.




reen at the time". Press enter to go to the next screendump of the file.




an use "more" as in the following example:




ge txt file, you can use the "tail -n <file_name>" command.

d in the last (most recent) lines in the logfile,

ets go to that directory
ow the last 50 lines of SystemOut.log

ow the last 100 lines of SystemOut.log



very many lines, like WARNING messages, and all
ow, suppose you are only interrested
ins over a million lines, is no fun at all.



             # or use grep -e to let grep not distinguish between small and large capital.


cause of the pipe "|" to grep.
p" to search for as string,

e of the ">" symbol), to

ier to do than SystemOut.log,




rne again shell), then you will get four
sed", "awk" and "grep" utilities.
se them in scripts.


lustrate the four utilities




, or a string, in a file (or interactively).
s pscp, from a PC to a Linux machine in /tmp.
nd" of each line, because it is a DOS/Windows file.




ith the "-d" option, the '\r' the return character,
nd write the results to the output test_new.txt (via "> test_new.txt")

X, or the other way around, you do not need to do other actions, like in this example?
 in the "right way". FTP in binary mode, or other forms of file transfer,



ommands that take an inputfile, and should write to an outputfile.



various locations, the characters "{" and "}".




the "\" symbol. This is so, because that character

he shell not to regard the "[" as it would do normally,




n, this is a very simplified document, and here we
ll probably use in scripts.


imilar editor, is to substitute (hence the option s) one value for another.
 the operation is:


er symbol like "!". You might use anoher symbol, because
 (e.g. with pathnames).




ite", we could do this:
      # this works too:   sed s/Brown/White < people.old > people.new
f "Sally Brown" to "Sally White"


w



    working on it, please read further.
us content won't be recoverable.
stripes, a stripesize of 8KB and a size of 100MB in the volume group named vg00. The logical volume name will be

0/snap which has access to the contents of the original logical volume named /dev/vg00/lvol1 at snapshot logical
nf if none given. Specifying - as filename means reading data from standard input.
with the files /etc/sysconfig/network/ifroute-interface.
vg00. The logical volume name will be chosen by lvcreate. #

d /dev/vg00/lvol1 at snapshot logical volume creation time. If the original logical volume contains a file syste
logical volume contains a file system, you can mount the snapshot logical volume on an arbitrary directory in o
volume on an arbitrary directory in order to access the contents of the filesystem to run a backup while the ori
esystem to run a backup while the original filesystem is updated

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:1/4/2013
language:English
pages:335