How to use the command
Shutdown--help
Shutdown--?
Man shutdown these three ways can be
Shutdown's wrong, he'll have a clue.
Which command does not know how to use, ask a man on it
Man is manual handbook, manual Hand, manual
Clear
Clear is the clear screen, Windows is CLS
CD Conversion Catalog
The conversion directory is a CD, just like under windows
CD/So it's up to the root of the directory, the forward slash is the root of the directory
Mkdir
Mkdir make dir Create a new directory, not a file
Rm
RM-RF most commonly used
RmDir Delete an empty directory, the directory cannot have anything underneath it.
RmDir Empty directory Name
Rm-r Directory name recursive this command always asks me
RM-RF Directory name Force don't ask me again. Most commonly used
RM-RF file names can also be deleted
Recursive regression, recursive remove removal
Touch
Create a file
Touch 1 File name 1, no suffix
Under Linux, the suffix name of the file is technically meaningless. But when it comes to naming a file, it's normal. For example, 3.txt is a text RT.exe is an executable program
List the contents of a file
Cat TAC Head Tail more
Cat 3.txt positive sequence starts from the first line
TAC 3.txt Reverse from the countdown to the first line
Head 3.txt head head-3 3.txt list first 3 rows head can take parameter-lines
Tail 3.txt tail tail-1 3.txt last line
More 3.txt-------The default is to be paged, so a lot of plumbing used him
Cp+move
CP copy copy MV move mobile
CP 1 2 Copy 1 of this file, called 2, so I have two files.
Cp-r d1 D2 Copy directory must have parameter R
It is easy to understand: Delete a directory, the first thing to delete the directory below. To use recursion, the copy is also
MV D2 D1 Move D2 directory to D1, if not, add recursion mv–r
Name of the word MV
In addition to the MV can be moved outside, but also can change the name
Mv 3.txt 4.txt Change the name of 3.txt to 4.txt
Shutdown + Restart + exit
Exit is the QUIT command line
Reboot is a reboot.
Shutdown shutdown, this command needs to take a parameter shutdown now
The init 0 is also off because there are several layers, 6 floors.
Logout is logoff
Exit: Q--CTRL + c---ctrl+d, I don't know what they're quitting, try it all
Man LS when there will be a lot of content, Q key can exit
LS lists things under the directory
Under Windows is dir, and Dir is also available under Linux
List the contents of the current directory (including directories and files), this command has several parameters.
Ls–l this most commonly used
ls horizontal display, this line is full of the next line
Ls-l is an L, which is also a line display, but a single line displays only one file or directory, with detailed information about the file or directory.
Ls-m Horizontal row, this line is full of the next line
Ls-r a little like a tree show.
WhoAmI
Displays the current user, root or other user
Pwd
Displays the current directory you are in
Press 5 down ESC
Press 5 to ESC and there will be a lot of commands to use
Display all 2091 possiblities, so Redhat Linux has more than 2000 commands.
Mount Mount + Uninstall
Mount point mount Points
Mount----------------------------------------------------------------------
MOUNT/DEV/CDROM/MNT/CDR the CDROM device under the Dev directory under the root directory with the
The CDR directory under the MNT directory under the root directory is associated with this is the Mount
mount point------CDR device-----CDROM
Uninstall---------------------------------------------------------------------
Umount/dev/cdrom or UMOUNT/MNT/CDR
VI is important
This command interview most, VI is a text editor, similar to the Notepad of Windows
Touch is to create a file, but this file has no content, how to add content, with VI
VI 3.txt After finishing this command,
Out a text editor, but not the content, because just started to enter the command mode, can only knock command
VI has two modes-command mode and edit mode, just start to enter the command mode, cannot enter content
Hit a into the edit mode, the bottom will appear insert this word append append
Tap ESC to exit Edit mode and enter command mode
Under command mode, break the colon: and then the colon will appear underneath, and then the command W is disk
Q is to exit q! is not to save the WQ is to save the exit (most commonly used)
I think Wq is to save the exit W is not write meaning
More 3.txt displaying 3. txt content
Find
How does he differentiate with grep?
Find the name of a file (if you remember the approximate name), find its path path, where he
Find features are powerful
You can also find rc.local based on creation date.
Find/-name *local starting from the root directory, specifying a location, starting from there
Find/etc-name *local
find/etc | grep Local System go back to find all the files or directories that contain the local letters
Find/-name MySQL system just go back to the file or directory named MySQL.
Find/-name mysql* system go back to find the first few letters are MySQL (back any)
The file or directory
Names don't have to be written full
Whereis
Whereis ls find ls where is this command
/bin bin directory below are various commands VI cat LS pwd and so on
There are also various commands under the/usr/bin directory
View environment variables
See Environment variables under DOS
Echo%path%
Echo%classpath%
Under Linux echo $PATH PATH must be capitalized
Link Ln
is LN-------------link
ln 3.txt 4 More 4
What is the difference between a link and a copy----------for the link, I changed the 3.txt,4 content will automatically follow the change
If you haven't modified it 4
ln 3.txt 4 This is a hard link, which is equivalent to copying another copy, and then creating a shortcut between the two files
Modifying the 3.txt,4 will also change
Ln-s 3.txt 5 Soft This is a soft connection, equivalent to a shortcut inside windows
Soft Connect: Modify 3.txt,5 will also change
Differences between the two types of links
The 3.txt is deleted, 5 does not exist, the connection is broken, and 4 is present.
Wc
Word count is not a toilet wc-l lines how many lines this file has
Grep
grep is a very common command, please remember him firmly what his full name is
Global Regular Expressions Print Universal Regular expression version
Finds the specified string in a text file, and displays the line that contains it, paying attention to the line
grep Student 4
In 4 This text file to find student this string, which line contains it, displayed
^ in regular expressions, represents the beginning of a line
Ls-l | grep ' ^d ' only lists the directories,/etc files and directories are many
^ This character is above the number 6
Rpm–qa to list all the bags,
Rpm-qa | grep MySQL finds all the packages that contain the words MySQL, as long as the package name contains MySQL letters, it will be found
grep and find
Find/-name mysql*
Find/| grep MySQL
Fdisk-l L
Displays the current disk information
Dmesg
List boot information for power on the full name is------D message
DMESG | grep eth0 See the first NIC booting up normal?
Command Replacement Wall
command to replace---with no more open two command lines
Wall Full name------warning All notify everyone, warning everyone, not the wall
Wall HelloWorld
The wall ' date ' warning character is the current time, take date as a command, and warn the result of the command execution.
Wall Date warning character is date
' This character is the number 1 left that character
redirect
There's not much to redirect---
One of Java's original programs
Replace out the Out
SYSTEM.OUT.PRINTLN () The command is output to the command line, and now he outputs the command to the file.
Ls
ls > Cmd.txt Input the results of the command just executed by LS into the Cmd.txt file.
Error output redirection---------
Lssss > Cmd.txt No, lsss, this command doesn't exist.
Lssss 2> Cmd.txt
REDIRECT Input
Wall < Cmd.txt to warn the contents of Cmd.txt
The empty
Pipeline
Huge number of pipes
page display,/etc a lot of content below
Ls-r
Ls-r | More of the meaning of the sentence
Give the result of the last command to the next command
Ls-l/etc | More
| ----------------is a pipe connector
More The default is to be paged, but the ls-l will not be paged, sometimes the content of the display is huge, with more will result. It's not good to split pages.
Once the pipeline learns, his function will be very powerful.
Ls-l | grep ' ^d ' only lists the directories,/etc files and directories are many
File Permissions Files Privilege
The most important thing about Linux-file permissions------must master-----------files privilege
Objective
A total of 10 people on the left
-(on behalf of the file) d (for the directory) L (is the L for the link)
The leftmost one is removed, leaving 9, which can be divided into 3 groups.
-rw-r--r--divided into 3 groups-rw-r--r--
Drwxr-xr-x
lrwxrwxrwx
In addition to the representative characters, there are 9 digits, what they represent
The permissions for Linux files are divided into 4 types---------
Read Write Execute none (Nothing)
9 bits divided into 3 groups
The first group represents what permissions the owner of this file has
The second set of permissions that are owned by the same group as the owner of the file
The third group represents what the rest of the people have right
X--------------Execute
R-------------Read
W---------------Write
-Stands for nothing but none
Chmod-not Professional
You can also modify the permissions change mode changes Modify
chmod +x 4 to 4 This file plus executable permissions, then the three groups of people have this permission
Chmod-x 4 Canceling permissions
I want to give myself only to add executable permission, the remaining two groups of people I don't care, only to the first group plus permissions
chmod u+x 4
How to get this permission for other people in the same group chmod g+x 4, only add permission group to the second group
chmod o+x 4, add permissions to the third group only
Professional Modification method
The above wording is not professional, the following good---------------------
chmod 755 4 chmod 777 4
7 means that the permissions are all 5 means no write permission
Representation of permissions within Linux (Unix), represented by 3 octal numbers
000 =====0 111 ======7
Read and write executable
One 8 binary one 8 binary one 8 binary
Three-bit three-bit three-bit
How to modify the owner of a file
Chown TestUser1 4-------------Change owner
Management of simple users
When a user logs in, the default path is the user's home directory
Add user
Useradd testuser adduser testuser
Both of these can be
Set Password
passwd testuser to this user set the password, if you lose the wrong password, press the BACKSPACE key---no, no. Because the password does not appear
Two position changes
After adding a user, the system has two positions that change--------------/home and/etc
--------------------------------------1
Cd/home ls
The home directory will have an automatically generated directory called TestUser.
--------------------------------------2
What about the ETC catalogue?
Cd/etc
More passwd open passwd this file
passwd This file does not have a password, it is stored by all users, testuser This user can also be found here
Testuser:x:501:502::/home/testuser:/bin/bash
This User ID number---501 in the group: 502
The user's home directory is----/home/testuser
The shell--------used by this user/bin/bash
User Group------------------------------------------------
The group's information is/etc/group in this file
When you add a user who does not specify a group, he adds a group that is the same as your user name
Add a group
Groupadd TESTG
Useradd testuser2-g Testg Specify a group when adding users
You can also modify the group that the user belongs to Usermod-g testuser TestUser2
New group user name
Usermod---------User Modify
Delete Users and Groups
Delete users in two steps---Delete the user deleted his directory
Userdel TestUser
Cd/home
RM-RF TestUser
Deletion of groups
Groupdel TESTG
User Switching
Switch User
Su TestUser2
Shell
User's Shell---------
You're not dealing directly with the kernel.
There is a layer outside the kernel, called Shell,shell, that will explain the commands you hit under Linux, and then deal with the kernel.
The shell has different forms
There are different shell,c shells-------the C-language form of the shell
Different shell commands are not the same, the same commands are not common under different shells, common commands
Can be universal
We use the shell called Bash, the former name BSH, the origin of the name, is a person called bone
wrote, so called BSH, and later he wrote one side, bone again shell, so called bash
BASH------Switch to bash
CSH---switch to C shell
Ksh-----switch to K shell
The most primitive and primitive shell of SH
BSH------Switch to BSH
To modify the system default boot level
When modifying that profile, first back up
Modify the configuration file/etc/inittab, change the number in Id:5:initdefault 5 to 3
Because
3 Pure command line interface, with network sharing
5 graphical interface
The next time the system starts, it's not going to get into that graphical interface.
Important A few
Ip
View IP address and set IP address
Ifconfig can either query IP or set IP
Ipconfig is the command under Windows
Linux Query IP command ifconfig----------------
The ifconfig command can also configure IP----------
Ifconfig eth0 IP Address
Services Service
Start a service, such as a service that starts MySQL
Service MySQL start not all the commands have this d this letter
Service iptables Stop shutting down the firewall
Service VSFTPD start VSFTP server
Service VSFTPD Stop Service stopped
Service VSFTPD Restart Restart
But how do you know the name of the service?? Use this command chkconfig
Ps-ef
How to know that the service has been started, such as the MySQL service has been started
PS---process processes-e = =-A Lists all processes
Ps-ef | grep Service Name
Ps-ef | grep MySQL Ps-ef | grep Tomcat
There are questions (you can think of them as closed when the result is only one line)
Boot from Boot
You don't have to start mysql,vsftp,apache manually, and so on.
With Chkconfig This command, check configure checks the configuration
You can not only know if the service is booting.
You can also set up boot-up for this service
You can also know the name of the service.
How do I know the name of the service------------
Chkconfig--list This command will list all the service items, you can take a slow look, and you can search
Chkconfig--list | More
Chkconfig--list | grep MySQL
Chkconfig--list | grep vsftpd
Chkconfig MySQL on these several 3 4 5 levels all started
Chkconfig--level 3 MySQL on just starting at 3 this level
Chkconfig MySQL off
MySQL database service--------------MySQL
Vsftp Server service------------VSFTPD
Firewall service------------iptables
SSH service------------sshd
HTTP------------------httpd
Linux basic Commands