Preface

Linux It's open source 、 Free operating system , Its stability 、 Security 、 Processing concurrency has been recognized by the industry , At present, many enterprise level projects will be deployed to Linux/unix On the system .Linux It can be installed in various computer hardware devices , Like mobile phone. 、 The tablet 、 Router 、 Video game control 、 Desktop computer 、 Mainframe and supercomputers . Strictly speaking ,Linux The word itself only means Linux kernel , But actually people are used to using Linux To describe this based on Linux kernel , And use GUN Operating systems for engineering tools and databases . It's professional , Mainly for servers , The embedded , Mobile terminal system, etc , But personal desktop is not as good as Windows good . This article will introduce you in detail linux The complete play of the system .

official account :「 Shallow feathered IT hut 」

1、Linux System introduction of

「 System administrator :」

  • root yes Linux System administrator under

  • Ordinary users can use su- Switch to system administrator

「 Basic commands :」

  • command

 Shutdown command
shutdown -r now   Now restart the computer
reboot            Now restart the computer
logout         shutdown -h now   Shut down immediately
  Cancellation
cd ..    Go back to the up Directory
Save the file  ESC : wq!
Do not save    ESC :q!
Browse the files in the current directory   ls
Clear the desktop   clear

「vi Editor 」

  • vi The editor is Linux The most famous editor in the world , It's also learning Linux Tools that must be mastered

  • stay unix You can also use vi Developing programs

「Linux You can do it java/c Development :」

  • stay Linux Of vi Write something simple in the editor java Program “hello,world”

1、Vi Hello.java
2、 Input i[ Go to insert mode ]
  public class hello{
      public static void main(String []args){
             System.out.println("hello,world");
         }
}
3、 Input esc key [ Enter command mode ]
4、 Input wq Save and exit /q! Exit without saving
6、 compile javac hello.java
   javac Hello.java
7、 function  java Hello  [java Running class file ]
 
ls Command to display the current file
ls -l Command to display a detailed list of files 

「Linux Lower development c Program or c++(cpp) Program :」

  • establish vi hello.cpp

 #include <stdio.h>
int main(){
    printf("hello!");
        return 0;
}
 
gcc hello.cpp   use gcc When the compiler compiles, the unnamed will be a.out file
gcc -o [ file name ] [ The source file name ]  use gcc Compiler compile file name
/a.out        stay linux Run under c The program just inputs / Can run 

2、Linux File directory under

「 File directory :」

  • Linux The file system of is a hierarchical tree structure , At the top of this structure is the root directory “/”, Then create another directory in this directory , A deep understanding Linux The file directory is very important

linux The important directories in the root directory under are as follows, which are automatically assigned by the system
root Catalog 、home Catalog 、bin Catalog 、sbin Catalog 、mnt Catalog 、etc Catalog 、var Catalog 、boot Catalog 、usr Catalog 、tmp Catalog ( All of them are at the same level )
 
root Catalog : To hold root Directory of user related files
home Catalog : The directory used to store the related files of ordinary users
bin Catalog : A directory for storing common commands
sbin Catalog : A directory used to store commands that can only be used with certain permissions
mnt Catalog : Used to mount floppy drive by default 、 The directory of the CD-ROM drive     This directory can be used to mount files   Or use shared files
etc Catalog : Directory for storing configuration related files
var Catalog : A directory used to store files that change frequently
boot Catalog : Directory used to store system boot files ( important )
usr Catalog : The default directory used to store the installation ( The installation file will be installed in usr Directory )
tmp Catalog : Directory for storing temporary files
 
cd / Return to the home directory
ls And dir Same function, display directory name 

  • Shows which path is currently under pwd The command is to display the current path

3、Linux User management of ( Ordinary users can't use )

「 User management command :」

useradd command :useradd  user name ( Add users )
passwd command :passwd  user name   ( Change user password )
userdel command :userdel  user name  ( Delete user )
userdel -r  user name ( Delete user and user home directory )

4、Linux Common commands

「 Common commands 1:」

 Specify run level
command :init[012356]
Operation level
0: To turn it off
1: A single user
2: No network service in multi-user state
3: Multi user state has network service
4: System not used reserved for users
5: The graphical interface
6: System restart
Common operating levels are 3 and 5, To modify the default run level modifiable file /etc/inittab Of  
id:5:initdefault: The numbers in this line
 
When starting the boot screen, press e Enter editor , When entering grub In the interface , Please enter e After selecting the second option, press e, Enter... At the end  1[ Single user level ]  Then press b Enter single user mode .
*: In this way linux Modification of user password 

「 Common commands 2:」

 command pwd [ Show current working directory ]
command cd  [ Change the directory ]
command ls  [ List files and directories ]
    ls -a  Show hidden files
    ls -l  Show long list format
command mkdir [ Build directory ]
command rmdir [ Delete empty directory ]
rm -f  file       It's the files that are deleted
rm -rf  Folder    Delete directory 

「 Common commands 3:」

tab Key can complete the corresponding content
command touch  [ Create an empty file ]
command cp [ Copy command ]
   cp -r dir1 dir2 Recursive copy command ( Copy subdirectory information )
 
command mv [ Moving files and changing file names ]
command rm [ Delete files and directories ]
    rm -rf * [ Delete everything ( Including directories and files )r recursive f mandatory ]

「 Common commands 4:」

 command more [ Display file contents , With the paging ]
command less [ Display file content with pagination ]
command grep [ Query in text ] grep -n " Find content " [ file name ]
command | [ Pipeline command ]    stay linux and unix In the system | It's the pipeline command , Give the last order to
                   The results are given to the | The following commands are processed
command man [ amount to dos Under the help]
example : Show about grep Information about the order  man grep
View port usage
netstat -apn |grep  Port number
Kill the process that uses the port
kill -9  Process number
Go to the root directory    cd /   No matter under that directory, it will enter the root directory 

「 Common commands 5:」

 command find [ Search for files and directories ]
stay linux in , Because the file system is composed of a hierarchical structure , So it's not easy to find specific files and directories in the whole system . and "find" Command can solve the above problems .
1、 Search and display files and directories with specified names in a specific directory
 find / -name man: It means to search from the root directory with the name man Files or directories for
2、 Search is accessed over a period of time / Changed file or directory .
 find /home -amin -10: Files or directories retrieved in ten minutes
 find /home -atime -10: Ten hours of memory to retrieve files or directories
 find /home -cmin -10: Files or directories that have been changed in ten minutes
 find /home -ctime +10: A file or directory that was changed ten hours ago
3、 Search for files of specified size .
 find /home -size +10k: It means to find /home The size of the directory is 10k The file of
  find   file    Go straight to the file
 find  -name   "* keyword *"    Fuzzy search 

「 Common commands 6:」

 The file type is determined by the file header field , Not by file suffix .
Redirect command : Pipeline orientation command ">" To cover ,">>" Add after the content of the original file
  ls -l > a.txt  Contents of list written to file a.txt in ( Overwrite )
  ls -al >> aa.txt The contents of the list are appended to the file aa.txt At the end of
   Enter information from a file database_program<database_data
 
-------------------------------------------------------------------
File owner 、 Your group and other groups
stay linux Each user in must belong to a group , Can't be independent of the group . stay linux Each file in has an owner 、 Group 、 Other group concepts .
(1) owner
It's usually the creator of the document , Who created the file , It's natural to be the owner of the document .
use [ls -ahl] Command to see the owner of the file
You can also use it [chown  user name   file name ] To modify the owner of the file .
 
(2) Group
When a user creates a file , The group of this file is the group of this user .
use [ls -ahl] Command to see all groups of files .
You can go through [chgrp  Group name   file name ] To modify the group where the file is located
 
(3) Other groups
Except for the owner of the file and the users of the group , Other users of the system are other groups of files .
 
(4) Change the user's group
When adding users , You can specify which group to add the user to , The same with root Can change the group of a user :
    usermod -g  Group name   user name
You can use it.
    usermod -d  Directory name   user name   Change the initial directory where the user logs in
 
How to be in linux Add groups to
Need to use root Users to add , Ordinary users cannot add users and groups
Add group command :groupadd  Group name
 
see linux Information about all groups in
command :vi /etc/group
View command :cat /etc/group
Group name :x: Group ID Number :
 
Create user , And assign the user to the specified group .
command :useradd -g  Group name   user name
 
see linux All user information in
You can edit the view command :vi /etc/passwd
View command :cat /etc/passwd
 
user name :x: user ID: User group ID: notes :/ User home directory /: The user uses shell Interpreter
Set the password
command :passwd  user name
 
- rw- r-- r--
- For file type ,- For ordinary documents ,d For folder ,l For links
rw- The rights of the owner of the file to the file . There are three kinds of permissions 1、r Read and use 4 Express ;2、W I can write and use 2 Express ;3、X Executable can also use 1 Express .
r-- The permission of the file group to the file
r-- Permissions of users in other groups on the file
 
How to modify the access rights of the file ?
notes : Modify file access only root Users and file owners .
View the current operator command who am i
command chmod Commands for modifying file access rights .
chmod 777  file name
 
explain :
- --- --- --- 000
- r-- r-- r-- 444
- rw- rw- rw- 666
- rwx rwx rwx 777
- rwx rw- r-- 764

Conclusion

This article is about Linux This is the end of the introduction , There will be more about Linux More articles in series , Thank you for your support !

If you think that asamura's article will help you , Please search and follow on wechat 「 Shallow feathered IT hut 」 WeChat official account , I'll share my computer information knowledge here 、 Theoretical Technology 、 Tool resources 、 The software is introduced 、 The backend development 、 interview 、 A series of articles, such as thoughts on work and some thoughts on life . What you see and what you get , It's all about life . take your time , Work harder , You and I grew up together ...

I set up a technology group , If you want to know more about IT The technology of the industry and the problems in life , Welcome to join the group , Just add my wechat , Note that you can enter the group , We look forward to your participation .

Previous recommendation

Simplify the development |Lombok Artifact takes you out of redundant code

 

Redis Use | Cache penetration , An avalanche , Breakdown and Solution Analysis

 

Asynchronous programming | Five minutes to let you learn local refresh Ajax technology

 

Comprehensive analysis | understand Nginx This one is enough

 

dried food |SpringBoot JMS(ActiveMQ)API Detailed explanation of practical application

 

Thorough understanding | utilize Apache CXF Framework development WebService

 

Use it quickly Docker, This article is enough !

 

IntelliJ IDEA Hot deployment tools JRebel The use of the tutorial

 

Shallow feather

Message area

Point a praise , Prove that you still love me