Linux Common Operations Command (ii)

Source: Internet
Author: User
Tags psql uncompress jboss dmesg

common commands for monitoring Linux
-----------------------
Ps-aux View All Processes
Ps-auxwww parameter w indicates widening of the displayed command line
Vmstat: Show Current Memory usage
Netstat: Display network status, use the parameter p to view the corresponding process number and program name
NETSTAT-ANP typically use parameter a (show all connection conditions) and n (do not reverse the domain name and service name)
Netstat-an | grep LISTEN View server listening status
Netstat-an | grep established view server-established connections
Ifconfig: View (or set) network device information
IFCONFIG-A: View all network setup Information
Last: Shows the log on to the server and the server restart condition
DF: Display hard disk space and usage, Linux can take parameter h, display results more humane.
Df-h hard disk space according to humanized display
Df-k hard disk space by kb
Df-m hard disk space on MB display
W: Displays a list of users logged on to the server

The following commands are for Linux only
Lsof: Displays a list of currently open files, including the established socket connection. This command can be used by programmers to check the number of open files written by the program
Sysctl: Display (or set) system kernel parameters
Sysctl-a Show All kernel parameters
SYSCTL-W parameter name = value of argument
Ulimit: Show (or set) resource limits that users can use

Introduction to output information

Procs r: Number of processes waiting to run
B: Number of processes in non-disruptive sleep state
W: The number of running processes that have been swapped out. This number is calculated by Linux, but Linux does not run out of swap space

Memory
SWPD: Virtual memory usage, unit: KB
Free: idle memory, in kilobytes
Buff: The amount of memory that is used as a cache, in kilobytes: KB

Swap
Si: Number of swap pages from disk swap to memory, in kb/seconds
So: number of swap pages from memory swap to disk, in kb/seconds

Io
BI: Number of blocks sent to block device, units: Blocks/sec
Bo: Number of blocks received from a block device, units: Blocks/sec

System
In: Number of interrupts per second, including clock interrupts
CS: The number of environment (context) switches per second

CPU is displayed as a percentage of total CPU usage
Us:cpu Use time
SY:CPU System Usage Time
ID: Idle Time
-----------------------

The sftp command uses
-----------------------
SFTP-L username hostname or SFTP [email protected]
After entering SFTP, it is no different than the normal mode of FTP operation.
Cd
LS dir
Mkdir
RmDir
Pwd
Chgrp
Chown
chmod
ln oldname newname
RM Path
Rename Oldname newname
Exit bye
-----------------------

Modify EVN:
-----------------------
VI. Bash_profile each user has
Vi/usr/jboss-3.2.0rc2/server/default/log/boot.log
source. bash_profile
-----------------------

Common Commands :
-----------------------
Rmdir-p Surf Delete Empty directory
mkdir New Directory
RM-RF deletes the entire directory, and does not ask
Tail-f/usr/jboss-3.2.2rc2/server/default/log/server.log always refresh view files
Ssh-l root 219.133.**.** into other servers
Psql-h 219.133.**.**-ult club_dump into the Postgre database of the other servers
Psql-upostgres club_dump into the server Postgre database
SELECT * from Pg_stat_activity; Query the number of connections to the database
/etc/init.d/postgresql Restart Restart database service
-----------------------

Our teacher used the order , We can study it ourselves .
-----------------------
Df-kh
DMESG | grep CPU
Df-kh
Free-m
Free-kh
Free-k
Meminfo
Mem
Dmesg
Env
Df-kh
Tail-f Nohup.out
Nohup./run.sh &
Ps-ef
chmod u+x *.sh
-----------------------

file or directory package ( from network data )
-----------------------
In the UNIX system business use (especially data management and backup), after some research, collation, make full use of the UNIX system itself, the command tar, cpio and compress to do packaging and compression, so that it acts as a DOS-like compression software, but also in the UNIX system is universal.
In Unix systems, many files are packaged into a single vault by Cpio or tar, and then compressed with compress to achieve the goal. The methods and procedures used are described in Cpio and tar, respectively.

First, Cpio

1. File or directory packaging.

There are a number of scenarios for packaging:

A) package with sub-directories:

Find/usr/lib-print|cpio-o〉/u0/temp1.cpio

Package the files in the/usr/lib directory with subdirectories into a single vault as/u0/temp1.cpio.

If all files and subdirectories under the entire directory are packaged through the-O option, use the Find directory name-print to find out the names of all the files and subdirectories, through the pipeline "|" Passed to Cpio packaging.

B) Packaging without subdirectories:

Ls/usr/lib|cpio-o〉/u0/temp1.cpio

Package files in the/usr/lib directory (files without subdirectories) into a single vault for/u0/temp1.cpio.

C) package specific files:

You can use the Text Search command grep with the pipeline to exclude or select specific types of files to pass to Cpio packaging. such as: Ls/usr/lib/*.c|cpio-o〉/u0/temp1.cpio

or Ls/usr/lib|grep′.c$′|cpio-o〉/u0/temp1.cpio

The meaning is to find out the files in the/usr/lib directory that end in. c are packaged.

Another example: Ls/usr/lib|grepabcd|cpio-o〉/u0/temp1.cpio, which means to find the file name in the/usr/lib directory containing the ABCD character files to be packaged.

Ls/usr/lib|grep-vabcd|cpio-o〉/u0/temp1.cpio, which means to locate files in the/usr/lib directory that do not contain ABCD characters in the file to be packaged. The-v option in the grep command means that the column containing the string is excluded.

This allows for the full use of Unix pipelines and the power of some commands to package files.

2. Compression:

Once the file is packaged, you can compress the package file with the Compress command in UNIX (/usr/bin). For general text files, the compression rate is higher, up to 81%.

Compress/u0/temp1.cpio compresses the vault/u0/temp1.cpio to/u0/temp1.cpio.z (added automatically. Z and delete/u0/temp1.cpio).

3. Unzip:

The uncompress/u0/temp1.cpio.z is automatically reverted to/u0/temp1.cpio.

4. Unpacking expansion:

The unpacking of the original directory structure will be expanded to the current directory. If a relative path is packaged, when the unpacking is expanded, it is also the file data that is stored in the relative path, and if it is packaged as an absolute path, the expanded file data is also stored as an absolute path when the unpacking is expanded. Therefore note that if the relative path, you should first enter the corresponding directory and then expand.

Cd/u1

Cpio-id〈/u0/tmp1.cpio then extracts the/u0/temp1.cpio to/U1 (this assumes that Temp1.cpio is compressed with a relative path).

If you add the U option, such as Cpio-iud〈/u0/temp1.cpio, the file will be overwritten if it exists, that is, forced overwrite.

Cpio-id〈/u0/temp1.cpio *.C expands the *.c file, similar to the pkunzip-d temp1.zip unpacking function in the PKZIP software in a DOS system.

5. Display:

Cpio-it〈/u0/temp1.cpio [*.C] Displays the file name in the vault, similar to the PKUNZIP-VBNM temp1.zip function in the PKZIP software in a DOS system.

Ii. Tar


1. File or directory Packaging:

Tar-cvf/u0/temp2.tar/usr/lib

Package the files in the/usr/lib directory with subdirectories into a single vault as/u0/temp2.tar.

Tar-cvf/u0/temp2.tar/usr/lib *.c *.F

Package files (excluding subdirectories), such as *.c *.f, in the/usr/lib directory.

Note: If you specify a file such as *.c *.f or *. *, no subdirectories are included in the package. If specified as. or *, the subdirectory is included.

2. Compression:

Ibid.: Compress/u0/temp2.tar Compression for/u0/temp2.tar.z

3. Unzip:

The uncompress/u0/temp2.tar.z is reverted to/u0/temp2.tar.

4. Unpacking expansion:

Tar-xvf/u0/temp2.tar

When unpacking with a relative path, the expanded file data is stored in a relative path, and the expanded file data is stored in an absolute path if the package is packaged as an absolute path.

If you specify an expanded file name, be aware of the directory path of the file.

5. Display:

Tar-tvf/u0/temp2.tar Displays the file name in the vault. When specifying a file name, you should also note the path to the files.

These two commands have their advantages and disadvantages in relative terms.

1) tar is slower than cpio and cannot span two storage media, but the file format is common in almost all UNIX systems and is easy to use.

2) Cpio because of the pipeline function, so that its packaging when the file selection, removal function is very strong, and can span multiple media, and can back up special system files.

In addition, the compression command compress lower than the DOS PKZIP compression rate. After testing, in a directory of 527 text files Total 15.7MB, after the UNIX packaging with compress compression, size 2.1MB, the same file copied to the DOS system with PKZIP compression, the size is 1.4MB.

Linux Common Operations Command (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.