Linux introduction and Common commands

Source: Internet
Author: User
Tags oracle vm virtualbox vm virtualbox

Linux introduction and Common commands

 

1 Linux introduction (learn more)

1.1 differences between Linux and windows

  • Linux is a regular operating system developed.
    • Server projects are deployed on the Linux operating system.
  • Windows is a civil operating system. Entertainment, audio and video, and Internet access. (Developed by small and medium-sized companies)
    • Powerful logging system and powerful desktop applications (rendering of desktop applications ).

 

1.2 Linux history and use cases

  • Linux was born in 1990s and is a Unix operating system.
    • Unix Introduction
      • Unix is a powerful multi-user, multi-task operating system.
      • Developed at Bell Labs in 1969.
      • Unix trademark rights are owned by international development standards organizations.
      • The Unix operating system is a commercial version and requires a fee. The price is more expensive than that of windows. However, there are also free versions of Unix, such as NetBSD and other Unix-like versions.
  • Linux is free and open-source.
  • Unix is charged and closed.
  • Linux is gradually replacing Unix.
  • Linux application scenarios: Server OS, mobile devices (Android phones, tablets), wireless routers, switches, and smart homes.

 

1.3 Linux

  • Linux Kernel version: Linux kernel O & M development team.
    • The source code is not open source in certain programs.
  • Linux release version: customized by major Internet/software companies.
    • Source code of peripheral style functions is completely open source.
    • RedHat, Ubuntu, and CentOS.

 

  • A kernel version has a variety of Release versions.

 

2 Linux installation [Key]

2.1 Introduction and installation of virtual machines

  • Install the Virtual Machine and install the Linux operating system through the Virtual Machine.
  • Virtual Machine: a virtual computer.

 

  • Virtual Machine Software
    • Vmware Workstation is a powerful desktop virtual computer software that charges fees. VMware is the world's leading provider of desktop-to-Data Center virtualization solutions.
    • VirtualBox is an open-source Virtual Machine Software. VirtualBox is a software developed by Innotek and developed by Sun. It is written using QT and officially renamed Oracle VM VirtualBOX after SUN is acquired by Oracle.

 

2.2 Virtual Machine and Linux Installation

  • Disable anti-virus software and firewall.
  • Use administrator permissions for installation.

 

  • Linux Installation

 

Linux:

  • Super administrator: root
  • Password: 123456 (set by yourself, at least 6 digits ).

 

2.3 Linux directory Introduction

 

 

 

  • Bin (binaries) stores binary executable files.
  • Sbin (super user binaries) stores binary executable files, which can be accessed only by the root user.
  • Etc (etce) stores system configuration files
  • Usr (unix shared resources) is used to store shared system resources.
  • Home: root directory for storing User Files
  • Root superuser directory
  • Dev (devices) is used to store device files
  • Lib (library) stores the shared libraries and kernel modules required for running the program in the root file system.
  • Install the temporary file system by the mnt (mount) System Administrator
  • Boot stores various files used for system boot.
  • Tmp (temporary) is used to store various temporary files
  • Var (variable) is used to store the files whose data needs to be changed during running.

 

  • Common Directories
    • /Linux root directory
    • The directory where the/ect system configuration file is stored. For example, firewall files, network settings files, JDK environment configuration files, and MySQL configuration files.
    • /Usr application storage directory jdk, tomcat, mysql, redis, ngnix, etc.
    • /Root system administrator root's home directory. Windows desktop.

 

3 Common commands

3.1 disk management

3.1.1 ls command

  • Ls (list) function: list Directory content
  • Format: ls [parameter] [file or directory]
    • -A or -- all: displays all files or directories. Hide files and special directories.
    • -L detailed list of Usage
    • -T sort by the change time of files and directories
    • -R reverse sorting
    • -- Help Online help
    • -H friendly prompt
      • D indicates the Directory
      • -Common File
      • L indicates the link

 

3.1.2 cd command

  • Cd (change directory) function: Switch directories.
  • Format: cd [Directory]
    • ~ : Current user directory
    • /: Root directory
    • -: Last accessed directory (only two directories can be switched to each other)
    • ...: Directory at the upper level
    • Default (cd): default current directory
    • Cd/directory: switch to the specified directory (absolute path of Linux)

 

  • Absolute path of Linux: cd/etc/t1 first switches to the/directory, then finds the subdirectory etc under the/directory, and finds the subdirectory t1 in the etc directory. You can switch between any directory at will.
  • Linux relative path: cd t1/t2 search for the sub-directory t1 in the current directory, and then find the sub-directory t2 in the t1 directory. Make sure that the current directory has a subdirectory t1.

3.1.3 pwd command

  • Pwd (print working directory): displays the current directory. Returns the absolute path.

 

3.1.4 mkidr command

  • Mkdir (make directory): Creates a directory.
    • -If the parent directory of p does not exist, create the parent directory (parents) first ).
    • -V displays the detailed information during command execution.

 

  • Create the t1 directory under the/root directory

  • Create the t2 directory under the t1 directory under the/root directory

  • Create the t3 directory under the/root directory and create the t4 directory under the t3 directory (at this time, the t3 and t4 directories do not exist)

 

3.1.5 rmdir command

  • Rmdir (remove directory): deletes an empty directory.

 

3.2 file management-file browsing command: Used to view log files, XML, properties and other files.

3.2.1 cat command

  • Cat (catenate) function: Quick display of text file content
    • Syntax: cat file, which displays all contents of a specified file.
    • Cat is suitable for viewing files with a small amount of information.

 

3.2.2 more command

  • More feature: displays the file content by PAGE, and supports direct row navigation.
    • Syntax: more files
    • Operation:
      • Enter down n rows, which must be defined. The default value is 1 row.
      • Space key scroll down one screen or ctrl + F
      • B returns the previous screen or Ctrl + B
      • Q: Exit more.

    

3.2.3 less command -- suitable for viewing large amounts of data

  • Less function: display file content by PAGE
  • Syntax: less [parameter] File
    • -M: display the percentage of more commands.
    • -N: displays the row number of each row.
  • Operation:
    • Enter down n rows, which must be defined. The default value is 1 row.
    • Space key scroll down one screen or ctrl + F
    • B returns the previous screen or Ctrl + B
    • Q: Exit less

 

3.2.4 tail command

  • The tail-numeric file name allows you to quickly view the content of X rows after the file.
  • For example, for the tail-3 file name, view the last three lines of the file.

  

3.3 file operation commands

3.3.1 cp command

  • Cp (copy): copy a file or directory.
  • Syntax: cp [parameter] [source file or directory] [target file or directory]
    • -R or -- recursive processing that processes the files in the specified directory along with the subdirectories.

 

  • Copy the/root/Demo1.java file to the/root/t1 directory. (The current location is at/root)

 

  • Copy the/root/Demo1.java file to the/root/t1 directory and change it to ddd. java (current location/root)

  • Copy the/root/t1 directory to the/root/t5 directory (the current location is/root)

 

3.3.2 file Movement

  • Mv (move) function: move or rename an existing file or directory
  • Syntax: mv [parameter] [source file or directory] [target file or directory]
    • -F or -- force if the target file or directory is the same as the existing file or directory, the existing file or directory will be overwritten.

 

  • Move the t5 directory under/root to the/root/t1 directory (the current location is/root)

  • Move the t5 directory under/root to the t1 directory under/root (the current location is/root, and the t1 directory already contains the t5 directory)

 

 

  • Rename the directory or file (rename Demo1.java under/root to hehe. java, current location is/root)

 

3.3.3 rm command

  • Rm (remove): deletes a file or directory.
  • Syntax: rm [parameter] [file or directory]
    • -F or -- force delete a file or directory
    • -R,-R, or -- recursive processing to delete all files and subdirectories in the specified directory

  

  • Delete the hehe. java file under/root. The current location is/root.

  • Delete the t1 directory under/root (the current location is/root)

 

 

3.3.4 find command

  • Find function: find files or directories
  • Syntax: find [directory...] [parameter] 'string to be searched'
    • -Name: Specifies the string as the template style for searching for files or directories.

 

3.4 document editing commands

  • Windows has notepad and Linux has similar notepad. Vim.

 

  • Vim command
    • Enter "vim file name" to enter "Normal Mode"
    • Press "I" to enter "insert mode" in normal mode"
    • Press "esc" from "insert mode" and exit to "normal mode"
    • In "Normal Mode", enter ": wq ". Exit editing.

    • Normal Mode: You can browse the file content and perform quick text operations. Single-row replication, multi-row replication, row deletion, and so on
    • Insert mode: You can edit text content.
    • Baseline mode:
      • You can force exit. Q!
      • You can save and exit the operation. Wq

 

3.5 grep and MPs queue

  • Grep (global regular expression print) regular expression: string search.
    • Function: used to filter and search for specific characters. You can use regular expressions to use multiple commands.
    • Format: grep [option] pattern [file] (the file to be searched by the grep string)
      • -I or -- ignore-case or slightly case-insensitive characters

     

  • Management commands: you can connect to multiple Linux commands.

 

 

  • Syntax: command 1 | command 2 | command 3

  

  • Query the row data with the ins keyword in the current directory.

 

 

3.6 compression and decompression command --- tar command

  • Linux compressed package:
    • *. Tar is packed, but the size is not compressed. For example, if files 1, 2, and 3 are all 1kb, the package is 3 kb after *. tar.
    • * .Tar.gz package and compress the file size.

 

  • Tar function: compress or decompress files
    • Syntax: tar command
    • -C: create a parameter command for creating a compressed file -- Compression
    • -V unzipping the extract command of a compressed file
    • -Do I need gzip compression for z?
    • -V verbose)
    • -F: use the file name, and immediately connect the file name (file) After f)
    • Common combination of Compression Parameters:-zcvf
      • Compression command: tar-zcvf compressed package name .tar.gz content to be compressed
      • For example, tar-zcvf hehe.tar.gz * compresses all content in the current directory, and the file name is hehe.tar.gz.
    • Common combination of decompression parameters:-zxvf
      • Decompress the command: tar-zxvf compressed package name .tar.gz
      • For example, extract the name of the compressed package to the current directory.
      • For example, the name of the compressed package to be decompressed in tar-zxvf-C specifies the decompression path and decompress it to the specified directory.

 

3.5 system commands

3.5.1 ps command

  • Function: The ps command is short for process status. It provides a one-time View of the process and the process information at the time when the ps command is executed.
  • Format: ps [parameter]
    • -E shows the program.
    • -F displays the uid, ppip, c, and stime fields.

  • Requirement: view the backup-related processes in the process.

 

3.5.2 kill command

  • Kill function: delete a program or job in execution.
  • Syntax: kill [parameter] [Program]
    • -L <information number> if no <information number> is added, the-l parameter lists all information names.
    • Force kill a process: kill-9 pid

 

 

3.5.3 ifconfig command

  • Function: displays network devices.
  • Command: ifconfig

 

3.5.4 ping command

  • Function: test the connectivity with the target host.
  • Command: ping the host name or IP address.

 

3.5.5 shutdown and restart

  • Linux centos restart command: reboot.
  • Linux centos shutdown command: halt shutdown immediately.

 

3.6 network settings  

 

3.7 File Permissions

  • Chmod (change mode) function: change the file or directory permissions.
    • Syntax: chmod [parameter-R] permission setting file name for permission change

  

  • Linux permission format: <type> <user> <group> <other users>

 

  • Change the permissions of the Demo1.Java file to all permissions.

 

  • Change the user permission of the Demo. java file group to r-x.

  • Change permissions of all Demo1.java users to r --

 

  • Change the permission of the user to r --

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.