17
Uname shows the version of the linux

Linux Points

  • Upload
    ehsan

  • View
    225

  • Download
    5

Embed Size (px)

Citation preview

Uname shows the version of the linux The/etc/init.ddirectory 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.conffile, calls the/etc/rcscript 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 modechkconfig --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/procdirectory 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: sed '1,3 s/unix/linux/' file.txt sed '2,$ s/unix/linux/' file.txt sed '/linux/ s/unix/centos/' file.txt >grep 'unix' file.txt >sed -n '/unix/ p' file.txt >sed 's/unix/linux/g' file.txt awk awk '/gold/ {print $5,$6,$7,$8}' coins.txt awk '{if ($3 < 1980) print $3, " ",$5,$6,$7,$8}' coins.txt RCS(for keep the revision of files) ci f.c co f.c co -l f.c vim f.c rcsdiff f.c

Process Monitoring:1. 1-Top Press O(to sort the processes based on any column) R to reverse the order Press k ( to kill the process you want) Press r to Renice the process Press u to specify ehsan Color => z and b Press c => name to real path Firefox -> /lib/app/firefox Press n to specify the number of process to show2. We show who is logged on and what they are doing.Process Management:3. Qps (GUI) awesome command for process manipulation4. ps (ps auxw)5. pstree 4-pgrep 6. strace p 7. 7-ipcs (interprocesses such as shard mem, mapped mem, semaphore, queue)8. Lsof I n P | grep firefox(shows all file descriptions)service --status-all

Filesystems and Storage Devices:

df shows the drives and their sizessar Fdisk lFdisk l /dev/sdamount 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/Thecronddaemon executes scheduled tasks on behalf ofcronand it startsanacrononce every hour.crondlooks in/etc/crontabor in files in/etc/cron.dfor systemcronjob definitionsSystemcronjobs are defined incrontab-format files in/etc/crontabor 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 /optNetwork/etc/hosts/etc/nsswitch.conf/etc/resolv.conf/etc/sysconfig/network

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

ROUTINGAny changes that you make to the routing table usingip routedo not persist across system reboots. To permanently configure static routes, you can configure them by creating aroute-interfacefile in/etc/sysconfig/network-scriptsfor the interface. For example, you would configure a static route for theeth0interface in a file namedroute-eth0. An entry in these files can take the same format as the arguments to theip route addcommand. For example, to define a default gateway entry foreth0, create an entry such as the following inroute-eth0:default via 10.0.2.1 dev eth0The following entry inroute-eth1would define a route to 10.0.3.0/24 via 10.0.3.1 overeth1: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 showip route get 23.6.118.140

DHCP client:/etc/sysconfig/network-scripts/ifcfg-iface BOOYPROTO=dhcp or noneDHCP server:/etc/dhcppdDNS:Install BIND as server, use the file /etc/named.conf to configure, #host is used to do name query like nslookupNscd(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 membersOperating System tuning:Installation Option:Startx vim /etc/inittabbChanging kernel parameters, =

System Activity Reporter sarProcessor Tuning

Network Tuningttcp (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 nstatMemory:1. VMSTAT s 2. free l 3. /proc/buddyinfo 4. pmap -d 1115 the memory map of the process 5. nmonTCP Small Queue

Queues tcp_wmemBuffer Queue Limit

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 42. Byte Queue Limits: old driver queue does not care about size of the segment bit only on the number of packets. 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 (byte queue limitsput 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/tx-0/byte_queue_limits(still BQL does not differentiate the flows and is FIFO) so we have3. Queue Disctxqueuelen parameter controls the size of the queues in the Queueing Discipline box for the QDiscsifconfig eth0 usually 1000tc s d qdisc show dev eth0tc 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 TCP Small Queues adds a per TCP flow limit on the number of bytes which can be queued in the QDisc 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

Lsmodlist the modules==== cat /proc/modulesmodinfo ahcidetailed information about a module# modprobe -rv nfsUnload module

modprobe sch_netemtc qdisc add dev eth0 root netem delay 100ms

Parameters that Control System Performancefs.file-maxSpecifies 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_backlogSpecifies 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_maxSpecifies 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_maxSpecifies 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_controlDisplays the TCP congestion avoidance algorithms that are available for use. Use themodprobecommand if you need to load additional modules such astcp_htcpto implement thehtcpalgorithm.net.ipv4.tcp_congestion_controlSpecifies which TCP congestion avoidance algorithm is used.net.ipv4.tcp_max_syn_backlogSpecifies the number of outstandingSYNrequests that are allowed. Increase the value of this parameter if you seesynfloodwarnings in your logs, and investigation shows that they are occurring because the server is overloaded by legitimate connection attempts.net.ipv4.tcp_rmemSpecifies minimum, default, and maximum receive buffer sizes that are used for a TCP socket. The maximum value cannot be larger thannet.core.rmem_max.net.ipv4.tcp_wmemSpecifies minimum, default, and maximum send buffer sizes that are used for a TCP socket. The maximum value cannot be larger thannet.core.wmem_max.vm.swappinessSpecifies 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.CautionThis 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.4Parameters that Control Kernel PanicsThe following parameters control the circumstances under which a kernel panic can occur:kernel.hung_task_panicIf set to 1, the kernel panics if any user or kernel thread sleeps in theTASK_UNINTERRUPTIBLEstate (D state) for more thankernel.hung_task_timeout_secsseconds. 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.TipTo 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_secsSpecifies how long a user or kernel thread can remain inD statebefore a message is generated or the kernel panics (if the value ofkernel.hung_task_panicis 1). The default value is 120 seconds.kernel.panicSpecifies 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_oopsIf 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_oomIf 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.