O-Linux&Shell-W4

EDITORIAL words:
I own blog on-line friends
are welcome to visit
http://www.tianxu.top

O-Linux&Shell-W4

Linux system files and directories basic operations (a total of 10 points)

A, operation problems (a total of 10 points each 1 minute)

Please use the following exercise ordinary individual users log in directly to system operation.

  1. Use ls view the current user's home directory, the command will result screenshots.

  2. In the individual user's home directory, create one directory level, requires three nested directories, directory name, use the name of your school classmate their hearts Pa top three, will command screenshots.

  3. The workspace switch to the three-step innermost nested directories, the command will be shot.

  4. Create an empty file his name in the current location, will command screenshots.

  5. Use the vi editor on this empty file for editing, any write some kind of self-introduction in English text in the file, and save and exit, the text will introduce self-shots.

  6. Copy his name file to / tmp location and file name in the same class name renamed the best relationship with their students, will command screenshots.

  7. His name files (three nested directories innermost files, non-copy to / tmp in the file) to create a hard link, the name for the file name prefix his name h_, a soft link, the file name name name for himself prefix s_, we are created in the home directory of the user's personal general will command screenshots.

  8. The workspace switch to the individual user's home directory, use the rmdir directory-time three-tier hierarchy recursively delete command screenshots and describe what can be done if, and why.

  9. For the last step of the operation What command can also implement this function, the command screenshots.

  10. After successfully deleted the directory hierarchy using vi look at the user's home directory hard links and soft file connection file, will result screenshots and explain what the emergence of this situation and why.

Parsing step
following exercises are operating in the general user

  1. Enter lsto view the current user's home directory.

  2. Create a directory command: mkdircreated at once plus -poptions.

      mkdir -p xueba_1/xueba_2/xueba_3
    
  3. Switch workspaces used cdcommands.

      cd xueba_1/xueba_2/xueba_3
    
  4. Create an empty file of the command touch.

    touch yourname
    
  5. With the vicommand to enter file editing, press the keyboard ikey to open the insert mode, then press the questions asked type your self-introduction. Press the top left corner of the keyboard after the completion of ESCthe introduction of the insert mode, then enter :wqto save and exit.

  6. Copy command is cpused as follows:

    cp [源文件目录][空格][目标目录]
    cp xueba_1/xueba_2/xueba_3/yourname  /tmp/friendname
    //以上方式是将文件复制并改名,若不改名采用以下方式
    cp xueba_1/xueba_2/xueba_3/yourname  /tmp/
    
  7. Hard links: ln [源文件目录][空格][目标目录]
    soft links: ln -s [源文件目录][空格][目标目录]
    when creating links can also change the name of
    a hard link:

    ln xueba_1/xueba_2/xueba_3/yourname h_yourname
    

    Soft links:

    ln -s xueba_1/xueba_2/xueba_3/yourname s_yourname
    
  8. First, cdback to the user's home directory, delete command there rmdirand rm -r
    and requirements for rmdirdeleting a one-time three-level directory, plus a one-time needs-p

    rmdir -p xueba_1/xueba_2/xueba_3
    

    We will find that you can not delete, suggesting that the folder is empty
    if

     rmdir -p xueba_1/xueba_2/xueba_3/yourname
    

    You can delete

  9. We have already mentioned another delete command rm -rcan also delete

      rm -r  xueba_1
    

    If you want to force the removal can be used rm -rfbut do not easily use strong this destructive command.

  10. Here with the vicommand

    vi h_yourname
    vi s_yourname
    

    In which the hard link can access the file, soft links have been unable to access the file, this is because:
    1) Hard link : the same node node number and the node B node number A, that corresponds to a node inode two different file name, two file names point to the same document, a and B, the file system is completely equal. If you delete one of them, a no effect on another.
    2) soft links : node B and the node number of the node number of node A is not the same, A and B are directed to two different node, data block A is stored in the path name of B (B based on this can be found in directory entry). Is the "master-slave" relationship between A and B, if A is deleted, B still exist (because the two are different files), but it points to an invalid link.

Finally, attach a hard link and soft link to explain the article:
https://blog.csdn.net/yangxjsun/article/details/79681229

Published 10 original articles · won praise 10 · views 2544

Guess you like

Origin blog.csdn.net/tianxujituan/article/details/104960095