Linux Command Update + Introduction to Python Programming



Sublime text software
A text editing tool (commonly used for writing code) with powerful functions.


Task:
      1.
      Check the installation method
      of Sublime text3 by yourself. Create a Python editing tool with Sublime text3.
      2. Check the common shortcut keys of Sublime text3




file command to
   view the file type command
   file file


clear command to
   clear the screen
   
   Ctrl + l
cat command to
    view the content of the file
    will be displayed on the terminal (standard output).
    
    cat file name
    
ctrl + c can try to terminate the program


standard output redirection
1, >  
  command > file


  If the file does not exist, create a new file
  If the file exists, overwrite the file


  and output the content that should have been output to the standard output (terminal) to output other files


  cat examples.desktop > 1.txt
2. >>
   command >> file
   append content at the end of the file
   If the file does not exist, create a new file.
   If the file exists, append the content to the end of the file.




Pipeline :
   use the output of the previous command as the input of the next command    
     |
   cat examples.desktop | more




         
more command to
   view the content of the file, stop at the first Screen
   more file


   Use the space bar to flip the screen (if more than one screen, flip to the end, exit)
   Use the Enter key to flip the line
   Use the q key to exit the
  


head command
   Display the first few lines of the file, the default is 10 lines of
   head


   How to change the display number of rows?
   Check the help


tail command to
   display the lines at the end of the file, the default 10 lines
   tail file name


   how to change the number of lines displayed?
   Check help   




chmod command
   to change file permissions
   chmod mode file
   
   chmod a+x test.sh
   chmod ax test.sh


   chmod ar test.sh
   chmod a+r test.sh
   chmod u+w test.sh


   chmod mode file
      user: owner, users in the same group, other users
              u go
             a: all users (owner, users in the same group and other users)


      permissions: r read, w write, x execute
      
      plus permissions: +
      Reduce permissions:-


   chmod a+w test.sh add write permissions for everyone
   chmod u+w test.sh owner (owner) add write permissions
   chmod g+w test.sh add write permissions for users in the same group
   chmod o+ w test.sh Other users add write permissions


   chmod aw test.sh Everyone has write permissions
   chmod uw test.sh Owner (owner) key write permissions
   chmod gw test.sh Users in the same group reduce write permissions
   chmod ow test.sh Other users write down permissions


   using the permission bit mask
     owner and group other
     rwx rwx rwx
     -
     r
     0
     1
     ---r--r-- 
     000 100 100 
     001 execute 1 x
     010 write 2 w
     100 read 4 r
     110 6 rw-
     111 7 rwx
     101 5 rx
     011 3 -wx


     rwx r--r-- 
       1
      10
     100
     0+ 0+0 0 ---
     0+0+1 1 --x 
     0+2+0 2 -w-
     4+2+1 7 rwx all
     4+0+1 5 rx
     4+2+0 6 rw-


      
     chmod 555 test.sh
     chmod 644 test.sh


tar commands to
   pack, compress, decompress commands to
   
   pack:
   tar cvf filename directory/file
        
        cvf:options 
        File name: The name of the packaged file to be generated
                usually ends with .tar (extension)
                
        Directory/File: It is the directory/file to be packaged
   
   Expansion:
   tar xvf Filename
   
   Packing and compressing:
   tar cvfz Filename Directory/File
        cvfz: option 
        file name: the name of the packaged file to be generated
                usually ends with .tar.gz (extension)
                        .gz
                
        directory/file: the directory/file to be packaged and compressed




   Expansion:
   tar xvfz filename
   
find command To
   find a file
   , take the file name as the search basis as an example:
   find directory -name file name
         


         directory: which directory to start from to find
         the file name: the file to be found, you can use wildcard characters
                 plus "" to enclose the




grep command to
   search for files containing the specified content
   in a certain Search files for specified content
   
   grep option to find the content of the file (can be more than one)
   
         to find the content can be expanded with ""
   


   Job: check grep to help you determine the role of the -r option to
                        determine the role of the -n option The
   
wc command
  counts the number of lines and characters in the document , word
  wc file
  
ps command to
  view the command of the process (after the program runs, a process will be formed)
  ps aux
  ps aux | grep vim


kill command to
  kill the process
  kill process id
  (usually use ps to query the process id)
      -9  


pkill command
  pkill process


  name- 9 Options      


sudo command
  is that some commands are run with root privileges (do not need to switch to root state)
  sudo command ...


  








 How to switch the tab window of the terminal:
 New tab window:
   ctrl + shift + t
 to switch between tab windows Use alt+number
 
which query program location
   which program name


whereis query program, man manual, library location
   whereis program name
  
Python programming:
   open source, object-oriented interpreted language.
   High development efficiency, hybrid (glue language).




Write a Python program to complete the function:
   calculate and display a person's standard weight based on the input information.
   Split:
      1. Does this program require input?
          Our program needs to have an input part
          to solve the problem of using Pyton to input
      2. Does this program need output?
         Need to output, what is the standard weight displayed
      3. Do you need to calculate?
         Need to calculate
      4. The basis for calculation, standard weight calculation formula
      


1. Write a Pyton program, and
   after running it, it will display on the screen


    *
   ***
  *****
 *******
***** ****


python3 02.py




print(" *")


print is a standard library function in Python, and its function is to output the content to the standard output.


print(" *"), called function call, when the function is called by


1. Function name: print
2. The function call must have (), and it must be in English.
3. The parameters in the () are called function parameters. The parameters are optional, and there may or may not be.
    The parameter of the print function is an object, which can be multiple objects. If multiple objects are given, they
    need to be separated by ",". 
4. The function must be the same as the defined function name.
5. "*" is called a string, as a parameter of the function print


print("*", 100, 200)


 
      
Numerical operation (arithmetic operation):
 addition + 2 + 3
 subtraction - 3 - 2
 multiplication * 3 * 2 
 division / 3 / 2 = 1.5
 floor division // 3 // 2 = 1
 exponentiation ** 2 ** 3 = 8 


Python's basic data types:
1, number
2, string


1 , Number: Integer: -1 0 1 ... with positive and negative, no decimals, there is no limit         to the size of integers in
   Python3    Floating-point numbers: numbers with decimals, 1.5 1.0 0.1 -1.5             Floating-point numbers are double-precision    boolean types: true and Fake




             A simple look at the condition can be seen as true and represented by True.
                 If it is not established, it is false. False is used to indicate


2.
   The string is the text (text) expanded with single or double or triple quotes


   'Hello Aaa ~~~~'   
                  "let's go"


   "Hello" 






   '''
   Hello    '''    """
   Hello    hello    Your    height is:    """ # is a comment   Comments can appear at the beginning of a line, and content after the ending   # will be ignored
















Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324961304&siteId=291194637
Recommended