Linux Day Knowledge (Common question notes)

Source: Internet
Author: User
Tags log log

http://blog.csdn.net/yizhu2000/article/details/70688420) A preface to the day, when there is a record, since 09, work required, access to open source platform, on Linux often, in the meantime, the issue, the record, Although for our broom, dare not from Jane, the entries are not strictly sorted, I hope that the latter will benefit.

1) frequently used to view the path of a command

Which: View the path to a command that looks for a command in the path variable configuration and gives the first query result back

Several ways to view user information

Finger

Id

Groups

Delete Directory

The fruit directory is empty, can be deleted with rmdir if the directory is not empty, you can delete it with RM-RF

Create a symbolic link (shortcut)

ln-s {target-filename} {Symbolic-filename}

For example Create Softlink for/webroot/home/httpd/test.com/index.php as/home/vivek/index.php, enter the following comm And:
ln -s /webroot/home/httpd/test.com/index.php /home/vivek/index.php
ls -l

View System boot Logs

DMESG | More

Grep

Ignore case

Grep-i

Randomly generated network card address

#!/bin/sh
EXEC 2>/dev/null
DD If=/dev/urandom Bs=1 count=6 | OD-T X1 | Sed ' 2d;s/^0\+//;s//:/g '

Three ways to add a path variable

1) Modify the/etc/profile file, this modification is valid for the global user

2) Modify the. bashrc file to be accurate to the user (valid only for the current user)

3) Add a variable directly under the shell, and the shell will fail if it exits

List files in chronological order

Ls–t

Sequence out files in reverse chronological order (new file after)

LS–RT (R stands for reverse meaning, can reverse all sorts)

LS finds a file in the current directory, but does not list the contents of subfolders

Ls–d "pattern"

Copy all files in one directory

Cp-r

How to load all file systems without restarting after modifying fstab

Mount–a

Move a folder

MV Src dest

View Linux Versions

1. View the kernel version command:
1) [[email protected] ~]# cat/proc/version
Linux version 2.6.9-22.ELSMP ([email protected]) (GCC version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1 SMP Mon Sep 19 18:00:54 EDT 2005
2) [[email protected] ~]# uname-a
Linux q1test01 2.6.9-22.elsmp #1 SMP Mon Sep 18:00:54 EDT 2005 x86_64 x86_64 x86_64 gnu/linux
3) [[email protected] ~]# uname-r
2.6.9-22.elsmp
2. View the Linux version:
1) Log in to the server to perform lsb_release-a and list all version information, for example:
[Email protected] ~]# [[email protected] ~]# lsb_release-a
LSB Version:: core-3.0-amd64:core-3.0-ia32:core-3.0-noarch:graphics-3.0-amd64:graphics-3.0-
Ia32:graphics-3.0-noarch
Distributor Id:redhatenterpriseas
description:red Hat Enterprise Linux as Release 4 (Nahant Update 2)
Release:4
Codename:nahantupdate2
Note: This command applies to all Linux, including Redhat, SuSE, Debian, and other distributions.
2) Log in to the Linux execution Cat/etc/issue, as follows:
[Email protected] ~]# cat/etc/issue
Red Hat Enterprise Linux as Release 4 (Nahant Update 2)
Kernel \ r on an \m
3) Log in to the Linux execution Cat/etc/redhat-release, as follows:
[Email protected] ~]# cat/etc/redhat-release
Red Hat Enterprise Linux as Release 4 (Nahant Update 2)
Note: The specific version number can be seen directly in this way, such as AS4 Update 1
4) Log in to the Linux execution Rpm-q redhat-release, for example as follows:
[Email protected] ~]# rpm-q redhat-release
Redhat-release-4as-3
Note: A so-called release number can be seen in this way, such as the above example is 3
There is a certain correspondence between the release number and the actual version, as follows:
Redhat-release-3as-1-Redhat Enterprise Linux as 3
redhat-release-3as-7.4-Redhat Enterprise Linux as 3 Update 4
Redhat-release-4as-2-Redhat Enterprise Linux as 4
redhat-release-4as-2.4-Redhat Enterprise Linux as 4 Update 1
Redhat-release-4as-3-Redhat Enterprise Linux as 4 Update 2
redhat-release-4as-4.1-Redhat Enterprise Linux as 4 Update 3
redhat-release-4as-5.5-Redhat Enterprise Linux as 4 Update 4
Another: 3rd), 4) Two methods are only valid for Redhat Linux.

2) Start related how to auto mount

Add a file system that automatically mount after booting up, can be completed by adding items to the fstab, such as adding a shared connection to Windows

How to load all file systems without restarting after modifying fstab

Mount–a

Add a service that needs to run at startup:

Method One: Create a link in rc3.d

Method Two: Add the startup item in the Rc.local

INIT.D,RC[X].D Directory Relationships

Files in this directory are all links, all pointing to the directory/etc/rc.d/init.d, and this/ETC/RC.D/INIT.D directory is the Linux RPM installation method, set some service startup directory. For example, if you want to restart SendMail, and your sendmail is installed in rpm, then release/etc/rc.d/init.d/sendmail restart to start SendMail directly! So you can know the main function of/ETC/RC.D/INIT.D inside the file! Therefore, when your run-level within the scripts to start which write service, hehe! Link the file to the file in the INIT.D directory and start it! In other words, "when you start Linux in text mode (run-level=3), your system goes through the BIOS, MBR, Kernel, Init,/etc/rc.d/rc.sysinit, and then enters the/etc/rc.d/rc3.d to start a Some service "! However, it should be noted that in RC3.D (or other directory under the RC0.D ~ rc6.d) directory in the start of the file for the service, K is the beginning of the file is to kill the meaning of the service. So what do those numbers mean? That's the order of the boot! For example, S12syslog will be executed earlier than S90crond! So why do we have these orders? There's a reason for that! For example your host has to start WWW good, then your network settings should be started before it! So, if www first start, only to drive the network, then the WWW nature will certainly not come! So the starting order of the services is also very important! Currently mandrake, you can use the Chkconfig to set the boot to start the service options!

3) Performance-related view memory information

Cat/proc/meminfo Viewing memory information

To view the usage of the system disk

The DF command can

Df–h, making the presentation result easy for people to read with units, such as 15176390, written as 15G

4) directory Permissions

-rwxr-xr-x 1 root root 512 November 5 08:08 Net.lo
Drwxr-xr-x 2 root root 48 September 6 13:06 VMware
When the ls-l or Ls-al command is executed, the first 2nd to 10th character is used to represent the permission, as shown in the result. The first character is typically used to differentiate between files and directories:
D: Indicates a directory, in fact, in EXT2FS, the directory is a special file.
-: Indicates that this is an ordinary file.
L: Indicates that this is a symbolic link file, in fact he points to another file.
B, C: block devices and other peripheral devices, respectively, are special types of files.
S, p: These files relate to the system's
Data
and piping, usually very rarely seen.
The following is a detailed description of the types of permissions and how to set permissions.
Ii. General Competence
Each of the 2nd to 10th characters is a group of 3, the left three characters represent owner permissions, the middle 3 characters represent the permissions of the user with the same group as the owner, and 3 characters to the right are the permissions of the other user. These three groups have a total of 9 characters and represent the following meanings:
R (Read, reading): For a file, have permission to read the contents of the file;
Browse
Permissions for the directory.
W (write, writes): For the file, has the new, modifies the file content the permission, for the directory, has the deletion, moves the file inside the directory the permission.
X (Execute, execute): For the file, it has permission to execute the file, and for the directory, the user has permission to enter the directory.
-: Indicates that the item does not have permission.

5) General installation steps for Software Installation tar.gz

TAR–XZF: Decompression

./configuration: Generate make file, typically configure the target path with the prefix parameter

Make: Compile

Make Install: Install

Find the assembly path installed with RPM

Rpm–qa | grep * * *

To see if a package is installed

RPM–Q Package Name

Find the assembly path installed with RPM

Rpm–qa | grep * * *

Using apt to install

sudo apt install apache2 mysql5

Related introduction

The Advanced packaging Tool, or APT, was a free user interface, and works with core libraries to handle T He installation and removal of software on the Debian gnu/linux distribution and its variants. [2] APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, Configurati On and installation of software packages, either from binary files or by compiling source code. [2]

6) network-related view native service port

Netstat–tln

View the program for a port

lsof–i:80, or NETSTAT–ANP | grep Port

Shutting down the firewall

/etc/rc.d/init.d/iptables stop

Turn on the firewall

/etc/rc.d/init.d/iptables start

View Pre-iptable configuration

: Iptables–l

Packet capture and packet analysis

: Tcpdump–i eth1 host XXX.XXX.XXX.XXX and Port 80

Other commands are as follows

Tcpdump the command parameter saved to the file is the-W xxx.cap
Grab Eth1 's Bag
Tcpdump-i eth1-w/tmp/xxx.cap
Grab 192.168.1.123 's Bag
Tcpdump-i eth1 host 192.168.1.123-w/tmp/xxx.cap
Grab 192.168.1.123 's 80-port package
Tcpdump-i eth1 host 192.168.1.123 and Port 80-w/tmp/xxx.cap
Grab 192.168.1.123 's ICMP packet
Tcpdump-i eth1 host 192.168.1.123 and Icmp-w/tmp/xxx.cap
Grab 192.168.1.123 80 ports and 110 and 25 other ports on the package
Tcpdump-i eth1 host 192.168.1.123 and! Port and! Port and! Port 110-w/tmp/xxx.cap
Grab the packet for VLAN 1
Tcpdump-i eth1 port and VLAN 1-w/tmp/xxx.cap
Password to catch PPPoE
Tcpdump-i eth1 pppoes-w/tmp/xxx.cap
Save files in 100m size, more than 100m open a file-C 100m
Grab 10,000 packets and exit-C 10000
Background grab, console exit will not affect:
Nohup tcpdump-i eth1 Port 110-w/tmp/xxx.cap &
The captured files can be opened directly with ethereal or Wireshark. Wireshark is the new ethereal.

How to modify IP information under Linux systems

I used to change it with ifconfig, and I always have to redo it after reboot. If you modify the configuration file, it will not be so troublesome ~

A, modify the IP address

Immediate effect:

# ifconfig eth0 192.168.0.20 netmask 255.255.255.0

Activation takes effect:

Vi/etc/sysconfig/network-scripts/ifcfg-eth0

B. Modify the default gateway

Immediate effect:

# route add default GW 192.168.0.254

Activation takes effect:

Vi/etc/sysconfig/network-scripts/ifcfg-eth0

C. Modify DNS

Modify/etc/resolv.conf

Modified to take effect immediately, start the same effective

D. Modify Host Name

Immediate effect:

# hostname FC2

Activation takes effect:

Modify/etc/sysconfig/network

New Boot Network configuration

/etc/init.d/network restart

Note: After modifying the machine name, it is generally necessary to modify the hosts (/etc/hosts) file to add the IP corresponding to the machine name.

Prerequisite: Redhat System

IP, Mask:

Edit/etc/sysconfig/network-script/ifcfg-eth0
ipaddr=192.168.0.1
netmask=255.255.255.0

Gateway:

Edit/etc/sysconfig/network
Networking=yes
Hostname=xx
gateway=192.168.0.100
Dns:

Edit/etc/resolv.conf
nameserver=202.96.209.5
Note: The above IP address should be changed to the IP address corresponding to your network configuration.

7) VI

Vim:undo and Redo

: U (undo operand)

Ctrl+r

VI Find:

Command status input/pattern2search, continue to find directly press N

VI Paste: P

VI Cut: [NUMBER]DD or d[number]d,,number means to cut a few lines

VI copy: [Number]yy,number is the number of rows

Move to end of paragraph {}

Shift+g move to end of document

d L Delete current character (same as x command function)
D 0 Delete to the beginning of a row
d ^ Delete the first character position to a line (excluding spaces or ta b characters)
D W Delete to the end of a word
D 3 W Delete to the end of a third word
D b Delete to the beginning of a word
D W removes the end position of a word with a space separator
D B Delete to the beginning of a word with a space separator

8) Common Directory role

/bin stores the user's longest commands, such as CP, LS, cat, and so on.
/boot Some of the core files used when booting Linux.
/dev is the abbreviation for device (devices), which is the peripheral device for all Linux. D:\document\Chat\MyIM\MyIM\bin\Release
/etc This directory is used to store the configuration files and subdirectories required for system administration.
Home directory, for example, a user named Wang, his directory is/home/wang can also use ~wang to express.
/lib This directory is the most basic dynamic connection library of the system, and almost all applications need to use these shared libraries.
/lost+found This directory is usually empty, when the system is not properly shut down, this is a few homeless files refuge.
/mnt This directory is empty, the system provides this directory is to let users temporarily hook up the other file system.
/proc This directory is a virtual directory, it is a system memory mapping, we can directly access this directory to obtain system information. In other words, the contents of this directory are not on the hard disk but in memory.
The home directory of the/root system administrator (root), which is the prerogative of the owner of the system.
/sbin S is the meaning of super user, which means that the management program used by the system administrator is stored here.
/tmp This directory is where some temporary files are stored.
/usr The files we use for the application are stored in almost all of this directory:/USR/X11R6 stores X_window directories,/usr/bin stores many applications, and/usr/sbin some of the management programs that are used by the super users./usr/ Include the header files needed to develop and compile the application;/usr/lib store Some common dynamic connection shared libraries and static repositories;/usr/local This is the/usr directory that is provided to the general user, which is most appropriate to install the software here. /usr/man to store help documents. /USR/SRC Open source code exists in this directory.
/var This directory stores those things that are constantly expanding, in order to maintain the relative stability of USR, those who are, often modified directories can be placed in this directory, such as the/var/log log file.

9) Other about input and output"<"">"The meaning

Cat x y 1> hold 2>&1

The result is a standard + error output to hold;

The cat x y 2>&1 1> hold is to redirect the error output to standard output and to the standard to hold. So the error output does not enter hold because it is directed to the standard output.

Assignment relationships

(1) 1 = hold, 2 + = 1;

(2) 2 + = 1, 1 = hold.

Shell Scripting related

Shift: Removes the first variable from the list of command-line variables, the second variable becomes the first, and can be understood as a variable-list-head pointer to move a

Daemon statements and & symbols can turn a program into a background output

10) Some problems with virtual machine installation Linux

Virtual machine Installation Flower Screen adjust resolution

VITUALPC sometimes after installing Linux, into the graphical interface will produce a flower screen, you need to jump to the command line mode, adjust the parameters of Xwin, the method is as follows

At startup, Linux prompts you to enter the interactive load mode (interactive) mode by typing ' i ' before loading each startup item, typing I, entering interactive mode, manually allowing system entries, and preventing the system from booting Xwin

Enter the command line mode, enter the/etc/x11/directory, modify the resolution in the X11 configuration file, color depth, etc., after the modification is complete, restart

New Linux version?? The kernel will be unable to capture the mouse when loading the VIRTUALPC virtual machine, you can modify the kernel parameters in the grub.conf to correct

Navigate to Kernel

Add I8042.noloop at the end of its line

kernel/vmiluz******* RO root=label=/* * * i8042.noloop

Windows 2008 Remote Desktop, eliminate only one user logon limit allowed

http://vanderbiest.org/blog/2010/08/16/multiple-rdp-sessions-in-windows-2008-r2/

COLLNETSVN 1.1.0 x86 Linux Installation

Download COLLNETSVN file

CP to installation directory

Switch user to a normal user su Somebody (must not be root, if there is no user, you can add a adduser, and then use passwd username to modify the user's password)

TAR–ZXF Decompression

Run CSVN/BIN/CSVN start and csvn/bin/csvn-httpd start with just this ordinary user (must not use root)

You can add CSVN-HTTPD to a startup item by LN–S/CSVN/BIN/CSVN-HTTPD S99CSVN_HTTPD and rebooting the system to see that the service is loaded at startup

One) Httpdapache configuration forwarding

<virtualhost *:80>
Proxypreservehost on
ServerAdmin [email protected]
ServerName search.cd-host.net
DefaultLanguage ZH-CN
Adddefaultcharset Utf-8
proxypass/http://www.missworld.cn:8888/
proxypassreverse/http://www.missworld.cn:8888/
</VirtualHost>

Start the light httpd with its own fastcgi:spawn

/usr/local/webserver/php/bin/spawn-fcgi-a 127.0.0.1-p 10080-c 64-u www-f/usr/local/webserver/php/bin/php-cgi

Linux Day Knowledge (Common question notes)

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.