Vous êtes sur la page 1sur 16

Uname shows the version of the linux

The /etc/init.d directory contains the scripts that are used to start, stop, or otherwise control the
operation of system services. When the system changes run level, init, under the control of
the /etc/init/rc.conf file, calls the /etc/rc script to start the services that are required for the
new run level and to stop any currently running services that are not required.

System information

most hardware information has been moved to /sys.

/proc is very special in that it is also a virtual filesystem. It's


sometimes referred to as a process information pseudo-file
system. It doesn't contain 'real' files but runtime system
information (e.g. system memory, devices mounted, hardware

configuration, etc). For example, 'lsmod' is the same as


'cat /proc/modules' while 'lspci' is a synonym for 'cat
/proc/pci'. By altering files located in this directory you can
even read/change kernel parameters (sysctl) while the system
is running.

Change this one to make it permanent


/etc/sysctl.conf
Services

/etc/init.d/sshd start =====


service sshd start
chkconfig list
shows which services are running in each mode

chkconfig --del mythbackend

The /etc/sysconfig/ directory is where a variety of system configuration files for


Red Hat Enterprise Linux are stored.

The files in the /proc directory hierarchy contain information about your system hardware
and the processes that are running on the system

Text Editor:

Nano( it is very nice for editing files)


Vim
Cat
less( viewing files) use q to quit, use / to search
head n 20 test.py
tail n 20 test.py
grep a for /tst.py | less
Log gfiles are in the folder /vera/log. We have syslog, application log,
Sed:
o sed '1,3 s/unix/linux/' file.txt
o sed '2,$ s/unix/linux/' file.txt
o sed '/linux/ s/unix/centos/' file.txt

o
awk

>grep 'unix' file.txt


>sed -n '/unix/ p' file.txt
>sed 's/unix/linux/g' file.txt

o awk '/gold/ {print $5,$6,$7,$8}' coins.txt


o awk '{if ($3 < 1980) print $3, " ",$5,$6,$7,$8}'
coins.txt

RCS(for keep the revision of files)


o ci f.c
o co f.c
o co -l f.c
o vim f.c
o rcsdiff f.c

Process Monitoring:
1. 1-Top
o Press O(to sort the processes based on any column)
o R to reverse the order
o Press k ( to kill the process you want)
o Press r to Renice the process
o Press u to specify ehsan
o Color => z and b
o Press c => name to real path Firefox -> /lib/app/firefox
o Press n to specify the number of process to show
2. We show who is logged on and what they are doing.

Process Management:
3.
4.
5.
6.
7.
8.

Qps (GUI) awesome command for process manipulation


ps (ps auxw)
pstree 4-pgrep
strace p
7-ipcs (interprocesses such as shard mem, mapped mem, semaphore, queue)
Lsof I n P | grep firefox(shows all file descriptions)

service --status-all

Filesystems and Storage Devices:


df

shows the drives and their sizes

sar
Fdisk l
Fdisk l /dev/sda
mount 10.1.1.50:/home/nfs /home/nfs_local

The command rdist helps the system administrator install software or update
files across many machines. The process is launched from one computer.

TASK SCHEDULING

Ro run shell script to have run hourly, daily, weekly or monthly into the
appropriate directory:
/etc/cron.hourly/
/etc/cron.daily/
/etc/cron.weekly/
/etc/cron.monthly/
The crond daemon executes scheduled tasks on behalf of cron and it starts anacron once
every hour. crond looks in /etc/crontab or in files in /etc/cron.dfor system cron job
definitions
System cron jobs are defined in crontab-format files in /etc/crontab or in files
in /etc/cron.d.

at command is used to schedule one time


tar -cvf /dev/st0 /home /opt
tar -xvf /dev/st0 /home /opt

Network
/etc/hosts

/etc/nsswitch.conf /etc/resolv.conf

/etc/sysconfig/network

Bonding interfaces
http://docs.oracle.com/cd/E37670_01/E41138/html/ch11s05.html

ROUTING
Any changes that you make to the routing table using ip route do not persist across system reboots.
To permanently configure static routes, you can configure them by creating a route-interface file
in/etc/sysconfig/network-scripts for the interface. For example, you would configure a static
route for theeth0 interface in a file named route-eth0. An entry in these files can take the same
format as the arguments to the ip route add command. For example, to define a default gateway
entry for eth0, create an entry such as the following in route-eth0:
default via 10.0.2.1 dev eth0
The following entry in route-eth1 would define a route to 10.0.3.0/24 via 10.0.3.1 over eth1:
10.0.3.0/24 via 10.0.3.1 dev eth1

# ip route add 10.0.4.0/24 via 10.0.2.1 dev eth1


# ip route show
ip route get 23.6.118.140

DHCP
client:
/etc/sysconfig/network-scripts/ifcfg-iface BOOYPROTO=dhcp or none

DHCP server:/etc/dhcppd

DNS:
Install

BIND as server, use the file /etc/named.conf to configure,

#host is used to do name query like nslookup

Nscd(cache DNS Server): Linux can run nscd or BIND or dnsmasq as the name service
caching daemon. Large and work-group servers may use BIND or dnsmasq as a dedicated caching
server to speed up queries.
netinet is the folder to store the tcp and udp code

tcpdump nnvvSX tcp[13]&32!=0

netstat t

Does not show lots of things

netstat s

shows all statistics of tcpstat struct members

Operating System tuning:

Installation Option:
Startx

vim /etc/inittabb

Changing kernel parameters

System Activity Reporter

sar

Processor Tuning

Network Tuning
ttcp (testing tcp)

ethtool eth0(see speed)

TCP tuning :
Time Wait
FIN_WAIT_2
WEBSERVER

SYN COOCKIES

, =

To see the number of packets of all protocols use

nstat

Memory:
1.
2.
3.
4.
5.

VMSTAT s
free l
/proc/buddyinfo
pmap -d 1115 the memory map of the process
nmon

TCP Small Queue

Queues

Buffer Queue
Limit

tcp_wmem

ethtool -g eth0 (shows the interface queue size)


driver queue( its the ring buffer)
1. Driver Queue Ring size (NIC Queue):
ethtool -G eth0 tx 4
2.Byte Queue Limits: old driver queue does not care about size of the segment bit only on the

number of packets.
o Byte Queue Limits (BQL) is a new feature in recent Linux kernels (>
3.3.0) which attempts to solve the problem of driver queue sizing
automatically. This is accomplished by adding a layer which enables and
disables queuing to the driver queue based on calculating the minimum

buffer size required to avoid starvation under the current system


conditions. Recall from earlier that the smaller the amount of queued
data, the lower the maximum latency experienced by queued packets
o

byte queue limits put a cap on the amount of data


that can be waiting to go out a specific network
interface)
(

/sys/devices/pci0000:00/0000:00:14.0/net/eth0/queues/tx0/byte_queue_limits
(still BQL does not differentiate the flows and is FIFO) so we
have
3. Queue Disc
txqueuelen parameter controls the size of the queues in the Queueing Discipline box for the
QDiscs

ifconfig eth0 usually 1000


tc s d qdisc show dev eth0

tc qdisc add dev eth0 root netem delay 100ms

4. TCP Small Queues:is built to control the BQL and Ring based on the
tcp session
o TCP Small Queues adds a per TCP flow limit on the
number of bytes which can be queued in the QDisc
o allowing no more than ~128KB [1] per tcp socket in qdisc/dev
layers at a > given time

/proc/sys/net/ipv4/tcp_limit_output_bytes131072

KERNEL
Lsmod
modinfo ahci
# modprobe -rv nfs

list the modules====


cat /proc/modules
detailed information about a module
Unload module

modprobe sch_netem

tc qdisc add dev eth0 root netem delay 100ms

Parameters that Control System Performance


fs.file-max
Specifies the maximum number of open files for all processes. Increase the value of this parameter if
you see messages about running out of file handles.
net.core.netdev_max_backlog
Specifies the size of the receiver backlog queue, which is used if an interface receives packets faster
than the kernel can process them. If this queue is too small, packets are lost at the receiver, rather
than on the network.

net.core.rmem_max
Specifies the maximum read socket buffer size. To minimize network packet loss, this buffer must be
large enough to handle incoming network packets.
net.core.wmem_max
Specifies the maximum write socket buffer size. To minimize network packet loss, this buffer must be
large enough to handle outgoing network packets.
net.ipv4.tcp_available_congestion_control
Displays the TCP congestion avoidance algorithms that are available for use. Use
the modprobe command if you need to load additional modules such as tcp_htcp to implement
the htcp algorithm.
net.ipv4.tcp_congestion_control
Specifies which TCP congestion avoidance algorithm is used.
net.ipv4.tcp_max_syn_backlog
Specifies the number of outstanding SYN requests that are allowed. Increase the value of this
parameter if you seesynflood warnings in your logs, and investigation shows that they are
occurring because the server is overloaded by legitimate connection attempts.
net.ipv4.tcp_rmem
Specifies minimum, default, and maximum receive buffer sizes that are used for a TCP socket. The
maximum value cannot be larger than net.core.rmem_max.
net.ipv4.tcp_wmem
Specifies minimum, default, and maximum send buffer sizes that are used for a TCP socket. The
maximum value cannot be larger than net.core.wmem_max.
vm.swappiness
Specifies how likely the kernel is to write loaded pages to swap rather than drop pages from the
system page cache. When set to 0, swapping only occurs to avoid an out of memory condition.
When set to 100, the kernel swaps aggressively. For a desktop system, setting a lower value can
improve system responsiveness by decreasing latency. The default value is 60.
Caution

This parameter is intended for use with laptops to reduce power consumption by the hard disk. Do
not adjust this value on server systems.

5.2.4 Parameters that Control Kernel Panics


The following parameters control the circumstances under which a kernel panic can occur:
kernel.hung_task_panic
If set to 1, the kernel panics if any user or kernel thread sleeps in the TASK_UNINTERRUPTIBLE state
(D state) for more than kernel.hung_task_timeout_secs seconds. A process remains in D state
while waiting for I/O to complete. You cannot kill or interrupt a process in this state.
The default value is 0, which disables the panic.
Tip
To diagnose a hung thread, you can examine /proc/PID/stack, which displays the kernel stack for
both kernel and user threads.
kernel.hung_task_timeout_secs
Specifies how long a user or kernel thread can remain in D state before a message is generated or
the kernel panics (if the value of kernel.hung_task_panic is 1). The default value is 120 seconds.
kernel.panic
Specifies the number of seconds after a panic before a system will automatically reset itself.
If the value is 0, the system hangs, which allows you to collect detailed information about the panic
for troubleshooting. This is the default value.
To enable automatic reset, set a non-zero value. If you require a memory image ( vmcore), allow
enough time for Kdump to create this image. The suggested value is 30 seconds, although large
systems will require a longer time.
kernel.panic_on_oops
If set to 0, the system tries to continue operations if the kernel encounters an oops or BUG condition.
When set to 1 (default), the system delays a few seconds to give the kernel log daemon, klogd, time
to record the oops output before the panic occurs.

In an OCFS2 cluster. set the value to 1 to specify that a system must panic if a kernel oops occurs. If
a kernel thread required for cluster operation crashes, the system must reset itself. Otherwise,
another node might not be able to tell whether a node is slow to respond or unable to respond,
causing cluster operations to hang.
vm.panic_on_oom
If set to 0 (default), the kernels OOM-killer scans through the entire task list and attempts to kill a
memory-hogging process to avoid a panic. When set to 1, the kernel panics but can survive under
certain conditions. If a process limits allocations to certain nodes by using memory policies or
cpusets, and those nodes reach memory exhaustion status, the OOM-killer can kill one process. No
panic occurs in this case because other nodes memory might be free and the system as a whole
might not yet be out of memory. When set to 2, the kernel always panics when an OOM condition
occurs. Settings of 1 and 2 are for intended for use with clusters, depending on your preferred
failover policy.

Vous aimerez peut-être aussi