20165322 preparatory work 3 Linux installation and learning

Source: Internet
Author: User
Tags bz2 parent directory rar

Linux Installation and Learning installation section

Since it was the first time I had knowledge of the virtual machine, I didn't know much about it, so I chose to follow the teacher's tutorial to install the VBox virtual machine completely.
The virtual machine installation process is very smooth, not to do a detailed explanation.

Problems that arise
    • There was a problem when I started my new virtual computer. The problem is shown below

I got the help of the school sister after Baidu. Enter the BIOS, select the Intel Uirtual technology in the configuration, and save the disabled to Enabled.

    • I see an installation failure when I install the enhanced feature. The problem is shown below

After a long struggle to find the data ... Well, I found that I was careless when I started a new virtual computer, I chose the version as 32bit, and my host system was 64bit, which caused the conflict. The re-establishment of the virtual computer will be solved successfully.

Harvest

The first independent installation of virtual machines and systems, in the beginning of knowledge according to the teacher's tutorial step by step, after encountering problems, I try to solve their own, and no rush to help others immediately, in the process of thinking, I gradually understand the relationship between the virtual machine and the system (before this is really a computer small white) in addition, and win different systems operating methods also let me feel new, Linux is not as good as win easy to understand, relatively more intuitive to show every step of the code, clearly presented in front of me. During the fake period I also based on Baidu to pull out the win in the terminal, modified do not know why they jumped off the wireless network settings.

Learning Part One, learning the ingenious Linux command learning method
    • architecture for Linux : hardware, kernel, system call, Shell (shell), library function, application.

    • ubuntu shortcut :
      ctrl+alt+t : Open terminal;
      ctrl+shift+t : New Tab;
      ALT + numeric +n : Jump tab;
      Tab : Complete terminal commands, also used in C programming;
      up key : Toggle History command;
      Ctrl + C : Interrupt program;

    • linux command :
      Command format: command [options] [arguments]

    • man command :
      Manual (Manual, Guide), you can use the man Man command to view Help, where man-k is used to search for keywords To find what you want, based on the matching numbers. You can then use man-f to view the command's basic functionality.

    • cheat Command :
      It looks interesting, but ... Well, see the teacher's explanation confused, or honest installation hands-on operation.
      Prompt me when installing unable to get lock/var/lib/dpkg/lock-open (11: Resource is temporarily unavailable) , probably when I was playing. What command was executed halfway? Orz. Enter the instruction sudo rm/var/lib/dpkg/lock force to terminate it, hope not to leave any sequela.

    • Other core commands :
      Find Find file path
      Locate Swift version find
      grep Full-text search for files
      whereis , which find the command tool where it is installed.

II. Introduction to Linux Systems
    • Component (see above), history profile, key figures

    • Linux is open source free software, with some software quality and experience lacking. Security is higher than Windows. The operation is difficult to get started, but highly efficient.
    • About Learning Linux: At this stage it's still a fresh attempt and touch, and it's unclear what you're going to do with it. But I very much agree with the teacher said the importance of playing a good foundation, the concept of practical operation to understand the thorough understanding of the application, I think more secure.

Iii. Basic concepts and operations
  • Terminal concept : essentially corresponds to the/dev/tty device on Linux, the default provides 6 pure command line interface of the terminal, on the physical machine system you can use [Ctrl]+[Alt]+[F1]~[F6] to switch, by pressing [Ctrl]+[Alt]+[F7] to switch back to the GUI.

  • Shell Shell : He is our intermediate program to communicate with the system, and also the scripting language of the control system.
  • command-line actions : touch Create a file, cd enter a directory, pwd view the current directory, other commands can be seen in the Linux command Daquan
  • important shortcut keys :
    Ctrl+d: keyboard input end or output terminal
    Ctrl+s: Pause the current program and press any key to resume operation
    Ctrl+z: Keep the current program running in the background
    fg: Background Run program recovery foreground
    Ctrl+a: The cursor moves to the input wardrobe, which is equivalent toHome
    Ctrl+e: The cursor moves to the end of the input line, equivalent toEnd
    Ctrl+k: Delete from the cursor position to the end of the line
    Alt+Backspace: Delete a Word forward
    Shift+PgUp: Scrolls the terminal display up
    Shift+PgDn: Scrolls the terminal display down
  • Wildcard: A wildcard is a special statement that has an asterisk (*) and a question mark (?) to make a fuzzy match to a string (such as a file name, parameter name).
  • Shell wildcard characters :
    *: Match 0 or more characters
    ?: matches any one character
    [list]: matches any single character in the list
    [!list]: Matches characters other than any single character in the list
    [c1-c2]: matches any single character in the C1-C2
    {string1,string2...}: Match string1 or string2 (...) One string
    {c1,c2,...}: matches all characters in the C1-C2

Iv. User and file Rights management
  • View User : Enter whoami , output the first column is the current pseudo-terminal user name, the second row pts/数字 represents the open pseudo-terminal sequence number, the third column represents the start time of the current pseudo-terminal.

  • Who command :
    -a: Print all that can be printed
    -d: Print the Dead process
    -m: and am i , mom likes same
    -q: Print the number of currently logged in users and user name
    -u: Print current logged in user login information
    -r: Print Run Level

  • To create a user :

    In a Linux system, the root account has the supremacy of the entire system, such as new/added users.

    This command is required for sudo.

    Create a new User:$ sudo adduser 用户名
    Add users to the system and create a home directory for new users by default:
    $ ls /home
    To toggle a new User:$ su -l 用户名
    Then enter the password ... Exit the user and exit the terminal method consistently.

  • User Groups :
    Use the groups command to 用户名:用户组 view the cat /etc/group file directly, or use the command. Users need to join the sudo group to get root privileges, as follows:

    $ su shiyanlou # 此处需要输入shiyanlou用户密码$ groups lilei$ sudo usermod -G sudo lilei$ groups lilei
  • To Delete a user :$ sudo deluser 用户--remove-home

  • To View file permissions :
    File type:Linux everything is file.
    File permissions: A directory with read and Execute permissions to open and view internal files, and a directory with Write permission to allow other files to be created in it.
  • lsCommon uses of commands:
    ls: Lists and displays the files in the current directory
    -A: Displays . all files except (current directory) and .. (top level directory), including hidden files ( . files that start with Linux are hidden).
    -Al: View the full properties of a directory
    -dl<目录名>: Show all file sizes
    -AsSh: Small s for display file size, large S to sort by file size, available man knows how to sort by other means

  • Change file owner :$sudo chown <新所有者> <文件名>
  • Modify file Permissions :
  • mode 1:2 binary digit representation

    rwxCorresponding owner, owning user group, other users
    $ chmod 数字 文件名
  • Mode two: Add and subtract assignment operation
    g, as o well as u the group, others, and user, respectively, + and to - Add and remove corresponding permissions
    $ chmod go-rw 文件名

  • adduser with the useradd difference :

    Useradd, Userdel This kind of operation is more like a kind of command, the execution is finished to return. And adduser more like a program, you need to enter, determine a series of operations.

V. Basic operation of Linux directory structure and files
  • FHS Standard

  • Four forms of interaction of the catalogue

  • Target path
    There are also paths to disks and folders in Windows. In Linux, cd you can switch directories by using commands. -represents the last directory, usually the current user's home directory.
  • Absolute Path :
    The full path from the root "/" directory to the end of the directory you want to go to. This is similar to the path that Windows chooses when we download the software.
  • relative path :
    Start with the current directory . and end with the directory you want to go to. Use the pwd command to get the current path (absolute path).
  • New File :
    Create a new blank file because you do not have permissions in other directories, so you need to cd ~ switch back to the user's /home/用户名 directory first
  • New directory :
    Use the Make mkdir directories command to create an empty directory, or you can specify a permission attribute to create a directory. Using -p parameters to create the parent directory at the same time (if the parent directory does not exist), we create a multilevel directory at the same time (this is useful when installing the software and configuring the installation path). Effect is$ mkdir -p father/son/grandson
  • To copy a file :
    Use cp the (copy) command to copy a file to the specified directory.$ cp test(文件名) father/son/grandson(路径)
  • To copy a directory :
    To successfully replicate the directory, you need to add -r or -R parameter, which means recursive replication.$ cp -r father family
  • To delete a file :
    Use rm the command to delete a file, with the -f ability to force delete parameters.
  • To Delete a directory :
    The addition or parameter is required to successfully delete the directory -r -R .
  • To move a file :
    Use the mv command to move the file (cut).mv 源目录文件 目的目录
  • To rename a file :
    mv 旧的文件名 新的文件名, rename Batch Rename
  • To view files :
    cat: Positive sequence display print file contents to standard output (terminal), plus -n parameter display line number
    tac: Reverse print file contents to standard output (terminal)
    nl: Add line number and print, cat -n more professional line number Print command
  • Using more and less commanding paging to view files
    Used to read files. When turned on, only one screen is displayed by default, and the bottom of the terminal shows the current reading progress. You can use the key to scroll Enter down Space a line, scroll down one screen with the key, press h show Help, q exit.
  • Use head and tail commands to view files
    View only the first few lines of the file (the default is 10 lines, less than 10 lines show all), and the tail lines.
  • View File Types : Use file commands to view the types of files

VI. environment variables and file lookups
  • Variable
    declare: Create a variable
    =: assignment operator
    echo& $ : Read the value of a variable, the $ symbol is used to denote a value that refers to a variable
    Variable name: Not any form of variable name is available, variable names can only be English letters, numbers, or underscores, and cannot begin with numbers .

  • Environment variables
  • Determine environment variable : The child process in the current process is valid for the environment variable, otherwise it is not.
  • commands related to three environment variables :
    set: Displays all variables of 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 allows the command to run in the specified environment.
    export: Displays a variable that is exported from the Shell to an environment variable and can also be exported to an environment variable by it.
  • The environment variable is permanently active :
    /etc/bashrcand /etc/profile , respectively, they store shell variables and environment variables. If you want to add a permanently active environment variable, just open the/etc/profile and add the environment variable you want at the end.

  • Add a custom path to the "path" environment variable
    Be sure to add a custom path to the environment variable using an absolute path PATH :$PATH=$PATH:/home/shiyanlou/mybin
    >>: Indicates that standard output is redirected to a file in Append mode
    >: Is redirected to a file in a overwritten manner
  • Variable modification

  • variable deletion : unset Delete an environment variable with a command

  • make the environment variable effective immediately :
  • $ source .zshrc(配置文件)
  • $ . ./.zshrc(The following file must specify the full absolute or relative pathname)
  • Search for files :
    whereisSimple and fast: queries directly from the database, only binary (-B), man help (-M), and source code (-s).
    locateFast and full: Manually execute the updatedb command once to update its lookup object-the "/var/lib/mlocate/mlocate.db" database, which can be used to find different file types under the specified directory.
    whichSmall and fine: which is typically used to determine whether a specified software is installed, because it only searches for commands from the path specified by the PATH environment variable
    findFine and fine: it can be searched not only by file type, filename, but also by attributes of the file (such as file timestamp, file permissions, etc.). The first parameter of find is the place to search:$ sudo find /etc/ -name 文件或目录

    Note the path to the Find command is the first parameter, and the basic command format is find [path] [option] [action].

  • time-related command parameters :
    -atime: Last Access time
    -ctime: Last time the file content was modified
    -mtime: Last time the file properties were modified

  • number of days commands associated with these parameters (example with-mtime parameter)
    -mtime n: N is a number, expressed as a modified file "within one day" before N days
    -mtime +n: Lists files that have been modified before n days (not including the N-day itself)
    -mtime -n: Lists files that have been modified within n days (including the N-day itself)
    -newer file: File is an existing document, listing the new file name
  • list files in the home directory that have changed in the day (within 24 hours) :
    $ find ~ -mtime 0
  • list the new files in the user home directory than the Code folder :
    $ find ~ -newer /home/shiyanlou/Code

Vii. Document Packaging and compression
  • Common common compressed package file formats
    *.zipZip program to package compressed files
    *.rar: RAR Program Compressed file
    *.7z: 7zip Program Compressed files
    *.tar: Tar program packaged, uncompressed files
    *.gz: gzip (GNU Zip) compressed files
    *.xz: XZ Program Compressed file
    *.bz2: BZIP2 Program Compressed files
    *.tar.gz: Tar packaging, gzip program compressed files
    *.tar.xz: Tar package, XZ program compressed files
    *tar.bz2: Tar package, bzip2 program compressed file
    *.tar.7z: Tar package, 7z program compressed files
  • Some parameters :
    -r: Indicates that recursive packaging contains the entire contents of subdirectories
    -q: expressed as Quiet mode
    -o: Indicates the output file, followed by packaging the output filename immediately thereafter
    -O: You can specify the encoding type when extractingunzip -O GBK 中文压缩文件.zip
    du: View the default compression level, the lowest, the highest compression level, and the size of the uncompressed file (which means the depth of the file being viewed in a way that is $ du -h -d 0 *.zip ~ | sort -h expressed as human readable -d )
    -x: Excludes the zip file we created last time, otherwise it will be packaged in a compressed file. $ zip -r -9 -q -o shiyanlou_9.zip /home/shiyanlou -x ~/*.zip Set the compression level to 9 and 1 (9 max, 1 min) to use only absolute paths
    -e: Create an encrypted package
    -l: Convert LF to CR+LF, exclude open on Windows system looks like there is no line break problem
  • Zip compression wrapper :
    Package: Zip package output file name. zip-Packaged Directory (directory please add-r parameter)

  • Zip decompression
    Unpacking: Unzip Something.zip (unzip Sth. To the current directory)
  • RAR Packaging Compression Command
  • RAR command Parameters No-, if added will error
  • To delete a file from the specified compressed package file:$ rar d shiyanlou.rar .zshrc
  • To view the unresolved files:$ rar l shiyanlou.rar
  • Use unrar unzip rar file: $ unrar x shiyanlou.rar (full path decompression); $ mkdir tmp $ unrar e shiyanlou.rar tmp/ (remove path decompression)

  • Tar Packaging tools
  • Package: TAR-ZCVF Something.tar Something
  • Unpacking: TAR-ZXVF Something.tar
  • Specify path:-C parameter
    Compressed file format: Parameters
    *.tar.gz:-z
    *.tar.xz:-J
    *tar.bz2:-j
  • Some parameters:
    -c: Create a tar package file
    -f: Used to specify the file name to be created, note that the file name must be immediately -f after the parameter
    -p: Preserves absolute path characters
    Unpack a file ( -x parameter) to an existing directory (parameter) of the specified path -C :$ tar -xf shiyanlou.tar -C tardir
    To view only the unresolved package file-T parameter:$ tar -tf shiyanlou.tar

Viii. file system operations and Disk Management
  • To view the capacity of a disk
  • df: View the capacity of a disk
  • Parameters for enhanced readability -h :$ df -h

  • To view the capacity of a directory
  • du: View the capacity of a directory
  • Parameters for enhanced readability-h
  • Specify the depth of the view directory -d :

  • Common parameters:
    -a: Same--all Displays the size of all files in the directory
    -s: Show totals only for the same--summarize, only the last plus total value is listed
  • Create a virtual disk
  • ddCommands: For converting and copying files, you can also read files or write to them. Its command-line option format is 选项=值 . You can if change the standard input and output with the options (input file, enter files) and of (output file).
  • To create a virtual image file using the DD command:
    Create an empty file with a capacity of 256M from the/dev/zero device:
    $ dd If=/dev/zero of=virtual.img bs=1m count=256
  • Format a disk with the MKFS command
    Format our disk image as a Ext4 file system:
    $ sudo mkfs.ext4 virtual.img (disk)
    Linux Supported file systems:

  • Mount a disk to a directory tree using the Mount command
    mount: The mount instruction tells the operating system that the corresponding file system is ready to be used, and that the filesystem corresponds to a specific point (called a mount point). Mounted files, directories, devices, and special files can be used by users.
    The general format of the Mount command is as follows:
    mount [options] [source] [directory]
    Some common operations:
    mount [-o [操作选项]] [-t 文件系统类型] [-w|--rw|--ro] [文件系统源] [挂载点]
  • Uninstalling mounted disks using the Umount command
    $ sudo umount/mnt
  • Partitioning a disk using Fdisk
    Enter disk partition mode:
    $ sudo fdisk virtual.img

Ix. Help commands under Linux
    • Built-in commands and external commands
    • The result is that the built-in command, as stated above, is builtins in the bash source. def
      xxx is a shell builtin
    • The result is an external command, as stated above, the external command is in/usr/bin Or/usr/sbin, etc.
      xxx is /usr/sbin/xxx
    • If you get the result of alias, it indicates the name set by the command alias.
      xxx is an alias for xx --xxx

    • Help command
    • Ubuntu Environment Base has the help command built-in and can be used directly
    • The help command is a brief aid for displaying a shell built-in command, but can only be used to display help for the built-in command
    • ls --help: The external command basically has a parameter--help
    • Man command
    • You can also get more information about the program and more features of Linux by looking at the man in the system documentation
    • After opening the manual we can go up and down through PgUp and PgDn or up and down, can press Q to exit the current page
    • Man Manual Chapter

    • Info command
      Man and info are like two collections, they have an intersection part, but compared with man, the info tool can display more complete GNU tool information.

20165322 preparatory work 3 Linux installation and learning

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.