Learn about Linux

Source: Internet
Author: User
Tags clear screen gpg system log ping network fully qualified domain name


linux01
I. Introduction and Role of Linux
WINDOWS:95 98-XP Win7 Win8 win10 (client)
Windows 2003server 2008server (server)
Linux: Ubuntu red Flag, Android iOS Hammer
Linux:centos (server)
Linux Features:
Open Source (free)
Safety
Stability
Reliable
Windows Server
Simple
Use
User-Friendly
http://www.netcraft.com Casing Technology
Linastovas
Ken Thompson
Dennislich
Second, command line prompt
a) [[email protected] ~]# (master)
[Current login user @ Host name current directory] #
Linux Super User: root
Windows Super User: Administartor




Super User


$ normal User
Current directory ~ User's home directory
Admin Super User/root/
Common Crossbow/home/user name/directory
b) Linux command format
command space [options] space [parameters]
Options: Use and adjust the function of the command
Parameter: parameter is the object of the command operation if you can omit the parameter display that indicates that there is a default value
Note: All content that is strictly case-sensitive under Linux is strictly case-sensitive
c) The LS list displays the contents of the directory (key Focus)
LS Direct return to display the contents of the directory
Ls-l long format display (thumbnail option with a minus sign complete option using two minus)
Alias LL
-rw-r--r--. 1 root root 27034 July 22:42 Install.log
First column permission owner rights belong to group permissions other people permissions (learn)
Second column: reference count
Third column: Owner
Fourth column: Owning group
Fifth column: size default unit byte
Sixth column: Last modification and access time of the file
Seventh column: File name
Ls-hl-h humanized display file size displayed as M K G T
Multiple options can be used together and most do not have any order
Ls-a Show all files (including hidden files)
file with dot in front of file name is hidden file
Requirement: I want all files humanized long format display
Ls-ahl
d) directory Operations Command (key focus Focus)


  1. The directory where the CD is switched
    A) command name: CD
    b) cd/home
    Relative path
    Refer to the current directory for queries if you use relative directories, please check the directory
    Absolute path
    Start a first-level lookup from the root directory (/) until the location is found for beginners, the absolute path is recommended
    CD back to the home directory of the logged in user
    CD-Go to the last action directory
    Cd.. Go to the top level directory
    tab to complement our directories and files
    c) Terminate command execution using CTRL + C
  2. PWD Displays the current directory (key Focus)
  3. Linux Common directory (the following directories must all be recorded) (key points)
    /root directory
    /root home directory for Super admin
    Home directory for normal users
    /bin Command Save directory (general user's command)
    /sbin Command Save directory (Super User command)
    /dev Device File save directory
    Save directory for/etc configuration file
    Save directory for/lib function library
    /MNT System mount directory (recommended)
    /media Mount Directory
    /tmp Temp directory
    /proc Direct Write memory
    /USR system software Resources directory
    /var system related file content
    /var/log System Log
  4. Set up a catalogue (key focus)
    The blue name of the file is the directory
    mkdir Directory Name
    mkdir Weisuobao
    Mkdir-p Weisuobao/shuaiqixiang/qiuqiu/baizi
    Plus-P is recursive creation
  5. Delete (key focus)
    RM-RF Files/Directories
    -R Delete Directory
    -F Mandatory
    Shortcut keys:
    Forced termination: CTRL + C
    Clear screen: Ctrl + L
    Iii. Document Operation order (with emphasis on key points)
  6. Create a file New file
    Touch file name
    Touch Hetao.avi
  7. Cat file name view file
    Cat-n Install.log
    -N View file displays line number simultaneously
  8. More file name split screen display
    More Install.log
    Space down page b page up Q exit
  9. Head-The number of file names to view
    Head-10 Install.log
    Iv. commands that can be manipulated by documents and directories (key focus)
  10. RM Delete rm-rf File/directory
  11. CP Copy Copy
    CP./xiaoni.laodu./weisuobao/shuaiqixiang/xiaoni.laodu
    Cp/root/xiaoni.laodu/root/weisuobao/shuaiqixiang/xiaoni.laodu
    Copying files
    Cp-r/root/sanpi/root/weisuobao/sanpi/
    -R Copy Directory

  12. MV Cut or renamed
    MV Source File Destination location
    Mv/root/xiaoni.laodu/tmp/xiaoni.laodu Cut
    mv./xiaoni.laodu./weisuodelaodu renamed
    You have to cut and rename.
    Mv/root/sanpi/xiaoni.laodu/root/weisuobao/ml.laodu


V. Authority management (key points and key points key points and difficulties)


    1. Permission bits


D rwx R-xr-x
The permission bit is 10 bits
First bit: Represents the file type


  • Normal file
    D catalog File
    L Link File
    The back nine bits per three bits represent a permission
    Second-to fourth-bit owner rights U=user
    Fifth to seventh member group permissions G =group
    Eighth to tenth other person permissions o = Other
    R Read 4
    W Write 2
    X execution 1
    • No permissions
      1. Modify permissions (Super Focus key points)
        chmod permission file name
        Logical Description Method:
        chmod u+x Yanquan.avi
        chmod u-x Yanquan.avi
        chmod u=rwx Yanquan.avi
        chmod g=rwx Yanquan.avi
        Other people right on the plus rwx for Yanquan.avi this file
        chmod o=rwx Yanquan.avi
        Please change someone else's permission to RW for Yanquan.avi this file
        chmod o-x Yanquan.avi
        Digital Description Method
        R =4 W =2 x=1
        chmod 5 5 5 Yanquan.avi
        chmod 755 Yanquan.avi
        chmod 777 Yanquan.avi
        777 maximum permissions are forbidden in the production server to grant this permission
        Experiment: Ask the root user to create a directory (default permissions rwxr-xr-x) in the directory of a new file set to 777 whether ordinary users can delete files
      2. Mkdir/jack
      3. Cd/jack
      4. Touch ROSE.RMVB
      5. chmod 777 ROSE.RMVB
      6. Useradd User name (add user) (Learn)
      7. passwd User name (add password for user) (learn)
        Use normal user to try to delete rose.rmvb file
        What are the results? Delete failed
        Cause: RWX permissions are inconsistent with the actual meaning of the directory and file
        File:
        R: View File contents
        W: Modify File Contents
        X: Execute File
        Directory:
        R: List Files
        W: Create Delete file
        X: Enter Directory
        Modify directory permissions If you want to delete files in the directory
        chmod 777/jack
        Summarize:
      8. Write permission to the file can only be modified to modify this file to delete the directory where the file is required to have write permission
      9. As long as the directory has write permissions to the files in the directory is root created files can also be deleted
        Give permission to be reasonable
      10. Having w permissions on a directory means that you need to have RWX permissions
      11. Rx is required for script execution and RX permission is also available for this directory


Chown modifying owners and owning groups
Command name: Chown
Chown User name File name change owner
Chown Linlin Yanquan.avi Linlin This user must exist
Chown User name: User group file name
Chown Linlin:linlin Yanquan.avi Change owner at the same time change the owning group
Vi. Help Commands
I. Man command name
Man LS space down page b page up Q exit
II. Command--HELP
LS--help
Vii. Shutdown and restart commands


    1. Shutdown-h now shutdown-H shutdown
    2. Shutdown-r now restart-R reboot
    3. Reboot restart
      Note: If it is a server please do not shut down but if it is your virtual machine you can be happy.
      linux02
      Eight, find the command
    4. Whereis command to find commands at the same time see the Help document location (master)
    5. The Find Search command searches the system for eligible file names (with key focus points)
      Find find location by what mode search search criteria
      A. Search by file name
      Find Find location-name file name
      Find/-name "SANPI" finds Sanpi files by file name (case-sensitive)
      Find/-iname "SANPI" finds Sanpi files by file name (case insensitive)


B. Search by File size
-size by File size
+50k Greater than 50k
-50k less than 50k
50k equals 50k
b k M G
Find/-size +50k finds all files with a file size greater than 50k in the root directory
C. Search by that file type
-type type Find by file type F: File D: directory L link file
Find/root-type d Find Home directory all file types below find all directories
d. Direct command operation in the results of the query
Find/root-name "Yanquan.avi"-exec ls-l {} \;
Find the location to find the way to find the file name-exec the command to manipulate {} \;
{} is used to place the results you have previously queried.
\ is escaping means that a command uses its own meaning and does not use aliases
; End of statement
Note that fixed formats can only be written in this way and note spaces


    1. grep "string" file name searches for eligible content in the document (focus on key points)
      -V Reverse Selection
      -I ignores case
      Grep-i "Root"/root/install.log
      Grep-v "Root"/root/install.log
      grep "string" file name
    2. Pipe character
      Command 1 | Command 2 command 1 Executes the result as an operand of command 2
      Ls-l/etc | grep Yum
      Ls-l/etc | More split-screen display of all content under the ETC Directory page Down space B cannot be manipulated
      Nine, compression and decompression (key focus focus on key points)
      Compression type under windows: RAR zip. 7z
      Linux compression type: tar.gz tar.bz2
    3. Compression
      TAR-ZCVF compressed file name source file
      -Z recognition. gz format
      -C Compression
      -V Show Compression process
      -F Execute Compression package name
      Compress options do not change the order
      TAR-ZCVF Shuaiqixiang/root/meilidelixiang


TAR-JCVF compressed file name source file
-j recognition. bz2 format
Tar. JCVF shuaiqidebao.tar.bz2 Meilidelixiang


    1. Unzip
    2. TAR-ZXVF Compressed file path
      TAR-ZXVF shuaiqixiang.tar.gz
      -X Decompression
    3. TAR-JXVF Compressed file path
      -X Decompression
      TAR-JXVF shuaiqidebao.tar.bz2
    4. Specify the decompression path
      TAR-ZXVF unzip the path to the path of the file-C location to be decompressed
      -C Specify path
      TAR-JXVF unzip the path to the path of the file-C location to be decompressed
      -C Specify path
      X. Mounting orders (with key focus and focus on key points)
      All Linux storage devices must be mounted to be used (the mount point in Linux is the drive letter in Windows) If you are mounting a disc, you must have a disc in the optical drive in advance
    5. Insert Disc ISO
    6. Set up a mount point
      Mkdir/mnt/cdrom
    7. Mount device description File mount point (must exist and directory must be empty directory)
      Mount/dev/sr0/mnt/cdrom
      If the following sentence appears to indicate your CD mount success
      Mount:block Device/dev/sr0 is write-protected, mounting read-only
      CD Uninstall
      Umount/mnt/cdrom
      Error
      Umount:/mnt/cdrom:device is busy.
      (In some cases useful info about processes
      The device is found by lsof (8) or fuser (1))
      The computer wants to say: "Big Brother can be done I don't want to kill myself
      Important: Be sure to exit your current mount point directory before uninstalling


XI. Network Command


    1. Ifconfig is the same as Ipconfig-all in Windows. Display Network Information
      Ifconfig eth0 192.168.204.250 Temporary modification
    2. Ping Network Connectivity Test
      Ping 192.168.204.148
      Ping-c IP ping number of times
    3. Netstat Viewing network status commands
      -T view TCP port TCP Transmission Control Protocol
      -u view UDP port UDP User Datagram Protocol Instant Messaging
      -L Monitoring
      -N Display IP and port number
      -A View all connections
      : Apache
      : 3306 MySQL
      Netstat-talun | GREP:80 to see if port 80 is being used Apache
      Netstat-talun | grep:3306 View 3306 port usage MySQL
      Tonight, you guys need to connect me with your external link tool.
      The/etc/selinux/config inside of the SELinux = enforcing changed to selinux=disabled after the reboot restart to take effect


12. Vim Editor
Vim is a full-screen plain text editor


    1. Vim use
      How to get into vim
      After vim, write the file name you want to manipulate.
      Example: Vim 1.php
      A. Vim mode


Command mode, insert mode (input mode)
A post-insert mode (APPEND)
I pre-insert mode
o Lower Insertion mode
A insert at the end of the bank
I Insert at the beginning of the bank
O Upper Insert Mode
Insert mode, Command mode ESC key
Command mode, edit mode (:) colon: w Save: Wq Save and exit: q! do not save exit (! Force)
Shortcut keys But this shortcut is only allowed in command mode
ZZ Save and exit
B. Command mode operation (Linux is mouse operation, Vim is all through the shortcut keys to operate, these shortcuts can replace the mouse)


  1. Cursor operation
    : N Moves to nth row
    : Set NU Displays line number
    in command mode
    H left J down k up L right
    GG Move to file header
    G move to end of file
  2. Delete entire row, cut
    DD Delete a single line
    NDD Delete multiple rows n represents the number of rows you want to delete
    DG is removed from the line where the cursor is located to the end of the file
    P Paste
  3. Copy
    YY Copy a single line
    Nyy Copy multiple rows n represents the number of rows you want to copy
    P Paste
    NP Paste N rows
  4. Undo Back
    U undo Windows Ctrl + Z
    Ctrl+r anti-undo Windows Ctrl+y
    Note: If you use a series of software such as internal Netcom, please exit the software and then use Ctrl+r why because Ctrl+r has hot keys in these software (shortcuts)
  5. Show line Numbers
    : Set NU Displays line number
    : Set Nonu hidden line number
  6. Find
    /Find Content
    N Next
    N Previous
    linux03
    First, package management
    A) Windows and Linux software not universal Windows. exe files cannot be installed directly under Linux
    Cons: All software is developed independently in Linux
    Advantage: Windows virus and Trojan can not be installed under Linux
    b) Package Selection principles
    I. If the package is installed after providing access to a large number of clients we are using (source package) installation
    II. If the package is installed after the local or a small number of client use recommendations we use (binary package) installation
    c) Package classification
  7. SOURCE Package
    Pros: Open from definition itself compilation efficiency
    Disadvantages: Long compilation time Once the error is not easy to exclude
  8. Binary (RPM) packages
    Advantages: Quick and easy installation speed
    Disadvantage: not open from Definition performance Poor package dependency high
    A--------------->b---------------------->c Tree-type dependency
    A---------------->b-------------------->c------------------->a ring dependent (library software dependent)
  9. RPM Installation
    I. Package naming
    Package name-Version number-number of releases-suitable for linux-hardware. rpm


II. Package FULL Name: Operation not installed package use our package full name is (with suffix name)
III. Package Name: operation of the installed packages using our package name (that is, no suffix name)


    1. dependency particularly severe
    2. install
      RPM-IVH Package full name (absolute path)
      -I installation
      -V Show details
      -H Show Progress
      Install location: default location
      RPM package is not recommended to specify the installation location
      1. The system is accustomed to using the default location to find RPM related information
      1. RPM package has the corresponding uninstall command do not worry about the installation is too messy to uninstall the
    3. Upgrade
      RPM-UVH Package Full name
      -u upgrade
    4. Uninstall
      RPM-E package name
      --nodeps do not check dependencies
    5. View
      a) see if the software installs
      Rpm-q package name--The query package is No install
      Rpm-qa | grep httpd-Displays all installation query HTTP installation
      -Q query
      -a All
      B) query the location of the package installation
      RPM-QL Package name-the location of the installation of the Chinese parts of the query package -l list
      C) query which package the system files belong to
      RPM-QF System file name---see which package file for this system file
      -F files file

    6. experiment: Install HTTPD
      Prepare: Mount Disc
    7. put the ISO image file
    8. Create a directory if you already have it, you don't have to create it.
    9. mount/dev/sr0/mnt/cdrom
    10. If the mount is successful, go to the mount point directory
      Cd/mnt /cdrom/packages/


E RPM-IVH httpd-2.2.15-53.el6.centos.i686.rpm
C RPM-IVH apr-util-ldap-1.3.9-3.el6_0.1.i686.rpm
B RPM-IVH apr-util-1.3.9-3.el6_0.1.i686.rpm
A RPM-IVH apr-1.3.9-5.el6_2.i686.rpm
D RPM-IVH httpd-tools-2.2.15-53.el6.centos.i686.rpm


  1. Start the httpd service
    Service httpd Start
    If the browser is slow to access, please check if your firewall is not turned off.
    setup-> firewall->* Remove to save
  2. Yum command installs RPM package without Yum package Yum is RPM's online automatic installation method
    Yum-y Install package Name
    Install installation
    -Y Auto Answer Yes
    Yum-y Remove Package name unload
    YUM-Y Update package name updates
    Yum List view all packages that can be installed
  3. Use the disc as your source address for Yum Source (very focused very focused very focused very focused very focused very focused)
    1. cd/etc/yum.repos.d/
    2. MV Centos-base.repo Centos-base.repo.bakcentos-base.repo Network Source The action above is to disable Yum's network source
  4. Mount/dev/sr0/mnt/cdrom (if not mounted please enter this command if it is already mounted please ignore)
  5. Vim/etc/yum.repos.d/centos-media.repo
    [C6-media] # yum Source name
    name=centos-$releasever-media #yum源说明
    baseurl=file:///media/centos/#指定yum源地址
    file:///media/cdrom/
    file:///media/cdrecorder/
    Gpgcheck=1 # Yum source validation is in effect
    Enabled=0 # Yum in effect
    Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6
    Change the above content to the following
    [ C6-media]
    name=centos-$releasever-media
    baseurl=file:///mnt/cdrom/
    file:///media/cdrom/
    file:/// media/cdrecorder/
    gpgcheck=1
    enabled=1
    gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-6
    Save and exit the file after you change
  6. do an experiment to test whether the Yum source has changed successfully yum-y install GCC (gcc is C language compiler does not install GCC source package)
    D) source package installation
    1. upload package
      Use Remote Tools such as WINSCP to connect Linu X transfer file
      Experiment upload httpd
    2. Install (key focus)
      a) Unzip
      TAR-ZXVF file name
      B) CD into the Unzip directory
      CD into the unzip directory
      C) View installation documentation (learn)
      INSTALL
      README
      D) Detect
      ./configure--prefix=/usr/local/apache2
      --prefix= Two spaces cannot appear in the middle of the space
      function:
      1. Detection system Environment Declare makefile file
    3. define software options
      --prefix specify software installation directory
      E) Compile
      make
      If compilation fails use make clean empty compile file
      F) Install
      make Insta LL
      Error judgment:
      First: Whether the installation process stops
      Second: Where to stop error warning such an error message
  7. Start
    /usr/local/apache2/bin/apachectl start
    Note the following error is 80 port is occupied
    (98) Address already in use:make_sock:could not bind to address [::]:80
    (98) Address already in use:make_sock:could don't bind to address 0.0.0.0:80
    No listening sockets available, shutting down
    Unable to open logs
    The solution is to start the Apache you want to open immediately after restarting the computer.
    How to change the following error
    Httpd:could not reliably determine the server ' s fully qualified domain name, using Localhost.localdomain for ServerName
    The configuration file
    Vim/usr/local/apache2/conf/httpd.conf's content is about 97 lines to remove the previous #
    #ServerName www.example.com:80
  8. Unloading
    Delete the installation directory directly
    Rm-rf/usr/local/apache2
    Problem:
    1. What kind of service can change the port number
    If the service is accessible to a large number of clients, we do not recommend modifying the port number because you cannot find it after you change it.
    If the service is just for your own use we recommend modifying the port number for security reasons
  9. We have installed an Apache RPM package we use the source package also installed an Apache can do?
    Answer: Can be because the location of the installation is not the same
    RPM package is installed in the system default location
    Source package installed is our manual installation of the location
  10. Can I start two Apache services?
    Answer: cannot only open one because 80 port is occupied
  11. Where does the source package get
    Where to get the RPM package
    RPM Package gets from CD
    Source packages are available from the official website
    www.apache.org
    Www.php.net
    linux.cn Linux China


System Management and network management
User and User group management
User information file:/etc/passwd View all Users
Shadow files:/etc/shadow See which users have passwords
Group information file:/etc/group See which user groups are in the system


    1. Add user
      Useradd User Name
    2. Set Password
      passwd User Name
      Yes to write user name does not write user default change root password
    3. Delete User
      Userdel-r User Name
      -R with Home directory delete
    4. Add Group
      Groupadd Group Name
    5. Delete a group
      Groupdel Group Name
    6. Add an existing user to the group
      GPASSWD-A User Name Group name--Join the user to the group
      GPASSWD-D User Name Group name--Remove the user from the group
    7. SU User name--Switch User identity
      Process Management
      Process Management three main tasks
      1. Determine Server health status
        Memory/cpu 70/90 Security Range
    8. View all running
      A) legitimate processes occupy resources
      b) Illegal processes occupy resources
    9. Forcing the process to terminate


First, Process view


    1. PS aux view all running of the current system
      -a show all foreground processes
      -U Display user name
      -X shows all background processes
      A. User: username
      B.PID: Process ID
      C.%cpu:cpu occupancy percentage
      D.%mem: percent in existence
      E. Command: Conduct itself
      The foreground process is not ready to be manipulated after you have to wait for it to finish.
      Background process does not need to wait for the end to be able to operate again command background process use need to add &
    2. Pstree Viewing the process tree
      -P View PID


Two



Learn about Linux


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.