2010年8月21日星期六

CentOS ulimit system command changes

In CentOS ulimit to explain to you before, let us know the next CentOS ulimit, then a comprehensive introduction CentOS ulimit, hope to be useful. CentOS ulimit value (Linux file handle number) in CentOS5 (RHEL5) of the adjustment.

Following the deployment of applications in Linux, when sometimes encounter Socket / File: Can't open so many files in question, such as Squid do have agency, when the file open count of more than 900 per hour will drop very fast, there is could not open page.
In fact, Linux is a file handle limit, and Linux the default is not very high, typically 1024, the production server is actually very easy to achieve with this number.

View Methods
We can use CentOS ulimit-a to view all limit
[Root @ centos5 ~] # Centos ulimit-a
core file size (blocks,-c) 0
data seg size (kbytes,-d) unlimited
max nice (-e) 0
file size (blocks,-f) unlimited
pending signals (-i) 4096
max locked memory (kbytes,-l) 32
max memory size (kbytes,-m) unlimited
open files (-n) 1024
pipe size (512 bytes,-p) 8
POSIX message queues (bytes,-q) 819200
max rt priority (-r) 0
stack size (kbytes,-s) 10240
cpu time (seconds,-t) unlimited
max user processes (-u) 4096
virtual memory (kbytes,-v) unlimited
file locks (-x) unlimited | | < Which "open files (-n) 1024" is the Linux operating system, a process the number of open file handles limit (also includes the number of open SOCKET, MySQL can affect the number of concurrent connections). This value can be used CentOS ulimit command to modify the However, CentOS ulimit command changes the value only for the current logged-on user's current environment and effective, system restart or user exits will be invalid. Overall system limit is here, / proc / sys / fs / file-max. Can see the current value of cat, modify / etc / sysctl.conf can also be controlled. There is also a, / proc / sys / fs / file-nr, can see the whole system, the number of file handles currently in use Find file handle problem, there is a very useful program lsof. Can be easily opened to see who handles a process. You can also see a file / directory is what the process of taking up. Modification method To make permanent changes CentOS ulimits numerical effect, you must modify the configuration files, you can modify to CentOS ulimit command into / etc / profile which, this method is not convenient, there is a way to modify / etc / sysctl.conf . I modified, tested, but the CentOS ulimits-a user will not change. But / proc / sys / fs / file-max value has changed. (I give the command into the rc.local of failure) I think the right thing to do is modify the / etc / security / limits.conf There are very detailed notes, such as * Soft nofile 32768 * Hard nofile 65536 Can also be run directly below the shell. Copy directly to your terminal to run just fine. echo-ne " * Soft nofile 65536 * Hard nofile 65536 ">> / Etc / security / limits.conf

Restrictions on the file handle can be unified into soft-32768 hard 65536. Configuration file is the front of the domain, set to star on behalf of the overall situation, plus you can make a different for different users limit attention. That among the hard limit is the actual restrictions, and soft constraints, is warnning restrictions will only make the warning. In fact, CentOS ulimit command itself is divided soft and hard settings, add-H is hard, add-S is the soft limit by default shows the soft If running CentOS ulimit command does not modify the time with it, are two parameters change with it. effect
Re-login to see modifying. (My system is CentOS5.1. Revised and re-login after immediately. Can use CentOS ulimit-a view confirmed.)
If you are using squid, you should be in / etc / init.d / squid file join CentOS ulimit-HSn 65535. In addition, in squid.conf should join max_filedesc 16384

Eight Windows system command prompt special skills

I believe most people have already familiar with Le De Microsoft Windows user interface, but not all the features Bixujiezhu Ta can be achieved, so even in Windows 2000 and Windows XP li still Baoliu the Lei Si DOS command window, Dangrantamen and Yi Wang Windows 9x version under the command window there are many different, and therefore there are many special application skills, we might take a look together.

Click the "Start → Programs → Accessories → Command Prompt" or "Start → Run," and then enter "CMD" into the command can be prompt.

1 Using automatic memory function

Command window with the command and memory function, you enter in the window all the command line will be automatically memory down, by clicking up and down arrow keys on the keyboard can be the command just entered one by one taken out of tune, similar to the DOS in the DOSKEY instructions It just built this instruction in the command window. This memory can relieve you of the pain of repeatedly enter the same commands, for network debugging environment is particularly useful, can save you a lot of duplication of effort and valuable time.

2, fun prompt

You will be imagined to make your command prompt into the present time? Can display the current Windows XP version number? If you want to be able to achieve. Here we will teach you how to achieve.

Here we make use of a prompt in the DOS command, which a lot of useful parameters, the role of detailed parameters prompt the reader in the state of running prompt /? To Search. Understanding of the role of these parameters, you can create a path in the install file, name it as run.bat, the contents of the folder for the prompt $ V $ D $ G $ G. Next, open the Registry Editor, and then click Browse to HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Command Processor \, then double-click on the right of the AutoRun key, be revised to% systemroot% \ run.bat, save your settings exit. Re-open the command prompt, how is not made changes. In fact, according to prompt the parameters as long as you can define your own rich text prompt.

3, copy the contents of the window

Copy of the string in terms of useful window for the command. But Windows 2000 and Windows XP command prompt copy, quite different from previous versions, even if not the same between the two, the former is the use of marker replication method, while the latter directly by right-clicking the replication method. Specifically described as follows:

In Windows XP, the for all, you can click the right mouse button in the "Select" to select, and for the contents of the specified range, you can right click the first election in which the "marked" item, then move the mouse to The command character to be copied Department, drag the mouse to select this string, the string will appear immediately in the form of anti-white screen, click the right mouse button or press the Enter key, then move to the target location, right-click and select "Paste "Such a command string is automatically copied to the specified location.

In Windows 2000 下, as in the command window does not support the right of the menu (Dan supports drag the mouse of choice), so it gives up one kind of simplicity of the Fang Shi Yong Geng Wei-day command characters of Fu Zhi, first you must hold down the left mouse button, drag the selected command string to be copied, they will be anti-white form on the screen, first click the mouse to the right (ie implementation of the copy operation), move your mouse over the target location, and then click the left mouse key, the command character is automatically pasted into a new location on the!

4, change the window properties

If you long to work at the command prompt can also self-adjust its appearance to suit their habits, such as their window title, color and other personalized settings, frequent use of the relevant commands are:

a) change the title: CMD / k TITLE new title name

b) to change the command character: CMD / K PROMPT [text] (text for the new command prompt)

c) to change the foreground and background colors: CMD / t: gf (g is the background color specified in hexadecimal numbers, common color have the following values: 0 black, 1 blue, 2 green, 3 light green, 4 red , 5 purple, 6 yellow, 7 white, 8 Gray, 9, light blue, A light green, B blue, C light red, D light purple, E pale yellow, F white light.

5, the command window shortcut keys

In the command window has many useful shortcut keys, can greatly accelerate the speed of your input and debugging, but some of the features also provide a graphical way.

ESC: Clear the current command line;

F7: Display the command history in the form of a graphic window shows a list of all who enter the command, and can be up and down arrow keys to select again the implementation of the order.

F8: search command history, cycle show all who enter the command, press the Enter key until the date;

F9: select the command by numbers, graphical dialog box asking for your input command corresponding to the number (starting from 0), and the order displayed on the screen;

Ctrl + H: Remove the cursor left one character;

Ctrl + C Ctrl + Break, forced suspension of command;

Ctrl + M: said press Enter key;

Alt + F7: Clear all who enter the command history;

Alt + PrintScreen: interception of the screen window of the contents of the current command.

6, good "color" of the command line

By default command line is always black and white, from where the first surgery. In the Run dialog box, type cmd, open a command prompt, in the open right click on the title of the window, the pop-up menu, select "Properties" and open the window switch to the "Color" tab, and then click to select screen text, screen background options, and set the appropriate color, note that when we changed settings Shi Shi Zhi Hou will be displayed at the bottom, under which we can enjoy in a timely manner according to their own adjustments to make after the application save the settings will be asked properties, choose "Save property for later use with the same title of the window," so they would not only effect the current window.

7, quickly select files and folders

At the command prompt, we can press the Tab key to select the current directory the following files and folders, and its order of selection the basis of certain assessment, 按下 Shift + Tab key combination can also be used against the direction of choice, is convenience. Note that at this time we have chosen document also includes hidden files included.

8, save the file list information

Sometimes we need to drive in the list of files in a directory of all information printed, then you can use the following method: type the command DIR> C: \ 1.TXT after the carriage return, so the current directory list of files will be saved to C disk 1.txt file.

mount command Xiangjie

Function: load the specified file system.
Syntax: mount [-afFhnrvVw] [-L

Common command rpm

1. Install a package
# Rpm-ivh

2. Upgrade a package
# Rpm-Uvh

3. Remove a package
# Rpm-e

4. Installation Parameters
- Force even if the cover package of documents belonging to others forced to install
- Nodeps if the RPM package installation depends on other packages, even if no other packages installed, but also to force installation.

5. Check whether a package is installed
# Rpm-q

6. Get the information package to be installed
# Rpm-qi

7. Out of the package in which files
# Rpm-ql

8. Listed on a file server to which they belong RPM package
# Rpm-qf

9. Can be integrated with the use of several parameters
# Rpm-qil

10. Lists all installed rpm package
# Rpm-qa

11. Listed are not installed into the system an RPM package file which contains files?
# Rpm-qilp

<>
First, install the

Command format:

rpm-i (or - install) options file1.rpm ... fileN.rpm

Parameters:

file1.rpm ... fileN.rpm will be installed RPM package file name

More options:

-H (or - hash) hash mark (``#'') installed output
- Test only to test the installation, not the actual installation.
- Percent in the form of output as a percentage of the progress of installation.
- Excludedocs not install packages in the document file
- Includedocs installation documentation
- Replacepkgs forced to re-install already installed package
- Replacefiles replacement documents belonging to other packages
- Force Ignore package and file conflicts
- Noscripts not run pre-installation and post-installation script
- Prefix the package installed by the specified path
- Ignorearch do not check the structure of package
- Ignoreos run the operating system does not check package
- Nodeps do not check the dependency relations
- Ftpproxy used as a FTP proxy
- Ftpport FTP port number specified

General Options

-V Display additional information
-Vv display debugging information
- Root for the specified path as the RPM will be the "root directory", so that after pre-installation procedures and safety
Installation program will install to this directory
- Rcfile file set rpmrc
- Dbpath RPM information to set the path where inventory

Second, delete

Command format:

rpm-e (or - erase) options pkg1 ... pkgN

Parameter

pkg1 ... pkgN: To remove the package

More options

- Test only delete the test implementation
- Noscripts not run pre-installation and post-installation script
- Nodeps Do not check dependencies

General Options

-Vv display debugging information
- Root for the specified path as the RPM will be the "root directory", so pre-and post-installation setup
Program will be installed to this directory
- Rcfile file set rpmrc
- Dbpath RPM information to set the path where inventory

Third, upgrade

Command format

rpm-U (or - upgrade) options file1.rpm ... fileN.rpm

Parameter

file1.rpm ... fileN.rpm package name

More options

-H (or - hash) hash mark (``#'') installed output
- Oldpackage allow the "upgrade" to an old version of the
- Test only upgrade testing
- Excludedocs not install packages in the document file
- Includedocs installation documentation
- Replacepkgs forced to re-install already installed package
- Replacefiles replacement documents belonging to other packages
- Force Ignore package and file conflicts
- Percent in the form of output as a percentage of the progress of installation.
- Noscripts not run pre-installation and post-installation script
- Prefix the package installed by the specified path
- Ignorearch do not check the structure of package
- Ignoreos run the operating system does not check package
- Nodeps do not check the dependency relations
- Ftpproxy used as a FTP proxy
- Ftpport FTP port number specified

General Options

-V Display additional information
-Vv display debugging information
- Root for the specified path as the RPM will be the "root directory", so pre-and post-installation setup program will install to this directory
- Rcfile file set rpmrc
- Dbpath RPM information to set the path where inventory

4, the query

Command format:

rpm-q (or - query) options

Parameters:

pkg1 ... pkgN: check installed packages

More options

-P (or ``-'') check the file package
-F query belongs to which package
-A check of all installed packages
- Whatprovides query a feature of the package
-G queries the packages belonging to group
- Whatrequires check the package all the necessary functions

Information Options

Show all packages identification
-I display a summary of the information package
-L display list of files that the package
-C show a list of configuration files
-D displays the document file list
-S Display the package list of files and display the status of each file
- Scripts show install, uninstall, verify script
- Queryformat (or - qf) is displayed to the user specified query information
- Dump display each file all the parity information
- Provides display package provides the functionality
- Requires (or-R) shows the functionality required package

General Options

-V Display additional information
-Vv display debugging information
- Root for the specified path as the RPM will be the "root directory", so pre-and post-installation setup program will install to this directory
- Rcfile file set rpmrc
- Dbpath RPM information to set the path where inventory

5, check the installed package

Command format:

rpm-V (or - verify, or-y) options

Parameter

pkg1 ... pkgN going to check the package name

Package Options

-P Verify against package file
-F check their packages
-A Verify check all packages
-G checking all packages belonging to group

More options

- Noscripts script does not run check
- Nodeps do not check dependencies
- Nofiles not verify file attributes

General Options

-V Display additional information
-Vv display debugging information
- Root for the specified path as the RPM will be the "root directory", so pre-and post-installation setup program will install to this directory
- Rcfile file set rpmrc
- Dbpath RPM information to set the path where inventory

6, check the paper package

Syntax:

rpm-K (or - checksig) options file1.rpm ... fileN.rpm

Parameters:

file1.rpm ... fileN.rpm package file name

Checksig - more options

- Nopgp not verify PGP signature

General Options

-V Display additional information
-Vv display debugging information
- Rcfile file set rpmrc

7, other RPM options

- Rebuilddb rebuilding RPM database
- Initdb to create a new RPM database
- Quiet reduce output as much as possible
- Help Show help file
- Version display the current version of RPM

2010年8月14日星期六

CentOS operating system commonly used commands

A: Using CentOS common command to see cpu

more / proc / cpuinfo | grep "model name"

grep "model name" / proc / cpuinfo

[Root @ localhost /] # grep "CPU" / proc / cpuinfo

model name: Intel (R) Pentium (R) Dual CPU E2180@2.00GHz

model name: Intel (R) Pentium (R) Dual CPU E2180@2.00GHz

If you feel the need to see a more comfortable

grep "model name" / proc / cpuinfo | cut-f2-d:

2: Using CentOS common command to see memory

grep MemTotal / proc / meminfo grep MemTotal / proc / meminfo | cut-f2-d: free-m | grep "Mem" | awk '(print $ 2)'

3: Using CentOS common command to see cpu is 32-bit or 64-bit

View CPU digits (32 or 64)

getconf LONG_BIT

4: Using CentOS common command to see the current version of linux

more / etc / redhat-release

cat / etc / redhat-release

5: Use common command to see the kernel version of CentOS

uname-r

uname-a



6: Using CentOS common command to see the current time

The above date has been how to synchronize time

7: Using CentOS common command to see the hard disk and partition

df-h

fdisk-l

You can also view partition

du-sh

You can see all the space occupied by the

du / etc-sh

You can see the size of this directory

8: Using CentOS common command to see the installed packages

View the system when the installation package to install

cat-n / root / install.log

more / root / install.log | wc-l

See who is already installed package

rpm-qa

rpm-qa | wc-l

yum list installed | wc-l

But very strange, I passed the rpm, and yum install the package in two ways the query, the number not the same. Did not know the cause.

9: Using CentOS common command to see the keyboard layout

cat / etc / sysconfig / keyboard

cat / etc / sysconfig / keyboard | grep KEYTABLE | cut-f2-d =

10: Using CentOS common command to see selinux case

sestatus

sestatus | cut-f2-d:

cat / etc / sysconfig / selinux

11: Using CentOS common command to see the ip, mac address

In ifcfg-eth0 file, you can see mac, gateway and other information. ifconfig cat / etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR cat / etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut-f2-d = ifconfig eth0 | grep "inet addr:" | awk '(print $ 2)' | cut-c 6 - ifconfig | grep 'inet addr:' | grep-v '127 .0.0.1 '| cut-d:-f2 | awk' (print $ 1) 'View the gateway cat / etc / sysconfig / network view dns cat / etc / resolv.conf 12: Using CentOS common command to see the default language

echo $ LANG $ LANGUAGE

cat / etc/sysconfig/i18n

12: Using CentOS common command to see whether the use of their time zone and UTC time

cat / etc / sysconfig / clock



13: Using CentOS common command to see the host name

hostname

cat / etc / sysconfig / network

Modify the host name is to modify this file, while at best the host file also changes.

14: Using CentOS common command to see the boot running time

uptime

09:44:45 up 67 days, 23:32, ...

Segment seems to have really the problem, my machine is 67 days before the boot.

# System resource usage

vmstat 1-S m procs ----------- memory ---------- --- swap - ----- io ---- - system - - ---- cpu ------ rb swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 233 199 778 0 0 4 25 1 1 3 0 96 0 0 0 0 0 233 199 778 0 0 0,010,298,561,318,600

2010年8月11日星期三

Uptime Usage of the command - system operation and guidance

REVIEW: uptime command displays the system has been running for how long, information display were: the time now, the system has been running for how long, the current number of login users, the system in the last 1 minute, 5 minutes and within 15 minutes average load.

uptime command usage is very simple: you can directly enter the uptime.

There is also a parameter-V, is used to query version. (Note the capital letter v)

[Linux @ localhost] $ uptime-V

procps version 3.2.7

[Linux @ localhost] $ uptime

Display results:

10:19:04 up 257 days, 18:56, 12 users, load average: 2.10, 2.10,2.09

Display shows:

10:19:04 / / system current time

up 257 days, 18:56 / / host has run time, time became, indicating that the more stable your machine.

12 user / / user connection, the total number of connections, not users

load average / / the system load average, statistics recently 1,5,15-minute system load average

So what is the average system load it? Average system load is run at a specific time interval, the average number of processes in the queue. If each CPU core, the number of currently active process, not more than 3, then the system performance is good. If the number of tasks for each CPU core is greater than 5, then the performance of this machine have a serious problem. If your linux host is 1 if dual-core CPU, when the Load Average note 6, when the machine has been fully used.

In addition, the following code shows how this kind of start-up time method of computing systems:


#include
#include
struct sysinfo s_info;
long uptime;
int d,h,m,s;
int main()
{
if(0==sysinfo(&s_info))
{
uptime=s_info.uptime;
d=uptime/(3600*24);
h=(uptime/3600)%24;
m=(uptime%3600)/60;
s=(uptime%3600)%60;
printf("d=%d:h=%d:m=%d:s=%d",d,h,m,s);
return 0;
}
return -1;
}

Run Results:

[xxx@wireless time]$ gcc -o uptime uptime.c
[xxx@wireless time]$ ./uptime
d=19:h=0:m=4:s=52
[xxx@wireless time]$

WindowsXP system, how to retrieve forgotten passwords

1, restart the computer, immediately after the startup screen appears, press the F8 key, select "Safe Mode with Command line."

2, run the end of the process, the system lists the system super user "administrator" and the local user "zhangbq" option menu, mouse click "administrator", enter the command line mode.

3, type the command: "net user zhangbq 123456 / add", forced to "zhangbq" user's password changed to "123456." To this add a new user (such as: user name is abcdef, password is 123456), please type "net user abcdef 123456 / add", add the following can be "net localgroup administrators abcdef / add" command will upgrade the system user Management group "administrators" of the user, and it has super rights.

4, restart the computer, select the normal mode, you can use to change the password after the "123456" Login "zhangbq" Users of the.

Use "administrator"

We know that in the process of installing Windows XP, the first work "administrator" default login will then ask create a new account, Yibianjinru Windows XP, use this Xinjian account login, and login screen in Windows XP only Chuxian created in Ye This user account does not appear "administrator", but in fact the "administrator" account still exists, and the password is blank.

When we understand this then, if forget the password, then the login screen, hold down the Ctrl + Alt key, then press and hold the Del key twice, you can appear classic logon screen, then type the user name "administrator", password is blank entry, and then modify the "zhangbp" password can be.