20165236 Guo Jintao Preparatory work 3 Linux installation and learning

Source: Internet
Author: User
Tags bz2 first string gz file parent directory rar file permissions

Linux installation process encountered problems 1, the Linux installation process does not have the Ubuntu (64-bit) option (My Computer is 64-bit)?? Workaround:The reason is that there is no open Blos, each computer has a way to enter the Blos, to the HP computer, for example, into the Blos method is to press the power button to start the computer, when the screen is just light, keep clicking the F10 button, you can enter the Blos interface, and then open Blos according to the options can be.

    • 2, encountered the problem of Figure 2

?? One of the reasons for this is that Blos is not turned on, possibly because the security software installed on the computer disables virtualization, and the workaround is to exit the security software and try again.

3. Problems with figure 3 when installing enhanced features

?? This is when we install the enhancement function when the terminal input the relevant command when the input error after the terminal wants to reinstall, the result appears in Figure 3 problem, because you have loaded the disc so need to eject the disc reload, pop-up method is on the Linux desktop selected disc icon left click to select Pop-up.

    • Linux Learning? Chapter One Introduction to Linux

This article mainly introduces the basic concepts of operating system, the history of Linux, the differences between Linux and Windows, and other introductory knowledge.

In this chapter, I see the whole process of Linux development is the countless computer genius of the continuous efforts to promote, with a lot of advantages.

Compared to Windows, its advantages are also obvious

Free use

High safety

High efficiency

Customizable

Wide Application scope

During the Spring Festival, I happened to also go to see a movie--------------2, one fragment of which is the Linux system blowing marvellous, can learn Linux is also very happy.

Chapter II Basic Concepts and operation

Some knowledge of the following:

Usually when we use Linux, we do not deal directly with the system, but through an intermediary program called the shell.

The Shell under the Linux operating system is both the interface of user interaction and the scripting language of the control system.

The Ubuntu terminal uses bash by default.

Create a filetouch file

Go to Catalogcd /etc/

View current directorypwd

Common shortcut keys

Ctrl+d
button function
tab Command completion
Ctrl + C forcibly terminate current program
keyboard input end or exit terminal
ctrl+s Pause the current program, pause and press any key to resume running
Ctrl + Z run the current program in the background and revert to the front desk for command FG
Ctrl + A move the cursor to the input outfit, equivalent to the home key
ctrl+e moves the cursor to the end of the input line, equivalent to the end key
ctrl+k Delete from cursor position to end of line
alt+backspace Delete one word forward
shift+pgup Scroll terminal display up
shift+pgdn Scroll the terminal display down
History input Command

Shell Common wildcard characters

character meaning
* Match 0 or more characters
? Match any one character
[List] Match any single character in the list
[!list] Matches a character other than any single character in the list
[C1-C2] Match any single word in c1-c2 such as: [0-9] [A-z]

{String1,string2,...} Match string1 or string2 (or more) one string
{C1.. c2}| Match all characters in c1-c2 such as {1..10}

Banner Main program

Installation

update$ sudo apt-get install sysvbanner

Print

$ banner shiyanlou

Font Change

$ printerbanner -w 50 A

This chapter job:

Chapter III User and file Rights management
    • View User
      $ who am i
      $ who mom likes
    • Who command
Parameters Description
-A Print all that you can print
-D Print the Dead process
-M With AM I,mom likes
-Q Print the current number of logged-in users and user names
-U Print current logged in user login information
-R Print Run level
    • New user$ sudo adduser lilei
    • Switch login User$ su -l lilei
    • Exit exit orCtrl+d
    • See which user groups you belong to

      1.groups command$ groups shiyanlou

      2. View/etc/group/file$ cat /etc/group | sort
      Filter information$ cat /etc/group | grep -E "shiyanlou"

    • Add another user to the sudo user group

$ su shiyanlou $ groups lilei$ sudo usermod -G sudo lilei$ groups lilei
    • Delete User$ sudo deluser lilei --remove-home
    • Change file Owner

      $ cd /home/lilei$ ls iphone6$ sudo chown shiyanlou iphone6
    • Modify file Permissions
      $ chmod 700 iphone6
      $ chmod go-rw iphone6

This chapter job

Fourth Linux directory structure and file basic operation
    • The difference between a Linux directory and a Windows directory
    1. Linux is directory-based and Windows is based on storage media
    • FHS Standard
    • Directory path
    1. Go to the top level directory$ cd ..
    2. Go to your home directory$ cd ~
    3. Get the current directory using PWD$ pwd
    • Absolute path: The full path from the root "/" directory to the end of the directory you want to go to
    • Relative path: In the current directory. As the starting point, to the end of the directory you want to go to
    • Basic operations for Linux files
    1. new Blank document   Touch command
    2. new directory   mkdir command, use -P to create parent directory simultaneously, example $ mkdir-p Father/son/grandson
    3. copy file   CP Command, example $ CP Test Father/son/grandson
    4. copy directory, CP plus -R or -R , example $ cp-r Father family
    5. Delete file: rm , Force delete -F
    6. Delete directory: RM Command plus -R or -R
    7. Moving files: mv , example

       $ mkdir documents$ mv file1 documents      
    8. renaming files: $ mv file1 myfile
    9. Batch rename:

# 使用通配符批量创建 5 个文件:$ touch file{1..5}.txt# 批量将这 5 个后缀为 .txt 的文本文件重命名为以 .c 为后缀的文件:$ rename ‘s/\.txt/\.c/‘ *.txt# 批量将这 5 个文件,文件名改为大写:$ rename ‘y/a-z/A-Z/‘ *.c
    1. View the file, cat tacnl
    2. Page view File more ,less
    3. View file types, example$ file /bin/ls
    4. Edit File, example$ vimtutor

This chapter job

Chapter fifth environment variables and file search
    • Creating variables$ declare tmp
    • Assigning values to variables$ tmp=shiyanlou
    • Read the value of a variable$ echo $tmp
    • Environment variables

Commands related to environment variables: set ,, envexport

Command Description
Set Displays all variables for the current shell, including the built-in environment variables (related to shell appearance, etc.), user-defined variables, and exported environment variables.
Env Displays the environment variables that are relevant to the current user, and lets the command run in the specified environment.
Export Displays variables that are exported from the Shell to an environment variable, and can also be exported to an environment variable by it.

    • Permanent effect

The Linux variables are divided into, permanent and temporary.
/etc/bashrcStore Shell variables

/etc/profileenvironment variable, permanent effect

    • The lookup path and order of the command
    1. View PATH Environment variables$ echo $PATH
    2. Create a shell script file$ gedit hello_shell.sh
    3. Add executable permissions to a file$ chmod 755 hello_shell.sh
    4. Execute script$ ./hello_shell.sh
    5. Create a C language "Hello World" program$ gedit hello_world.c
    6. Use GCC to generate executables after saving$ gcc -o hello_world hello_world.c
    7. Create a directory and move the file to it, for example:

      $ mkdir mybin$ mv hello_shell.sh hello_world mybin/
    • Add a custom path to the ' path ' environment variable

Add a custom path$ PATH=$PATH:/home/shiyanlou/mybin
Add content$ echo "PATH=$PATH:/home/shiyanlou/mybin" >> .zshrc

  • Modify and delete an existing variable
    1. Variable modification
    How variables are set Description
    ${Variable name # Match string} Start the match from the back to delete the shortest data matching the matched string
    ${variable name # #匹配字串} Start the match from the back to delete the longest data matching the matched string
    ${variable name% matching string} Match from tail forward to delete the shortest data matching string
    ${variable name percent match string} Match from tail forward to delete maximum data matching string
    ${variable name/old string/new string} Replace the first string that matches the old string with a new string
    ${variable name//old string/new string} Replace all strings that match the old string with a new string
    1. Variable deletion$ unset temp
  • How to make an environment variable effective immediately
    1. sourceCommand, example$ source .zshrc
    2. sourceAlias of the command . , example$ source .zshrc
  • Search for files
    1. whereisSimple and quick, example$ whereis who
    2. locateFast and full, examples $ locate /etc/sh ,$ locate /usr/share/\*.jpg
    3. whichSmall and fine, example$ which man
    4. findFine and thin, for example$ sudo find /etc/ -name interfaces
    5. Time-related command parameters
    Parameters Description
    -atime Last Access time
    -ctime Last time the file content was modified
    -mtime Last time the file properties were modified

This chapter job

Sixth. Document packaging and compression
    • Common Compressed Package file format
file suffix name Description
*.zip Zip program to package compressed files
*.rar RAR Program Compressed files
*.7z 7zip Program Compressed Files
*.tar Tar program packaging, uncompressed files
*.gz Gzip (GNU Zip) compressed files
*.xz XZ Program Compressed Files
*.bz2 BZIP2 Program Compressed Files
*.tar.gz Tar packaging, gzip program compressed files
*.tar.xz Tar packaging, XZ program compressed files
*tar.bz2 Tar package, BZIP2 program compressed files
*.tar.7z Tar pack, 7z program compressed files
    • Zip
    1. Use the Zip Package folder, for example:

      zip -r -q -o shiyanlou.zip /home/shiyanlou$ du -h shiyanlou.zip$ file shiyanlou.zip
    2. To set the compression level package, for example:

zip -r -9 -q -o shiyanlou_9.zip /home/shiyanlou -x ~/*.zip$ zip -r -1 -q -o shiyanlou_1.zip /home/shiyanlou -x ~/*.zip

viewing compressed file information$ du -h -d 0 *.zip ~ | sort

    1. Create an encrypted ZIP package
zip -r -l -e -o shiyanlou_encryption.zip /home/shiyanlou
    1. Unzip the file$ unzip shiyanlou.zip
    2. Quiet mode decompression$ unzip -q shiyanlou.zip -d ziptest
    3. View the contents of a compressed package with no pressure$ unzip -l shiyanlou.zi

Specifying the encoding typeunzip -O GBK 中文压缩文件.zip

    • rar
    1. Installation Tools
update$ sudo apt-get install rar unrar
    1. Create a compressed package or add a file to a compressed package from a specified file or directory
$ rm *.rar$ rar a shiyanlou.rar .
    1. deleting files
$ rar d shiyanlou.rar .zshrc
    1. View unresolved files
$ rar l shiyanlou.rar
    1. Full path decompression
$ unrar x shiyanlou.rar
    1. Go to the Path decompression
$ mkdir tmp$ unrar e shiyanlou.rar tmp/
    • Tar (most commonly used)
    1. Create a tar Package
$ tar -cf shiyanlou.tar ~
    1. Unpacking a file to a specified directory
$ mkdir tardir$ tar -xf shiyanlou.tar -C tardir
    1. View only unresolved package files
$ tar -tf shiyanlou.tar
    1. Preserve file attributes and follow links
$ tar -cphf etc.tar /etc
    1. gzip Compressed Files
$ tar -czf shiyanlou.tar.gz ~
    1. Unzip the *.tar.gz file
$ tar -xzf shiyanlou.tar.gz
    1. Other formats
compressed file format Parameters
*.tar.gz -Z
*.tar.xz -j
*tar.bz2 -j
Seventh. File system operations and Disk Management
    • View disk and directory capacity df commands, plus easier-to- -h read
    • ducommand to view directory capacity
Parameters function
Du-h With--human-readable, the k,m,g is the unit to improve the readability of the information.
$ du-h-D Specify the depth of the view directory
Du-a The same--all displays the size of all files in the directory.
Du-s Only the totals are displayed with--summarize, and only the last plus total value is listed.
    • Create a virtual disk

    • Create a virtual image file

if=/dev/zero of=virtual.img bs=1M count=256$ du -h virtual.img
    • Format disk
virtual.img
    • Hanging on disk to the directory tree
    1. To view a file system that is already mounted$ sudo mount
    2. Mount the real disk to the directory treemount [options] [source] [directory]
    3. Common operationsmount [-o [操作选项]] [-t 文件系统类型] [-w|--rw|--ro] [文件系统源] [挂载点]
    4. Cases:
virtual.img /mnt # 也可以省略挂载类型,很多时候 mount 会自动识别# 以只读方式挂载$ mount -o loop --ro virtual.img /mnt# 或者mount -o loop,ro virtual.img /mnt
    • Uninstalling mounted Disks$ sudo umount /mnt
    • Partitioning a disk
      1. View hard disk partition table information$ sudo fdisk -l
      2. Enter disk partition mode$ sudo fdisk virtual.img
      3. pView Results
    • Establishing an associated command for mirroring and loopback devices losetop
      The steps are as follows:
    1. See all loopback devices$ sudo losetup /dev/loop0 virtual.img
    2. Unlock Device Association$ sudo losetup -d /dev/loop0
    3. Installation kpartx Tools

      $ sudo apt-get install kpartx$ sudo kpartx -av /dev/loop0# 取消映射$ sudo kpartx -dv /dev/loop0
    4. Formatting
    5. Create a new four empty directory to mount the virtual disk:

/media/virtualdisk_{1..3}# 挂载磁盘分区$ sudo mount /dev/mapper/loop0p1 /media/virtualdisk_1$ sudo mount /dev/mapper/loop0p5 /media/virtualdisk_2$ sudo mount /dev/mapper/loop0p6 /media/virtualdisk_3# 卸载磁盘分区$ sudo umount /dev/mapper/loop0p1$ sudo umount /dev/mapper/loop0p5$ sudo umount /dev/mapper/loop0p6
    1. $ df -hCommand Check Results

This chapter job

Eighth. Help commands under Linux
      • Built-in commands and external commands
        1. Built-in command: Part of a shell program that contains simple Linux system commands that do not need to create sub-processes and execute faster than external commands
        2. External command: The utilities section of the Linux system contains a large number of programs, and the command execution process is controlled by the shell
        3. Differentiate built- type in commands and external commands with commands

          type exittype service
      • Help command
        1. This command is built into bash
          Get ready:
        2. Built-in commandshelp ls
        3. External commandls --help
      • Man command (no distinction between built-in and external commands)--man ls

20165236 Guo Jintao Preparatory work 3 Linux installation and learning

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.