Linux Talent Program

Source: Internet
Author: User
Tags aliases bz2 clear screen

Linux Talent Program

    • Linux Talent Program
      • Linux Application Areas
        • Linux differs from Windows
      • System partition Type
        • Partition device file name and mount
          • Linux Tree-shaped structure
          • Mount
        • CentOS 63
      • Common commands
        • Querying content in a directory
        • File processing commands
          • Additional Help commands
      • Shell Basics

1.Linux Application Areas
    • Enterprise Server aspects

      Www.netcraft.com Detection Website Background Service related information (foreign site)

    • Embedded application aspects

      Android xxxsshd remote security Management (QUICKSSHD)

Linux differs from Windows
    • Linux is strictly case sensitive
    • All Linux content is saved as a file, including permanent hardware presence
    • Do not rely on extensions to differentiate files from permissions
File Type Extended Name
Compress files . gz. bz2. tar.bz2. tgz
Binary Packages . rpm
Script file . sh
Configuration file . conf
    • Application different environments
2. System partition Type
    • Primary partition: Can only have up to four
    • Extended partition:
      There can be at most one
      Primary partition plus extended partition up to four
      Cannot write data, only logical partitions are included
    • Logical partition:
      Formatting writes specific data to a specific area of the disk, dividing a partition into disk space for file allocation tables, directory tables, etc. for file management
Partition device file name and mount Created with Rapha?l 2.1.0 Partitioning Formatting device file name for each partition Assign drive letter Linux Tree-shaped structure

/root directory Dev Hardware Device
HD[A-D]: IDE
SD[A-P]: SCSI/SATA/USB disk
CDROM or HDC: optical drive
FD[0-1]: Floppy disk
LP[0-2]: Printer (25-pin)
/USB/LP[0-15]: Printer (USB)
Mouse: Mouse

Mount * * The process of connecting the drive letter and partition together, the directory is called the mount point (equivalent to the drive letter of Windows) * * Directory as drive letter/root partition swap partition CentOS 6.3
手动分区    home boot swap / 安装方式    Basic Server    推荐分区 /boot 启动分区(200M)
**xshell**
    • First, use ifconfig eth0 down in Linux to turn off the NIC
    • Then use ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up restart NIC to manually configure IP
    • Or use the Setup tool to configure the IP address

Configuring connection information in Xshell

Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Onboot=yes//whether to boot with boot

3. Common commands

Command basic format

# 管理员用户 $ 普通用户/root   /home/other命令 [选项] [参数]... vi‘‘‘
1. Querying the contents of a directory
      ls [选项]        -a 显示所有文件 *(包括隐藏文件 .开头文件)*        -l 显示详细信息                >- 第一列 权限*(10位基本权限)*                    -文件类型 *(-文件 d目录 l软连接(快捷方式) )*                        后九位分三组代表权限                        所有者 u                         所属组 g *相同身份或相同权限的一类用户*                        其他人 o                     r 读 w 写 x 执行                    . 代表 ACL权限            >- 第二列 引用计数(被调用 链接)            >- 第三列 所属者用户            >- 第四列 所属组            >- 第五列 大小            >- 第六列 最后一次修改时间            >- 第七列 文件名

-D View Directory properties
-H Show File size
-I display Inode

2. File processing commands
    • Directory processing commands

          建立目录 mkdir    mkdir 目录名        -p 递归创建        mkdir -p abc/def/ggg
    • Switch your directory CD

          cd 目录        cd ~ / cd 切换家目录        cd -      上次目录        cd ..     上一级目录        cd .      当前目录

relative path: Refer to the current directory
absolute Path: Specified from the root, first-level recursive lookup
Table of Contents/Command completion Tab key

  • directory where the query is located pwd (print the current location)

        删除空目录 rmdir    rmdir 目录名    删除文件或目录 rm    rm -rf 文件或目录        -r 删除目录        
  • Copy command CP

        cp [选项] [原文件或目录] [目标目录] 目标目录后加文件名改名复制 不加名 原名复制        -r 复制目录        -p 连带文件属性复制        -d 若原文件是链接文件 则复制链接属性        -a 相当于 -pdr
  • Cut command MV

        mv [原文件或目录] [目标目录]        同目录下可以改名    常见目录作用        /       根目录        /bin /sbin /usr/bin /usr/sbin   保存系统命令 (s* root用户打开)        /boot   启动目录保存启动数据        /dev    硬件文件        /etc    配置文件        /lib    函数库        /media /mnt /misc   三个空目录 作为外接存放设备的挂载 (mnt)        /proc /sys 内存的挂载点        /tmp    临时目录        /usr    系统软件资源目录        /var    系统相关文档目录
  • Link command

        链接命令 ln    ln -s [原文件] [目标文件]        生成链接文件 (引用计数加1)        -s 创建软链接        硬链接        (具有相同的i节点和存储block块,可以看成是同一个文件)        一个文件的不同接入点        通过i节点访问        不能跨分区        不能针对目录使用        软链接        (类似Windows快捷方式)        拥有自己的i节点和block块 但数据块中只保存原文件的文件名和j节点号,没有实际的文件数据        lrwxrwxrwx l软链接            软链接权限都为 rwxrwxrwx        修改任意文件,另一个都改变        删除原文件,软链接不能使用        软链接非当前目录,原文件要写绝对路径
  • File Search Command

    locate 文件名    在后台数据库中按文件名搜索,搜索速度快    /var/lib/mlocate    后台数据库     updatedb            强制更新数据库    /etc/updatedb.conf 配置文件    PRUNE_BIND_MOUNTS = "yes"   筛选规则是否生效    PRUNEFS = ""    筛选规则 (不搜索以下文件系统)    PRUNENAMES = "" 筛选规则 (不搜索以下后缀名文件)    PRUNEPATHS = "" 筛选规则 (不搜索以下目录中)
  • Command Search command

    • Whereis command name

      Search system command Path (and help document)
      -B View command location only
      -M view only the Help document location

    • Which command name

      You can view aliases in addition to the commands the
      built-in command (shell) does not have a separate execution file for example: CD
      environment variable ($PATH) no search command file , you will get an error (not found)

    • Find command

      Find [search scope] [search condition]
      Find/-name install.log root directory Search by file name
      avoid wide search br> wildcard matches, wildcard characters are exactly matched (enclosed in double quotes)
      * Any Content
      ? Any one character
      [] any one of the characters in parentheses (or)
      Find-iname #不区分大小写
      Find -user #按所有者-nouser files with no owner (junk file) kernel generated file

        find-mtime +10 (Find files modified 10 days ago) -10 10 days modified file 10 10 day modified file +10 10 days ago Modified file Atime file access time CTime change file properties MT IME modifies file contents find. -size 25k (Find file size 25K) -25k less than 25K 25k size 25K +25k greater than 25K 10M size 10M default type is fan Block (512K) \ Find. -inum 262421 (Find I node is 262421) find/etc-size +20k-a-size-50k (find files larger than 20K and less than 50K in/etc/directory)-A and logos    Series with-O or logical or find/etc-size +20k-a-size-50k-exec ls-lh {} \;  (The result of the lookup is executed with the following command to process-exec {} \; Fixed format)  
    • grep command String Search

      grep [选项] 字符串 文件名    gerp "size" anaconda-ks.cfg        -v 取反        -i 忽略大小写

      Find searches the system for eligible file names and can use wildcards for exact matches
      grep searches the file for qualifying strings, and you can use regular expressions to implement the containing match
      File name wildcard character (exact match)
      File data regular expression (contains match)

    • Help commands

      Help Command Man
      (Get help for the specified command)
      Mans LS
      Name Command Purpose
      Synopsis format
      Description Option (Simplified)
      /d can automatically jump to the first-D option
      N Jump down Shift+n jump up

      man -f 命令(查看命令级别)(相当于 whatis 命令)    man -5 passwd    man -4 null    man -8 ifconfig默认打开最小等级的命令

      Man-k command
      #找到和命令相关的所有相关信息
      #相当于 Apropos command

    Additional Help commands
  • Command name Help
    get help with command options

    help shell内部命令    (获取shell内部命令的帮助)        whereis cd        #查看是否是shell内部命令 (无可执行文件)        help cd        #获取内部命令帮助   (内部命令无法使用man单独获取帮助)info    (获取详细帮助文档)    -回车     进入帮助子页面 (带*)    -u      返回    -n      下一个帮助小节    -p      上一个帮助小节
  • Compression and Decompression commands
    common compression formats. zip. gz. bz2 |. tar.gz. TAR.BZ2

    .zip格式压缩    zip 压缩文件名 源文件    (压缩文件)    不要求,但要使用扩展名,便于区分            zip -r 压缩文件名 目录    (压缩目录).zip格式解压    unzip 压缩文件    (解压缩.zip文件).gz格式压缩    gzip 源文件    (压缩为.gz格式的压缩文件,源文件会消失)    gzip -c 源文件 > 压缩文件    (压缩为.gz文件,源文件保留)    gzip -r 压缩目录    (把目录当中的所有子文件压缩,但是不能压缩目录).gz格式解压缩    gzip -d 压缩包名    (解压缩文件)    gunzip 压缩包名    gunzip -r 解压目录.bz2格式压缩    bzip2 源文件    (压缩为.bz2格式的压缩文件,不保留原文件)        bzip2 -k 源文件        (保留源文件)        (不能压缩目录).bz2格式解压缩    bzip2 -d 压缩包名    bunzip 压缩包名    (-k 保留源文件).tar 打包文件(解决目录压缩与解压缩)    tar -cvf 打包文件名 源文件        -c 打包文件        -v 显示过程        -f 指定打包后的打包文件名    tar -xvf 打包文件名    (解压缩)

    Compression and decompression after packaging
    TAR-ZCVF compressed package name. tar.gz source File
    TAR-ZXVF Extract the package name. tar.gz
    TAR-JCVF compressed package name. tar.bz2 source File
    After compressing multiple files, separate them with spaces
    Add a path before compressing the file name to specify the compression location
    TAR-JXVF Extract the package name. tar.bz2
    -C Specify decompression location

    tar -ztvf 压缩包名tar -jtvf 压缩包名    可查看压缩包
  • Shutdown and restart command

      shutdown command shutdown [options] Time-C cancels the previous command-H shutdown-R Restart (the service and file can be saved correctly) shutdown -R 05:30 & run other shutdown commands in the background halt poweroff init 0 Other restart command reboot init 6  

    System Run level
    0 shutdown
    1 single user
    2 not fully multiuser, no NFS service (file sharing service)
    3 full multiuser (character interface)
    4 unassigned
    5 graphical Interface (X)
    6 Restart
    RunLevel #查看之前级别和当前级别
    Cat/etc/inittab
    Id:3:initdefault://define system default Run level

      exit logon command L Ogout #注销  
  • Other common commands

    • Mount command

      mount#查看系统中已经挂载的设备mount -a(根据配置文件 /etc/fstab (自动挂载) )(如果将光驱和U盘写入文件 光驱内没有光盘,U盘没有插入系统 启动就会不成功)mount [-t 文件系统] [-o 特殊选项] 设备文件名 挂载点    -t 文件系统:加入文件系统来指定挂载的类型 ext3 ext4 iso9660(光盘)等文件系统    -o 特殊选项:可以指定挂载的额外选项        exec/noexec 是否可以执行可执行文件 默认允许        remount 重新挂载已经挂载的文件系统 一般用于指定修改特殊权限    默认已经挂载好的分区 可以省略 设备文件名挂载光盘    mkdir /mnt/cdrom    (建立挂载点)    mount [-t iso9660] /dev/sr0 /mnt/cdrom    (挂载光盘 将设备文件挂载到盘符)    (默认读写权限,光盘不可写 提示权限被迫改变)卸载光盘    (必须卸载才可取出光盘)    umount 设备文件名或挂载点    umount /mnt/cdrom/挂载U盘    fdisk -l    (查看设备文件名)    mount -t vfat /dev/sdb1 /mnt/usb/    (vfat (fat32)文件系统 Linux默认是不支持NTFS文件系统)用户登录查看命令     w       (查看用户登录信息 (系统资源情况) )    who     (查看当前登录用户)    last    (查看系统中所有已登录的信息 (历史记录) )    (日志文件 /var/log/wtmp (二进制文件) 不可用vi查看 )    lastlog    (系统当中的用户最后登录时间 )    (日志文件 /var/log/lastlog )
4.shell Foundation
  • Shell overview

    System command-line interpreter (binary language) | Accept input commands to compile binary transfers to the kernel
    is also a very powerful programming language, easy to write, easy to debug, flexible.

  • Classification

    • Bourne Shell: From 1979 Unix started using the master file named sh ksh bash PSH zsh Linux standard version for bash
    • C Shell: Mainly used in BSD version of UNIX system, similar to C language CSH tcsh
      Bash compatible/etc/shells
  • How scripts are executed


    Echo Output command
    echo [options] [Output CONTENT]
    Spaces need double quotes
    -e control character (escape character) \a warning tone \b Backspace key
    Hexadecimal tab ASCII \x can be entered
    #输出颜色 "\e[1;31m ... \e[0m"
    31m Red 35m Yang Hong 32m green 33m Yellow
    Echo-e "\e[1;31m hahaha \e[0m"

    第一个脚本    hello.sh    #!/bin/bash    echo -e "\e[1;36m 天上掉下个林妹妹  \e[0m"执行权限    通过Bash调用执行脚本        bash hello.sh    赋予权限,直接执行        chmod 755 hello.sh        ./hello.sh
  • Basic features of Bash
    command aliases and shortcut keys
    (Simplified operation, easy to remember)

    Alias
    (see aliases in the system that are in effect by default)
    Alias ls= ' Ls–color=never '
    (Set alias (temporarily active) alias aliases = ' original command ')
    VI ~/.BASHRC
    (Permanent write environment variable configuration file)
    Source ~/.BASHRC recall configuration file for settings to take effect

    Unalias aliases
    (delete alias (temporary effect))

    Effective order
    1. Commands executed with absolute or relative paths
    2. Performing aliases
    3. Execute bash's internal commands
    4. The first command found in the directory lookup order defined by the $PATH environment variable

  • Common Shortcut commands
    CTRL + C forces the current command to terminate
    Ctrl+l Clear Screen
    CTRL + A cursor moves to the beginning
    Ctrl+e cursor moves to end of line
    Ctrl+u from the cursor location to the end of the line
    CTRL + Z put commands into the background
    Ctrl+r Search in the history command

  • Historical command

        history 历史命令        history [选项] [历史命令保存文件]        -c 清空历史命令        -w 把缓存中的历史命令写入历史命令保存文件 ~/.bash_history    #默认保存1000条        HISTSIZE=1000        #vi /etc/profile 环境变量配置文件    基本调用        上下箭头来重复调用        !n      来执行第n条历史命令        !!      重复执行上一条命令        !字符串 重复执行后一个该串开头的命令    Tab键        进行命令(环境变量)和目录补全(操作路径)
  • Output redirection
    (show computer processed results)
    Standard input Output
    Keyboard/dev/stdin 0 standard input
    Monitor/dev/sdtout 1 standard output
    Monitor/dev/sdterr 2 standard error Enter

    • Output redirection

      • Standard output redirection
        commands > Files
        Output the correct output of the command to the specified file or device in a way that overrides it.
        Commands >> files
        to append

      • Standard Error output redirect
        Error command 2> file
        to overwrite the error output of the command to the specified file or device.
        Error command 2>> file
        to append

      • Correct output and error output save
        commands > Files 2>&1
        Command &> file
        to overwrite the correct output and error output to a file
        command >> text 2>&1
        Command &>> file
        to append
        ls &>/dev/null (Recycle Bin)
        Command >> file 1 2>> file 2 correct append to file 1, error append to file 2

    • Input redirection
      WC [options] [file name]
      -C Statistics bytes
      -W Statistics number of words
      -l statistics rows
      Ctrl+d Interrupt Statistics

      Commands < files
      (input of a file as a command)
      Command << identifier
      (the contents of the identifier are the contents of the command)

  • Pipe character
    Sequential execution of MULTIPLE commands
    ; Command 1, Command 2 Multiple command order execution (whether or not the intermediate is saved)
    && Command 1&& command 2 logic and when command 1 is executed correctly, then command 2 will execute
    || Command 1| | Command 2 logic or when command 1 is executed correctly, then command 2 does not execute
    # ls && echo yes | | Echo No

  • Pipe character
    Command 1 | Command 2
    #将命令1的正确输出作为命令2的操作对象
    # Ll/etc | More
    # Netstat-an | grep established (server shows the number of connections)
    # Netstat-an | grep established | Wc-l (processing line number)

  • Wildcard characters
    ? Match an arbitrary character
    * 0 or any number of
    [] matches one of the characters in brackets
    [-]-Represents a range [a-z] for matching a letter
    [^] Logical non-representation matches not one character in brackets [^0-9] represents a character that is not a number

  • Other special symbols

            ‘‘  特殊符号都没有特殊意义,原样输出                ""  $ ` \ 都具有特殊意义        ``  包含系统命令 执行后赋值给变量 等同于 $()        $  用于调用变量的值 (变量名=变量值)        #   shell脚本中,#开头的行代表注释        \   转义符 跟在\之后的特殊符号失去意义,变为普通字符
1
    1. Source Class study notes?

Linux Talent Program

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.