Linux Common commands

Source: Internet
Author: User
Tags first string gz file psql pkill

Ps-e | grep ' Java '

"To see all of the processes

Ps-auf

Ps-aux|more

"" Kills the process

Kill PID

Http://www.yuanma.org/data/2007/0516/article_2600.htm

"" View port

Netstat-an | grep 8081

"" Closed port

Netstat-an | grep 8081

[Email protected] tomcat]# NETSTAT-NTPL | grep 8081

TCP 0 0::: 8081:::* LISTEN 23793/java

Kill-9 23793

"To see which program is taking up a port

Netstat-an

lsof-i:8086

"" View user

# CAT/ETC/PASSWD

"" View Group

The fourth label inside the Cat/etc/group corresponds to the group number.

User name: Password: User id: Group identification number: Annotative Description: Home directory: Login Shell

"" To view login user history

Last

W.H.O.

W

"" To see the top n

Last-20

Want to kick apart kaifa this user and all of his open programs

[Email protected] ~]# pkill-u Kaifa

Note: This command is actually dangerous and should be executed with great care, as all operations of this user will be cut off immediately and not saved.

It is safe to look at the terminal number and then view all the processes performed by that terminal and stop the service based on the process number.

Safe culling of users

[Email protected] ~]# Ps-ef |grep PTS/2

Get the user to log in the corresponding process number PID after execution.

[[email protected] ~]# kill-9 PID

Modify Postgres user password: passwd postgres

Copy of ""

[Email protected] ~]# ls/root/temp/

Sk

[Email protected] ~]# cp/root/temp/sk/root/desktop/

CP: Skip Directory "/root/temp/sk"

[Email protected] ~]#

Workaround: Post CP plus-R

Copy subdirectories and files

Cp-a/opt/tomcat/webapps/negchina/js/* js/

"Delete User, group

3. Delete all special accounts

You should delete all unused default user and group accounts (such as LP, Sync, Shutdown, halt, news, UUCP, operator, games, Gopher, etc.).

To delete a user:

[[email protected]/]# Userdel LP

To delete a group:

[[email protected]/]# Groupdel LP

"Compressed folder

Example one: Package all the files in the/etc directory into/tmp/etc.tar

[[email protected] ~]# TAR-CVF/TMP/ETC.TAR/ETC <== package only, do not compress!

[[email protected] ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, compressed with gzip

[[email protected] ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== packaged, bzip2 compressed

TAR-ZCVF Src0819_2.tar.gz/var/www/negchina (Cannot use *. * Otherwise does not include subfolders)

Examples of advanced applications for compression commands:

Make a backup of all files in the/usr directory, including its subdirectories, with the backup file named Usr.tar

Tar cvf usr.tar/home

Make a backup and compress all the files in the/USR directory and include its subdirectories, and the backup file name is usr.tar.gz

Tar czvf usr.tar.gz/usr

--Example

Tar czvf negchina-src.tar.gz/usr

Compress a set of files with a suffix of tar.gz

#tar CVF back.tar/back/

#gzip-Q Back.tar

Or

#tar CVFZ back.tar.gz/back/

Releases a file with a suffix of tar.gz.

#tar zxvf back.tar.gz release back.tar.gz to Back.tar

#gzip back.tar.gz

#tar xvf Back.tar release Back.tar for Back

"" Unzip

TAR-ZXVF FileName.tar.gz

"" Linux view file and folder size

DF and Du commands

Du–h

Linux view disk partitions, file systems, usage

Df–lh

"" View CPU Memory

More/proc/cpuinfo | grep "model name"

Memory

grep memtotal/proc/meminfo

Model Name:intel (R) Xeon (r) CPU E5620 @ 2.40GHz

"" New user new Group

http://zh888.blog.51cto.com/1684752/385605

Useradd lighttpd//Add a user lighttpd

Groupadd lighttpd//Create a new LIGHTTPD group

Useradd-g lighttpd lighttpd

passwd lighttpd

Useradd zjfneg223

"" To inquire about the installed RPM package

Rpm-qa|grep Prostgres

RPM-E rpm Name Uninstall

"" To force the unloading of RPM packages

--nodeps

Yum Remove rrdtool-1.4.4-1.el5.rf.i386

"To force the deletion of a folder

RM–RF Dir_name

"To assign the permissions of a directory to a user

Chown-r Negzl:ftpuser/etc/httpd/logs

Chown-r/etc/httpd/logs

Chown-r Negchina:negchina/home/software

Chown-r Zjfneg223:zjfneg223/home/software

Chown-r Negsoft:ftpuser/home/software

"" Directory Permissions

chmod 755 Logs # Success

Drwxr-xr-x (755)

"" Linux File permissions detailed

"First-Indicates the type of file:-Normal file D directory file l symbolic link file (soft connection file) C-Symbol device file B block device file P pipe file s socket file

The meaning of the RWX Representative is: Read readable write writable executive executable;

"From the three groups of RWX representatives of the third group of the meaning: User belongs to the main group other

Rwx

111

From http://www.hackbase.com/tech/2011-04-27/63469.html

>>> If the user name is deleted , it is occupied with W command, find his terminal name, and then use the following command

Pkill-kill-t PTS/4

"This is a new kind of ftp . Account name

Useradd-s/sbin/nologin Account Name

======================================

I write
ESC exits
shift+: Initial state
Vim file name
Wq Write
Q! Do not save exit
SHIFT + Insert Paste
CTRL + Insert Copy

LS Select File
CD Space Road Warp
CD Space: Back to previous level
Ls-l Viewing users
SU user name (Negsoft)
CTRL + C debugging

CD/Return to the top level

Gzip-9/var/www/neg/negchina/var/www/neg/neg.tar.gz Packaging

Tar-zcvf/tmp/etc.tar.gz/etc

TAR-CVF Xxx.tar Negchina Tiansheng Dozen Ground Bag

Note: Xxx.tar to be packaged under that path
Negchina file path to be packaged

$ gzip Xxx.tar After this success, will become xxx.tar.gz will make the original file get a certain amount of compression

Cmd

CD file name

Dir Display file

Cd.. Back to previous level

Cd.. \ Return to the top level

tab can complete the file name

Common commands:
First, LS only lists the file name (equivalent to Dir,dir can also be used)
-A: Lists all files, including hidden files.
-L: List form, which contains most of the properties of the file.
-R: Recursive display.
--help: Help for this command.

Second, CD change directory
CD/: Go to the root directory
CD: Go back to your directory (different directories are different, root is/root,xxt for/home/xxt
Cd.. : Back to Parent directory
PWD: Displays the directory where you are currently

Three. Less file name: View the contents of the file.

Four. Q exit the Open file.

Five. Upload file: RZ Select the file to be transferred, OK.

Six. download file: Sz Specify the file name, enter to hit, that is downloaded to the Securecrt/download directory.

Seven: Delete file: RM Delete file, rmdir delete empty directory.

Eight. Show the last 20 commands entered: History 20

Nine. Get help command--help View command under detailed parameters: such as: RZ--help, Sz--help.

10. The CD Entry command to a folder:
mkdir+ folder name command to create a folder
sz+ file name from server-side send files to native command
RZ commands to transfer files from the local to the server side
ll lists all files in the current directory, including details for each file
Dir to the current folder
VI Open the current file

11. When editing a file:
A switch to edit mode
CTRL + C Exit Edit mode
DD Delete entire row
: Q Exits the current file
: W writes and saves the current file
-F Force XX parameters ...

Other commands:
1.PS-EF//View the server process as a list of the server processes that are displayed.
PS shows the process currently running on the system/usr/bin/ps [options]-e display each now running process-F to generate a full list

Actual operation:
--------------------------------------

1 SSH client connects to 10.5.1.55 system (see Starting remote client Instructions Securecrt.doc)

$ cd/home/bea2/user_projects/csdomain/bin

2 Viewing the WEBLOGIC92 service process

$ ps-eaf | grep WebLogic

BEA2 327926 331940 0 13:08:45 pts/4 0:00 grep weblogic

WebAdmin 421908 368956 0 Sep 24-4:13/usr/java5_64/bin/java-xms256m-xmx512m-da-dplatform.home=/home/weblogic/bea/ Weblogic92-dwls.home=/home/weblogic/bea/weblogic92/server-dwli.home=/home/weblogic/bea/weblogic92/integration- Dweblogic.management.discover=true-dwlw.iterativedev=false-dwlw.testconsole=false-dwlw.logerrorstoconsole=- Dweblogic.ext.dirs=/home/weblogic/bea/patch_weblogic923/profiles/default/sysext_manifest_classpath- Dweblogic.name=adminserver-djava.security.policy=/home/weblogic/bea/weblogic92/server/lib/weblogic.policy Weblogic. Server

BEA2 491796 385044 00:12:50 PTS/6 182:55/usr/java5_64/bin/java-xms6g-xmx8g-javaagent:/home/bea2/user_projects/ csdomain/introscope/wily/agent.jar-dcom.wily.introscope.agentprofile=/home/bea2/user_projects/csdomain/ introscope/wily/introscopeagent.profile-dcom.wily.introscope.agent.agentname=adminserver-da-dplatform.home=/ home/weblogic/bea/weblogic92-dwls.home=/home/weblogic/bea/weblogic92/server-dwli.home=/home/weblogic/bea/ weblogic92/integration-dweblogic.management.discover=true-dwlw.iterativedev=-Dwlw.testConsole=- Dwlw.logerrorstoconsole=-dfile.encoding=gbk-dibm.stream.nio=true-dweblogic.ext.dirs=/home/weblogic/bea/patch_ weblogic923/profiles/default/sysext_manifest_classpath-dweblogic.name=adminserver-djava.security.policy=/home/ Weblogic/bea/weblogic92/server/lib/weblogic.policy WebLogic. Server

Note: According to the above prompts to see the login user bea2 Start process, note the Red BEA2 for the process has, 491796 for the process number

3 Execute the following command to kill the process

$ kill-9 491796 (based on 2 operation to find the system process number)

Description: Execute $ ps-eaf after execution | The grep weblogic command will not see the process number of the WebLogic process

4 Starting the Service

$./quickrun.sh

-------------------------------------------------------------------
2.ant-buildfile cms_maintrunk.xml//build Bag

3.VI test.txt//Browse file contents
I {insert write input}
ESC exits Insert
: wq! Write save and Exit VI mode
: q! Do not save Exit VI mode

4. I am generally accustomed to using the PS–EF command to see the server process as a list, and to see the process of the server with the command Pstree so that the server process is displayed as a tree.
The advantage of the Pstree command is that the parent process of a process can be identified immediately. You may need to use the-P option to display the PID for each process, and the-u option to display the user name that started the process.
In general, this tree structure is longer, and you need to do so Pstree–up | Less this will give you an overview of the entire process tree structure.

5.secureCRT garbled Solution: Options->sessionoptions->appearance->font to change the default to UTF-8, you can display the Chinese font.

6.hostname: Check hostname

7.ifconfig Query Host IP

8. Use CTRL + C and CTRL + V under S-CRT:
Options---Global options---Edit default settings go inside and point terminal---emulation then point mapped Keys, point lower part, use Windows copy and Paste key, click Confirm.

9. Command to enter VI:
VI FileName: Opens or creates a new file and places the cursor at the beginning of the first
VI +n FileName: Opens the file and places the cursor at the beginning of nth
VI + FileName: Opens the file and places the cursor at the beginning of the last line
VI +/pattern FileName: Opens the file and places the cursor at the first string that matches the pattern

10. Move the Cursor Class command:
}: Move the cursor to the beginning of the paragraph
{: Cursor moves to end of paragraph
NG: Cursor moves to the beginning of nth
n+: The cursor moves down n rows
N: Move the cursor up n rows
n$: Cursor moves to end of Nth line
H: Move the cursor to the top row of the screen
M: Move the cursor to the middle line of the screen
L: The cursor moves to the last line of the screen
0: (note is the number 0) cursor moves to the beginning of the current line
$: Cursor moves to the end of the current line

11. Screen Tumbling Class command:
Ctrl+u: First half screen to file
Ctrl+d: Half-screen to the end of the file
Ctrl+f: Turn a screen at the end of the file//as if R
ctrl+b; Turn one screen to the top of the file

12. Search command:
/pattern: Searches for pattern at the end of the file from the beginning of the cursor
? pattern: Searches for pattern from the beginning of the cursor to the top of the file
N: Repeat the last search command in the same direction
N: Repeats the last search command in the opposite direction

Postgres using:
1. Enter the SQL runtime environment.
[Email protected] bin]$/psql-n dbname-u usrname
stay81=# Select COUNT (*) from table1;
Count
-------
5986
(1 row)

2. Exit, exit after use, or the connection has been suspended.
stay81=# \q

3.postgres data export.
[Email protected] bin]$/pg_dump-u postgres-t testtable-d testDB > Testtable.dump
or [[email protected] bin]$./pg_dump-u postgres-d testdb-t testtable-f c-v > Testtable.dump

4. Postgres data import.
[Email protected] bin]$/psql-u postgres-d TestDB < Testtable.dump
or [[email protected] bin]$./pg_restore-u postgres-d TestDB < Testtable.dump

5. On one host, dump the database directory on another host.
Pg_dump-h host1-p 5432 dbname | Psql-h host2-p Post1 dbname
Or./pg_dump-u postgres-d testdb1-t testtable |./psql-u postgres-d TESTDB2
-U is the user name,-D is the DB name, and-T is the table name, which is not required if the entire database is exported.

6.php execution.
[Email protected] bin]$/usr/bin/php-q./batchstart.php


Actual operation:
/home/absys6$ ls
DVLP dvlp_bak20090413 Personal tmp
/home/absys6$ CD DVLP
/home/absys6/dvlp$ ls
/home/absys6/dvlp$ CD Sv_policy
/home/absys6/dvlp/sv_policy$ ls
Include SRC
/home/absys6/dvlp/sv_policy$ CD src
/home/absys6/dvlp/sv_policy/src$ ls
/home/absys6/dvlp/sv_policy/src$ ls *pc//filtering the file
/home/absys6/dvlp/sv_policy/src$ grep VIP *PC//Lists part of the code that contains all the. pc files for the VIP.
/home/absys6/dvlp/sv_policy/src$ VI plyprmcnt.pc//view the entire file.

Command: gzip

Syntax: gzip [option] File name for compression (decompression)

-C writes the output to the standard output and retains the original file.
-D Unzip the compressed file.
-L Displays the following fields for each compressed file:
(1) Size of compressed files
(2) Size of uncompressed files
(3) Compression ratio
The name of the uncompressed file
-R recursively finds the specified directory and compresses all of its files or is decompressed.
-T test to check that the compressed file is complete.
-V for each compression and decompression file, display the filename and compression ratio.
-num adjusts the speed of compression with the specified number num,-1 or--fast represents the fastest compression method (low compression ratio), 9 or--best represents the slowest compression method (high compression ratio). The system default value is 6.

Note: gzip cannot compress the entire directory. You can use tar to package first, then compress

For example:
$ tar CF Test.tar test/
$ gzip Test.tar
Or
$ tar czf test.tar.gz test/


The directory/home has files Mm.txt, Sort.txt, xx.com.

Example 1: Compress each file in the/home directory into a. gz file.
$ cd/home
$ gzip *
$ ls
m.txt.gz sort.txt.gz xx.com.gz

Example 2: Unzip each compressed file in Example 1, and list detailed information.
$ GZIP-DV *
mm.txt.gz 43.1%-----replaced with Mm.txt
sort.txt.gz 43.1%-----replaced with sort.txt
xx.com.gz 43.1%-----replaced with xx.com
$ ls
Mm.txt Sort.txt xx.com

Example 3: Unzip the xx.com.gz.
$ gzip–d xx.com.gz
$ ls
Xx.com

Example 4: Detailed Example 1 shows the information of each compressed file, and does not understand the pressure.
$ gzip-l *
Compressed UNCOMPR. Ratio Uncompressed_name
277 445 43.1% Mm.txt
278 445 43.1% Sort.txt
277 445 43.1% Xx.com
$ ls
\

The so-called relative path:.

Linux Common commands

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.