| Back to logs list
22128020 2009 年 04 月 23 日 11:51 Reading (loading. ..) Comments (0) Category: Computer Related
linux tips techniques notes
+ + according to the process name to display the progress No.
# pidof httpd
1846 1845 1844 1843 1842 1841 1840 1839 1820
+ + e2fsck
check the use of Linux ext2 file system The partition is working, check / dev/hda5 is normal, if there is an exception will be automatically repair and set if Q were to answer [is]:
e2fsck-a-y / dev/hda5
+ + reverse output
rev reverse output (units of behavior)
tac reverse output (text)
+ + display terminal No.
tty
+ + file line number / word count
wc l file file line calculation of the number of
wc-w file computing the number of words in the file
wc-c file file in the calculation of the number of characters per line
+ + the first 5 to 9 characters
cut-b5-9 file.txt
+ + delete the text file appears in the ranks of the
uniq
+ + Back to search path
dirname / bin / tux # will return / bin
+ + fcitx under normal use in the English
# vi ~ /. bashrc
xport LC_CTYPE = XMODIFIERS = split merge files
split-b1440k a_whopping_big_file chunk # split
cat chunk *> a_whopping_big_file # co
split -2 abc 14_-d
# abc cutting the text file, each cut into 2 rows a sub-file, the generated file name to 14_ beginning, followed by two digits
+ + using the two existing files,
la gears sneakers, create a new file
# remove the two files and set (duplicate rows only keep a copy)
cat file1 file2 | sort | uniq
# Remove the intersection of two files (leaving only two files exist in the file)
cat file1 file2 | sort | uniq-d
# delete the intersection, leaving the other line
cat file1 file2 | sort | uniq-u
+ + build process kill -9 httpd command
ps aux | grep httpd | awk '{print Flow: of = / dev / dst bs = 131072
+ + FTP using wget to download the entire directory
wget-mcnH
ftp://hostname/dirname ftp-user = user ftp-password = password no-passive- ftp-o / tmp / down / down.log
+ + statistical mean value of a column
Example: grep Total: squid.log | awk '{print $ 2}' | awk '{sum + = $ 0} END {print sum / NR} '
+ + How to release. tar.gz is specified in the file / folder?
tar zxvf *. tar.gz [$ path / filename] [$ path / dirname]
if not path then will be directly released into the current directory, add path will retain the original directory structure
+ + to specify the sender to send mail
cat local-host-names sendmail-v-Cetcmailsendmail. cf-f
Sender@domain.com-oi To
i@zhangjianfeng.com
+ + apache log out alone 18:00 ~ 23:00 2007.1.24 log
sed-n '/ [24 / Jan / 2007 : 18 /,
la gear originals, / [24 / Jan / 2007 : 23 / p 'access_log> tmp.log
+ + / proc / sys / fs / optimization
1 ) / proc / sys / fs / file-max
can be allocated to the file specifies the maximum number of file handles. If you get an error message statement because the number of open files has reached the maximum, so that they can not open more multiple files, you may need to increase this value.
4096 (default) / 65536 (recommended)
echo 65536> / proc / sys / fs / file-max
2) / proc / sys / fs / file-nr # This file associated with file-max, it only shows, in order: the number of allocated file handles, used the number of file handles, file handles the maximum number of
+ + View can be loaded encoding
locale-a
+ more CPU (including dual-core) way to view the status of the CPU environment
by figures in the top 1
+ + in Linux how to view each file system block size
tune2fs-l / dev/sdb1 | grep Block
+ + How to open a port with iptables?
-A RH-Firewall-1-INPUT-m state - state NEW-m tcp-p tcp - dport 60001:60006-j ACCEPT
+ + to change the file was last saved time
touch-t 200504301100 filename # specific parameters,
la gear womens shoes, see - help
+ + How to View the history of the command execution time
HISTTIMEFORMAT = including the status of each disk
+ + Remove the last 10 commands, and remove the number
fc-n-l -10 # -10 can be replaced by a range of 110 temporary like
+ + Close a alias
program name such as rm
+ + remove all the words in the article, and ranking # Most recently the word back with
for i in $ ( + + files added protection against deletion
chattr + i filename # remove prohibited
chattr-i filename # lift the ban on
+ + tcpdump instance
tcpdump [src | dst] host [!] 192.168.25.1192.168.25.1
tcpdump host 192.168.25.1 and (192.168.25.2 or 192.168.25.3 ) # intercept and host 192.168.25.2 host 192.168.25.1 or 192.168.25.3 communication
tcpdump-i eth0 host 192.168.10.1 and [src | dst] port 80 # on the purpose of monitoring 192.168.10.1 / source port is 80 packets
tcpdump-l | tee file.log # in the packet capture file can be viewed at the same time by grasping the package
tcpdump - [w | r] tcpdump.out # to listen to the information input / output to a file
tcpdump udp port 53 # monitor 53 udp port monitor communications
tcpdump arp # arp Radio
parameter-nn port and host name without the conversion
+ + nmap instance
nmap-v
www.zhangjianfeng.com # scan
www.zhangjianfeng.com all open TCP port. -V details of the model.
nmap-sS-O
www.zhangjianfeng.com/24 # secret SYN scan, scan host
www.zhangjianfeng.com where the And try each of the host operating system type
nmap-sV-p 22 [url = # scan the target host [and where the network segment] is open 22 ports
+ + connections Statistics
netstat-an | grep 80 | grep EST | wc-l
netstat-an | grep TIME_WAIT | wc-l
+ + on the procedures for nice adjustment
nice n -5 xyz # nice value of -5 to start program xyz
renice 10 2500 # 2500 will be a process pid nice value to 10
+ + disk block size View
dumpe2fs-h / dev/sda1 | grep-F command parameters that
# top
f increase / decrease display column
A different system resources by category displayed
# iostat
Tps: the number of devices to transmit per second (per second The I / O requests)
Blk_read / s, Blk_wrtn / s: The device number of blocks per second read and write. Block may be a different capacity. Block size is generally 1024,2048,4048 byte
Blk_read, Blk_wrtn: since the system since the start of the block device read and write total
# vmstat
r: the number of processes waiting for run time b: in not interrupt the process of sleep
swpd: the number of virtual memory free: the amount of free memory buff: the amount of memory used as buffers
si: switching from the hard disk to the number of so: the number of exchange to the hard drive to
bi: a block device to block out the number of bo: block device received from a number of blocks
in: the number of interrupts per second, including the clock cs: context switches per second in the number of
The process -related fields are:
r - The number of runnable processes waiting for access to the CPU
b - The number of processes in an uninterruptible sleep state
w - The number of processes swapped out, but runnable
The memory-related fields are:
swpd - The amount of virtual memory used
free - The amount of free memory
buff - The amount of memory used for buffers
cache - The amount of memory used as page cache
The swap-related fields are:
si - The amount of memory swapped in from disk
so - The amount of memory swapped out to disk
The I / O-related fields are:
bi - Blocks sent to a block device
bo-Blocks received from a block device
The system-related fields are:
in - The number of interrupts per second
cs - The number of context switches per second
The CPU-related fields are:
us - The percentage of the time the CPU ran user-level code
sy - The percentage of the time the CPU ran system- level code
id - The percentage of the time the CPU was idle
+ + iostat check IO
iostat-d-k-x
iostat-x 1
sar-n DEV
+ + kernel module related operations
rmmod ip_conntrack / / remove the old module from the kernel
modprobe ip_conntrack / / add new modules to the kernel
lsmod | grep ip_conntrack / / verify that the new module has been inserted
depmod-a # module dependencies could be detected for the modprobe to install the module in use.
+ + find a column of average
grep END {print sum / NR} '
+ + awk taking the first row of a column, remove the other lines
awk'! a [$ 1 ]++'
+ + to modify the time zone
cp / usr / share / zoneinfo / Asia / Shanghai / etc / localtime
# view the current time zone cat / etc / sysconfig / clock
+ + using the backspace delete a character before the cursor can not be removed, there has been ^ H ^ h
stty erase ^ h
+ + restrict the list of
su user in / etc / pam.d / su add a line, and will require users to join the specified group su admin
auth required / lib / security / pam_wheel.so group = admin
+ + See linux version
lsb_release-a
+ + snmpd port into non udp161
edit / etc / init.d / snmpd, Modify the following line (suse environment testing)
startproc $ SNMPD $ SNMPDCONF-r-A-LF $ {SNMPD_LOGLEVEL:-d} $ SNMPD_LOGFILE-p / var / run / snmpd.pid $ agentargs $ SNMPDNOSM
UX $ SNMPDNOTCPWRAPPERLOG: 1611
+ + floating-point operations
let and expr can not be floating-point operations, but the bc and awk can.
# find a divide by 13, to retain three significant figures.
$ echo } '
+ + non-integer (including decimal places) to compare the
echo Non-interactive mode command line to add a timed task
echo date> date3.txt | at now +2 minutes # support hours / days and other
# at-l # list view the content
# at-cx # View the contents of the task id for the x
# atrm x # remove id to x, and the timing tasks at different
# batch: batch in the system is idle when it is running. at the specified time is running
+ + implementation of collaborative
first person screen # screen-S foo
second person perform # screen-x foo
+ + check-bandwidth
machine 1 # / home / bob / perf / bin / iperf - s-f M
# this machine will be used as the server and in MBit / s as the unit output speed of execution.
machine 2 # / home / bob / perf / bin / iperf-c ginger-P 4-f M-w 256k-t 60
+ + track a process called
strace-p pid
+ + See history command for each command to display the date and time
export HISTTIMEFORMAT = '% F% T'
+ + to install the software patch
patch-p1 <.. / patch-xyz # patch
patch-R-p1 <.. / patch-xyz # uninstall a patch
zcat path / to / patch-xyzgz | patch-p1 # do not extract a direct hit Patch
bzcat path/to/patch-xyzbz2 | patch-p1 # patch is not unpack directly
# p0 and p1 difference
-p [n] the n value, as long as the abolition of how many / and the left path. to / usr / src / linux as an example,
la gear sale,
-p0 is not to cancel any path will
-p1 / cancellation, was usr / src / linux
-p2 is the / usr / cancellation may src / linux
+ + View apache compile parameters:
cat $ apachehome $ / build / config.nice
+ + view php build parameters:
$ PHP $ / bin / php-i | grep configure
+ + compiler parameters see mysql installed
cat $ PATH / mysql / bin / mysqlbug | grep CONFIGURE_LINE
+ + lftp mirror automatically download the remote directory
lftp - c 'open-e the lower directory name, you need to download all you can with net_persistent_names.rules
+ + encrypt files
zip-e dstname srcname