Very useful Linux commands: Ruby
Determine whether a user exists. create a user if the user does not exist
User = 'grep' ^ admin: '/etc/passwd'
If [-z "$ user"]; then
Groupadd admin
Useradd-d/home/admin-s/bin/bash-g admin
Echo '200' | passwd -- stdin admin
Echo '200' | passwd -- stdin root
Fi
Increasing file system space
Umount/home
E2fsck-f/dev/mapper/VolGroup-lv_home
Resize2fs-p/dev/mapper/VolGroup-lv_home 10G
Mount/home
Lvreduce-L 10G/dev/mapper/VolGroup-lv_home
Vgdisplay
Lvextend-L + 210.5G/dev/mapper/VolGroup-lv_root
Resize2fs-p/dev/mapper/VolGroup-lv_root
Common VI commands
: 50, 70 s/^/# Comment 50 to 70 rows
: 0, $ d delete all content
: % S/r // g press enter to delete DOS ^ M
: % S/^ (. *) n1/1 $/delete duplicate rows
: <
View the file size in the current directory, in ascending order
Du-sh * | sort-nr | head
Multi-IP, gateway configuration
/Sbin/ifconfig eth0: 1 192.168.13.122 netmask 255.255.255.0 up
/Sbin/route del default gw 192.168.12.1
/Sbin/route add default gw 192.168.12.1
Synchronization time
/Usr/sbin/ntpdate 192.168.12.1;/sbin/hwclock-w
Cancel your have mail in/var/spool/mail/root prompt
Echo "unset MAILCHECK">/etc/profile
Password-free logon
Ssh-keygen creates the public key and key.
Ssh-copy-id copies (append) the public key of the local host to the authorized_keys file of the remote host.
The ssh-copy-id will also be sent to the user home directory (home) and ~ of the remote host ~ /. Ssh, and ~ /. Ssh/authorized_keys set the appropriate permissions
Make sure that the configuration in/etc/ssh/sshd_config is AuthorizedKeysFile. ssh/authorized_keys.
Step 1: Use ssh-key-gen to create a public key and a key on the local host
Ligh @ local-host $ ssh-keygen-t rsa
Step 2: Use ssh-copy-id to copy the public key to the remote host.
Ligh @ local-host $ ssh-copy-id-I ~ /. Ssh/id_rsa.pub root@192.168.0.3
[Note: The ssh-copy-id appends the key to. ssh/authorized_key of the remote host.]
Step 3: log on to the remote host directly
Ligh @ local-host $ ssh root@192.168.0.3.
Test disk IO
Read performance test
# Time dd iflag = direct, nonblock if =/dev/sda2 of =/dev/null bs = 8 k count = 8388608
Because/dev/sda2 is a physical partition, reading it will generate IO,/dev/null is a pseudo device, which is equivalent to a black hole, of this device will not generate IO, so, the IO of this command only occurs on/dev/sdb1, which is equivalent to testing the disk's read capability.
Write test
# Time dd oflag = direct, nonblock if =/dev/zero f =/opt/iotest bs = 8 k count = 8388608
Because/dev/zero is a pseudo-device, it only generates a null compaction stream and does not generate IO for it. Therefore, IO will be concentrated in the of file, and the of file is only used for writing, therefore, this command is equivalent to testing the disk write capability.
Read/write test
# Time dd iflag = direct, nonblock oflag = direct, nonblock if =/dev/sda2 f =/opt/iotest bs = 8 k count = 8388608
Mysql installation
Create the mysql installation directory and database storage directory
[Root @ rhel5 ~] # Mkdir-p/usr/local/mysql // install mysql
[Root @ rhel5 ~] # Mkdir-p/usr/local/mysql/data // store the database
Create mysql users and user groups
[Root @ rhel5 ~] Groupadd mysql
[Root @ rhel5 ~] Useradd-r-g mysql
Install mysql
# Tar-zxv-f mysql-5.5.10.tar.gz
# Cd mysql-5.5.10
# Cmake.
-DCMAKE_INSTALL_PREFIX =/usr/local/mysql
-DMYSQL_DATADIR =/usr/local/mysql/data
-DDEFAULT_CHARSET = utf8
-DDEFAULT_COLLATION = utf8_general_ci
-DEXTRA_CHARSETS = all
-DENABLED_LOCAL_INFILE = 1
# Make
# Make install
Install and configure JDK
Tar zxvf jdk1.6.0_25.tar.gz-C/export/servers/
Vi/etc/profile
Add as follows:
Export JAVA_HOME =/export/servers/jdk1.6.0 _ 25
Export JAVA_BIN =/export/servers/jdk1.6.0 _ 25/bin
Export PATH =/$ PATH:/$ JAVA_HOME/bin
Export CLASSPATH =.:/$ JAVA_HOME/lib/dt. jar:/$ JAVA_HOME/lib/tools. jar
Export JAVA_OPTS = "-Djava. library. path =/usr/local/lib-server-Xms1024m-Xmx2048m-XX: MaxPermSize = 256 m-Djava. awt. headless = true -Dsun.net. client. defaultReadTimeout = 60000-Djmagick. systemclassloader = no-Dnetworkaddress. cache. ttl = 300 -Dsun.net. inetaddr. ttl = 300"
Export JAVA_HOME JAVA_BIN path classpath JAVA_OPTS
Killing all processes
Ps-ef | grep $1 | grep-v grep | awk '{print $2}' | xargs kill-9
Uninstall openjdk
View
Rpm-qa | grep java
Uninstall:
Rpm-e -- nodeps java-1.6.0-openjdk-devel-1.6.0.0-1.45.1.11.1.el6.x86_64
Rpm-e -- nodeps java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
Force unloading:
Rpm-qa | grep software name | while read line; do rpm-e -- allmatches -- nodeps $ line; done
Soft link:
Ln-s/export/servers/jdk1.6.0 _ 25/bin/jar/usr/bin/jar
Ln-s/export/servers/jdk1.6.0 _ 25/bin/javac/usr/bin/javac
Source/etc/profile
View:
Java-version