linux learning main content integration

Using linux operating system

shell: Shell English words can be literally translated as "shell." Shell is a tool that animal as external protection.

A protective outer layer of Shell tool linux is linux kernel.

shell is a command line interpreter, the user operating system command analysis command can be appreciated,

Enabling user interaction with the operating system.

 

 

Shell type:

      Bourne Shell (referred to as sh): SRBourne developed by the AT & T Bell Laboratories, is a UNIX

      The first shell program, has become an industry standard. Currently, almost all Linux systems support.

      Defects: weak job control capability of the Bourne Shell, and does not support aliases and historical records and other functions.

      Therefore, most current operating system which was used as an emergency Shell.

 

 

      C Shell (referred to csh): University of California, Berkeley, csh programming scripts

      Style similar to the C language, won the support of the majority of C programmers.

      Defects: C Shell robustness as good as Bourne Shell.

 

 

      Korn Shell (referred to ksh): developed by the David Korn, solve the user the Bourne Shell

      Interaction issues, and to overcome the disadvantages of scripting quirks of the C Shell.

      Defects: Korn Shell use requires a license, leading to its wide range of applications as good as Bourne Shell.

 

 

      Bourne Again Shell (referred to bash): Also by AT & T Bell Laboratories developed a Bourne Shell

      The enhanced version, has become the most popular of Shell.

 

 

Shell command prompt format:

            username@hostname:direction$

             Username hostname directory name

 

 

Shell command format:

      $ Command [-Options] Argument1 Argument2 ...

         Command option parameters 1 Parameter 2 ...

 

Usually a command consists of three elements: the name of the command, option parameters. Command name is mandatory,
options and parameters are optional.
Three elements separated by a space between a command 1.
2. If a plurality of write commands on one line, the commands will be separated by a semicolon
3. If a command is not written in one line end of the line backslash this command is not marked the end of
 ~: represents the current path where the home directory
 /: root represents the directory
 whoami see the current user name
 hostname view the host name
 pwd get the absolute path
absolute path: the exact location of a file in the file system
relative path: relative location of a file or directory user's current location


linux basic commands
1 uname -r core edition number
2 open terminal: Ctrl + Alt + T
               Ctrl + Shift + n-
   filled command or file name: use the tab key
3 shutdown command: sudo shutdown -h now (time) -halt (stop) immediately shut down 
              sudo shutdown -r now (time) -reboot (restart) to restart
              sudo reboot now restart
  to view the system time to date  
  to set a new time sudo date -s 1:19:18  
   District cp When you change the / usr / report this content share / zoneinfo / Asia / on Shanghai / etc / localtime 
   

4 Enlarge font: ctrl + shift + plus
   Decrease font: ctrl + minus


5 clear screen command the Clear
              Ctrl + L
   to view the shell command history history 
   Viewing System capacity default history echo $ HISTSIZE
   temporarily modify the capacity HISTSIZE = 1000
   permanent change history capacity: vi .bashrc 
                             HISTSIZE = 2000
   to validate the configuration: Source .bashrc
 
5 ls browse the directory
  ls -l file presented in the form of a list of
  ls -h file size, use k, M
  LS -a list all files, including hidden files


drwxr-xr-- 2 wdl wdl 4096 2007-09-17 2:23 Desktop
file type, file access file link file number the owner of the group the file belongs file size, in characters 
time the file was last modified file or directory or directory name
the first group rwx: wdl user rights on behalf of  
the second group rwx: represent the same set of user privileges
third group rwx: on behalf of other User rights
File Type 
  - Normal File
  b (block) block device file
  c (char) character device file
  d (directory) directory file
  l (link) the link file
  p (pipe) pipe file
  s (socket) socket file


file and directory permissions
r (read) read access w (write) write permission x execute permissions


6 cd to change the working directory 
    ~ home directory of  
    the current directory.
    ../ previous directory
    cd - represents a cd command operations performed on

type 7 file display file
8 touch to create a the new file, change the file last modification time of


9 mkdir to create a directory
       -p create multiple layers of nested directories
  
10 rmdir remove directory
11 cp to copy files and directories to another file or directory
      -a recursively copy directories and links and reservations file attributes
      -r recursive directory copy all files and subdirectories
12 mv file or directory from the source directory to the target directory, rename the file name
13 cat read the contents of the specified file, and displayed on the standard output device
14 head 10 line display the default document beginning
   tail end of the file default display 10 lines
15 echo for the standard output - a text shown on the display, suggesting a role typically played
      -n not shown with a line
16 diff compare two files, different displayed 
   uniq remove duplicate files in adjacent rows
   grep "main" ./* -R represents the content in a multi-stage recursive search subdirectories
   wc -w file.txt calculate the number of words in the file
   wc -c file.txt calculated the number of characters in file
   wc -l file.txt calculate the number of lines in the file
to create a link files
linked files like shortcuts Microsoft Windows, retaining only the address of the target file without taking up storage space
linux there are two types of links
hard Links: use physical number --inode Linux file allocation for each link is established, therefore,
hard links can not cross file system.
Soft Link: to establish a connection using the pathname of the file.
(established under the default condition hard link) ln create a file link to file
  -s to create a soft link file
  

 

vi can be divided into three modes: line mode, insert mode and a command-line mode.
      A command line:
              Copy: yy, 4yy, 
              Paste: P (attached to the cursor on the next line), P (attached to a cursor on one line)
 Cut: Delete the first paste
              deleted: dd, 4dd
              delete a character: x, X
              replace one character: r, R (has been replaced, until the end of the press esc)
              to delete a character, s and enters insert mode
 to move the cursor: h, j, k, l respectively control the cursor left, under, on the right of a cell
 Ctrl a + b screen Ctrl + f to move up the screen to move down a
         G to move to the last line to the first line gg file
         . repeat the operation of a
            
            second insertion pattern
              i inserted in front of the cursor is
              a cursor inserted after
              I insert the first row jump
              a jump to end of the line is inserted
              o the cursor to the next line, the line in the first position of the insert
              O cursor on one line, the position of the first insert row


            3 line mode
              + Shift: 4,10y
                    : 4,10d
              Save: w
              Save and exit: wq, x, ZZ
 without saving changes Exit: q
              Mandatory Exit: q!
 : no change W filename file, exit without saving; file has been changed, save Release
 : R & lt filename data read another file appended to the end of this document
 : n1, n2 n1 W to save the contents of the filename into n2 file filename
 : ! command to temporarily leave vi into command line mode execution command to display the results
 : set nu show line numbers
   to replace: c $ to replace all the contents of the cursor to the end of
          c0 replace all the contents of the cursor to the beginning of the


   copy: y0 copy cursor to the beginning of SUMMARY
          Y $ content copied to the end of the cursor



 

Shell special characters
 Wildcard Meaning Example
    * represents the matching string of any length * .txt RM 
    ? Representative of a length of the matching character File .txt RM?
   [] Representative of a match where the specified character File RM [12 is] .txt
   [-] representative of a range of characters matches the specified File RM [1-4] .txt   
   [^] Representative in addition to the specified characters can match rm file [^ 1] .txt


pipe: pipe can connect a series of commands, the first command output as a second
input command, the command is passed to the second pipe, and outputs the second command as
input of the third command, and so on.
   ls ./ | wc -w test word of the current directory in the number of


input and output redirection: Input / output redirection Shell command or program is to change the default standard
input / output target, re-directed to the new target.
Linux default standard is defined as keyboard input, standard output is defined as a terminal window.
Meaning Example redirector
 > file redirect the file output source file, a new mode ./ LS> log.txt
 >> file to redirect output source document file, append mode ls ./ >> log.txt
 <File to an input source file redirection fiel WC <file
 2> or &> error messages generated by an input command to the specified file ls file 2> err.log


command substitutions: substitution command is a command as another output parameters of the command.
Format of the command is as follows:
command1 `` command2` LS pwd` display the file contents of the current directory of the


two popular package management mechanism
Background: Initially, linux-based system developer after completing the development of applications, many of the
binary files to users, user needs to install many programs one by one before using.
    
1.Debian Linux first proposed "package" management mechanism --Deb package, the application
binaries, configuration files, man / inf help pages and other documents merge packaged in a file,
the user use the package manager directly operating software package to complete the acquisition, installation, uninstallation, query and other
operations.


2.Redhat Linux Based on this idea it launched its own package management system --Rpm package.
Uses its own package format generation Rpm package file, Rpm Package Manager is responsible for installation, maintenance,
query, and even package version management.
   
Type packages:
    1. binary packages: contains the executable files, libraries, configuration files, man / info pages,
copyright notices and other documents.


    2. Source Package: comprising software source code, described modified version, the build instructions and compiling tools.
First by tar tool for the .tar.gz archive file, and then packaged into .dsc file.


Package Management Tool Category
  Category example describes common tools
                                           to complete the package management tasks at the command line mode.
                                           To get the package, query, depending on the package
 command line dpkg-deb, dpkg, apt Lai check, install, uninstall tasks,
                                           need to use their different command.


 Text window interface dselect, aptitude, tasksel in the text window mode, the window menu and 
                                              single management tasks can be completed package.




 Graphical interface synaptic running x-windows graphical desktop environment,
                                           with good interaction, readability, ease of use and so on.
Management tools
1.dpkg earliest Deb package management tool.
2.APT series Deb package management tool room tools most powerful.


dpkg is the earliest Deb package management tool that can be achieved using dpkg install a local package, compile,
uninstall, query, and application packaging and other functions.
Defects: Due to time limitations Linux systems and Internet-scale network conditions, without taking into account the current
Packages such a complex system dependencies, and to help users retrieve packages. Thus, in order to resolve
package dependency problem and access issues, there have been APT tool.


APT works
APT (Advanced Packaging Tool) is Ubuntu LInux the most powerful command line
package management tool for acquiring, installing, compiling, unload and queries Deb packages, as well as
checking package dependencies.
Ubuntu depot centralized mechanism to package a variety of different categories stored
in the depot, and effective management of the organization, and then placed in the depot many
image server, to enable a user to selectively access to mirror sites in the Ubuntu system,
using software source profile lists the most suitable access /etc/apt/source.list mirror site
address to the local host queries. This is the working principle of APT package manager.


 1) dpkg: local installation package, do not check dependencies between software
     sudo dpkg -i rxvt * .deb installation package
     sudo dpkg -s install software to view the status rxvt
     listed sudo dpkg -L rxvt file list of installed software
     sudo dpkg -r rxvt remove the software, but to retain the configuration file
     sudo dpkg -P rxvt delete all, including configuration files




  2) apt: online installation package
     Software source configuration file: /etc/apt/sources.list 
     refresh the software source list, established software index file: sudo apt-get update (required ubutun virtual machine networking)


     sudo APT-GET install rxvt online software installation
     sudo apt-get - reinstall install rxvt reinstall the package 
     dependencies between sudo apt-get check rxvt check packages
     sudo apt-get remove rxvt package removed, but retains the configuration file
     sudo apt-get --purge remove rxvt uninstall packages, including its the configuration file
 
package naming
names package follows the following conventions:
     Filename_Version-Reversion_Architectrure.deb
     package name _ software version - revision _ architecture



 

Shell command basic system maintenance
   shutdown command: sudo shutdown -h now (time) -halt (stop) immediately shut down 
              sudo shutdown -r now (time) -reboot (Restart) to restart
              sudo reboot now restart
   passwd to modify the current user's login password ( super user can modify all the user
            's login password, other users can modify this user's login password)
   su temporarily change the user's identity, the other user has permission to
   
   date view or change the system time
   sudo date -s 1:19:18 set a new time
   cp / usr / share / zoneinfo / Asia / Shanghai / etc / localtime change the time zone
   df view disk space usage
   df -Th display the type of file format and file system size of the physical file system by mega
            bytes
   df -aTh display the physical file system the type of file format and file system usage and
            size press megabytes
   lists the number of blocks of disk directories and files used by du, each accounting for 512 bytes
       -a list only the number of idle files
       listed -k disk usage (kb)
       -s lists the total free space (kb)
User Management
 vi / etc / passwd store user password information
 vi / etc / group information storage group
 vi /etc/adduser.conf  
   sudo adduser U1 to add a new user
   sudo deluser --remove-home u1 delete a user and the user's working directory
 
process management
   ps (process snapshot) process snapshot view process information
       -A list all processes
       -aux show all processes contain other users
a snapshot of the composition of the list of processes
% CPU occupancy of CPU usage
memory usage% MEM occupied rate
VSZ occupied by the virtual memory size
memory size RSS occupied
state STAT process
STATRT process start time
period tIME execution


state of the process flag
D: uninterruptible static R: being executed in
S: blocked T: suspended
Z: no but there is temporarily unable to eliminate W: there is not enough memory paging can be assigned
<: high-priority process N: low-priority process
L: there paging allocation and locked in memory
  top monitoring process, refreshed every 3 seconds (typically full-screen display, with the change of state of the process constantly updated)
       Shift +> Down shift + <q Exit page up
  pstree all processes in tree
  kill [- signal] PID using the kill command to terminate the process of


  
file compression and archiving
Ubuntu Linux installed by default compression tool is a graphical file Roller file Roller,
is integrated into Nautilus file manager, also has archiving, compression, decompression file / directory
functions.


shell archiving and compression tools
  gzip and gunzip
      gzip
      -l view the information within the compressed file, including the file number, size, compression ratio and other parameters
      -d unzip the file, the same function gunzip
      -num specified compression ratio, 1 to 9 NUM grade
  zip and unzip
      both only difference is that gzip compress a file, multiple files can not be compressed into
      a file that does not have archiving functions.
  tar
      -cjf -czf merge multiple files are archived and compressed
      -xvf unzip the file



 

Linux file system
file system: for a large number of files on the organization and management of computer storage devices, and provides user interaction interface.
Linux has a perfect file system, you can either use the user-friendly graphical file manager Nautilus,
you can use the powerful Shell file system management tool.


File system types
currently Ext3 is a file format widely used Linux system, the effectiveness of protection, data integrity, based on the Ext2
aspects of data access speed, backward compatibility and other improvements have been made.
Linux is a very high compatibility with the operating system, file system format supported by many, can be divided into the following categories:
     1) disk file systems: the actual local host can access the file system, including disk, CD-ROM ,
DVD, the USB memory, disk arrays, and so on. Common file system formats: the autofs, Coda, Ext (Extended
File System, extended file system), Ext2, Ext3, VFAT, UFS (Unix File System, Unix file system)
, the FAT (File Allocation the Table, File Allocation Table), FAT16 , FAT32, NTFS, etc.
 
2) network file system: remote access to the file system, the file system on the server side that is still local disk
file system, network remote client access data. Common file system formats: NFS (Network File System,
Network File System), Samba, AFP (Apple Filling Protocol, Apple Filing Protocol) and WebDAV, etc.
 
3) proprietary / virtual file system: does not reside on disk File system. Common formats: TMPFS (temporary file system),
PROCFS (Process File System, process file system) and LOOPBACKFS (Loopback File System, loopback file system)
 
file system structure
Linux file system is a hierarchical tree of organizational structure, the root (/) file system as a whole, only a starting point, All other
directories are starting from that point.
Under Windows, the directory structure belonging to the partition; In Linux, partitions belong to the directory structure.
    In Linux, all files are treated as hardware processing, including hard disk partition, CD-ROM, floppy drive and other USB mobile devices.
In order to access the hardware resources in a unified manner and method, Linux provides the appropriate device file for each hardware device. Once the
Linux system has access to the hardware, it will be on a file system is mounted to a subdirectory of the directory tree.



 

The basic structure of the directory
/ bin storage system most commonly used in binary executable file
/ boot storage linux kernel and system startup files, including Grab, lilo boot program
/ dev file to store all the equipment, including hard drives, partitions, keyboard, mouse, USB, tty etc
/ etc to store all system configuration files, such as passwd to store user account information, hostname storage host name, and so
the default location / home user's home directory
/ lib to store the shared library file that contains many of the use / bin and / sbin in the program library
/ media Ubuntu automatically mount the CD-ROM, floppy drive, a USB memory, temporary storage of the read files
/ mnt this is often used as the mounted file system mount point
/ proc file store all flags of course, they are identified by other dynamic information system after the process ID
/ root super-user's home directory
/ tmp to store temporary files and user program, all users have read and write access to the directory
/ usr / bin and user management members of a standard command
standard include file / usr / include c / c ++ and other development language environment
/ usr / lib and applications Link library package
/ usr / sbin users and administrators of standard commands
directory of shared files / usr / share storage using manuals
/ var / cache in application cache directory
/ var / tmp temporary files directory

Guess you like

Origin www.cnblogs.com/181118ljh123/p/12002333.html