Linux Common Commands 2

Source: Internet
Author: User
Tags aliases file copy ssh server

Netstat command to display network statistics
This command is used to display the entire

Netstat-anp
P Display name names

Kill-9 Process Number

Traceroute Show Packet History

What shell does the query system have?
Cat/etc/shells


Network card IP DNS address settings
http://xpku.blog.163.com/blog/static/239650020096213304219/

Samba installs and uses Samba as a resource share for Linux and Windows
Http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html
/etc/init.d/samba start

/etc/init.d/This is a directory, the following is a lot of service programs (of course, are executable).

Read Reading command

Read atest reading data into atest from the keyboard
Echo $atest
Read-p "Please enter your name:"-T-named
Echo $named

-P follow-up character
-T wait time

Declare declaring variables


History

!number executing the number in history command
!command Execute recent command search forward with command
!! Execute the most recent command


The order of Path and command lookups
Alias->builtin-> $PATH the order in which commands are found


Cat/etc/issue welcome information in which the change information is used for system login
CAT/ETC/MOTD This is provided for the Telnet user to display information using the


Cat/root/profile read information before logging in to login

Mysqldump-u root-p Password database name >data.bak backup
Mysql-u root-p Password database name <data.bak recovery

SSH installation
Ubuntu with apt-get install SSH server SSH service
Netstat-anp|more
-P View Process number

Kill-9 Process Number
/etc/init.d/ssh Start SSH Service
netstat-apn| grep 22 See if Port 22nd is turned on
If it is inside the virtual machine, the NIC must be bridged, and then the IP address is the IP address of the ifconfig displayed in the virtual machine to connect

Use Crontab for task scheduling
Crontab-r terminating task scheduling
CRONTAB-L lists which tasks are currently scheduled
1. Set up Tasks
Crontab-e
2. To perform at a certain time
Want to execute date>>/home/friends/mydate2 every 2 o'clock in the morning

minute-hour date calendar week (0-6)
5 * * * * ls-l/etc/>> filename

3. Scheduling Multiple tasks
1) write interlaced in crontab-e
2) All tasks can be written to an executable file (Shell programming)
Write a shell script, and then execute this shell script in 1)


View process
Ps-aux viewing process information to view a process at a time statically
Top Dynamic Ground
then enter the U return and enter the user name to see a user's startup process
Then enter k and enter the process ID number to end to kill the ID of a process

Top-d 1010-Second update process

Terminating a process
Kill PID kills the process because some processes will catch some signals, and if this process cannot be completed the following
Kill-9pid forcing the removal process


CD nothing adds default to your user's home directory

RM-RF B can delete the directory and the files inside it
-R Recursive Recursive
-fforce mandatory, will be full coverage, otherwise will ask whether to overwrite
Touch file name to create an empty file

Cp-r source folder destination folder Copy folder operations
CP source file destination file copy file

Automatically execute shell script files after user login (important)
Each user has its own set of environment variables configured, and the configuration file that runs the appropriate script before starting.
The. BASHRC is located in the main directory such as Friends
Before it executes the system script/ETC/BASHRC primarily the basic configuration data/ETC/BASHRC is the system

Bash_profile is located in the environment variable under the main directory such as Friends user, and the user's environment variable is configured.
It before executes the system script/etc/profile mainly configures the environment variable/etc/profile is the system shell script, configures the system environment variable

Shell Learning

CAT/ETC/PASSWD the last piece of data indicates which shell is provided for this user
Alias lm= ' ls-al ' command aliases replace

Type command to see if the command is part of Bash

command too long plus \ Press ENTER will let enter do not have the effect of the implementation of the multi-line input command function

User-defined variables are best added to my personal habits
setting of the MYNAME=WF variable
Echo$myname Display Variable Contents

If a space must be marked with double or single quotation marks

The contents of the double quotation mark can maintain the original characteristics of the data
The contents of single quotes are treated as ordinary characters

Unset MYNAME to cancel the setting of a variable

EXPORT MyName lets other sub-processes execute, making it an environment variable.

"The callout executes the command first and then executes the result to the perimeter command."
Ls-l ' Locate AA ' put the file name AA related first to find out and then display their information


ENV View Environment variables
Set view environment variables and custom variables
Export allows custom variables to be programmed environment variables


# #介绍重要的环境变量
Histsize Number of HISTORY commands
Random generates a number between 0~32767
PS1 set the prompt to show more content to the prompt P306
The following is the meaning of the configuration display in PS1
O \d: Represents the date, formatted as Weekday Month date, for example "Mon-1"
o \h: The full host name. For example, the bird's practice machine linux.dmtsai.tw, then this host name
O \h: Takes only the first name of the host name. In terms of the above, it is Linux only,. dmtsai.tw is omitted.
o \ t: Display time in 24-hour format such as: HH:MM:SS
o \ t: Show time, 12-hour time format!
O \a: Display time, 24-hour format, hh:mm
O \u: Current user's account name;
o \v:bash version information;
o \w: The full working directory name. Home directory will be replaced by ~;
o \w: Use basename to get the working directory name, so only the last directory name is listed.
O \#: The first few instructions issued.
o \$: Prompt character, if root, the prompt character is #, otherwise it is $.


PS2 When you use the transfer symbol \ The content of the second line is usually ' > '

$ this shell PID can $$ view the PID of this shell
The callback code if the last command execution succeeds the callback code is 0 otherwise it is not 0 through $? view


Declare and typeset are the same function, declaring the type of the variable
Declarebash all the variable names and contents.

-a defines the variable variable as an array type
-I integer number
-X usage is the same as export
-R is set to the ReadOnly type, and the variable cannot be changed or reset

For example
sum=100+200
Echo $sum result is 100+200
Declare-i sum=100+200
Echo Sum result is 300

Declare+x sum-becomes + can be canceled operation, the sum into non-environment variable

Ulimit-a View Parameters
can set the system maximum resource withstand range check command

Login Shell and Non-login shell

When you add an environment variable to a ~/.BASHRC file, you need the following to be active immediately
Source Configuration file Name
. Configure file name two command equivalent to read the settings of the master file into the current bash environment
source. BASHRC
. . BASHRC

~/.bash_history Store history Command record content histsize This environment variable think most of the memory
~/.bash_logout Records when the shell helps us do something, we can add things to the inside, when we quit what we want the shell to do for us

/ETC/BASHRC is a system that allows all users to share

/HOME/FRIENDS/.BASHRC is friends the current user is logged in the time to read


Configure the. bashrc file to specify that some programs will start automatically when the user logs on.

When you want to temporarily join a path, use export
Export path= $PATH:/root is temporarily in effect, add a path to make its child processes valid for this temporary variable, and the others will be invalid.

Bash produces child processes in child processes the parent process is declared to be useful with export

unset name cancels name the contents of this variable are valid only for the current bash or child bash. Invalid for newly launched bash

env | grep $PATH View

Alias usage aliases
Aliaswwff= ' ls-l/home ' temporarily in force
WWFF will be executed as an alias command.


Wildcard characters (must be mastered)

* Multiple letters or numbers
? 1 letters or numbers
[1-6] A number of numbers between 1-6

Linux Common Commands 2

Related Article

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.