The basics of how to use Linux (如何使用Linux,基础笔记五)

“In the Linux system, any thing is file.” In this blog, we are going to see some commands which can manipulate files, and those operations include “copy”,“move”,“rename”,“create”,“remove” and “create link”.

  1. Before we learn those commands, we need know a feature of Linux, “Wildcards”. “Wildcards” provides special characters to help you rapidly specify groups of filenames, so this feature can make file operations more efficient.

Using wildcards allows you to select filename based on patterns of characters. If you used the “Regular Expression”, you would be familar with this feature.

e.g.
在这里插入图片描述
List all files which their name contains “32”.

some patterns and rules are shown below:
Cite from Linux command line
Cite from Linux command line
Cite from Linux command line

  1. Create Directories : “mkdir”

“mkdir” means creating directorie, this command can create one directory or multiple dirs at same time.
e.g. Make a directory
在这里插入图片描述
e.g. Make multiple directories
在这里插入图片描述

  1. Copy files and directories : “cp”

“cp” can be used by two ways.

3.1. To copy the single file or directory “item1” to file or directory “item2”

在这里插入图片描述
e.g.在这里插入图片描述

3.2. To copy multiple items (either files or directories) into a directory.
在这里插入图片描述

e.g.
在这里插入图片描述

Tips: We can use this commands with some options

Cite from Linux command line

  1. Move and remove files : “mv”

The “mv” command can move a itme into another item, or we can use it to change item’s name.

4.1. To move or rename file or directory “item1” to “item2”
在这里插入图片描述

e.g.
在这里插入图片描述

e.g.
在这里插入图片描述

4.2. To move one or more items from one directory to another

在这里插入图片描述

Tips: We can use this commands with some options
Cite from Linux  Command line

  1. Remove files and Directories : “rm”

The “rm” command is used to delete files and directories.

在这里插入图片描述

e.g.
在这里插入图片描述

Tips : We can use this commands with some options
在这里插入图片描述

  1. Hard link and symbolic link

6.1. A hard link is indistinguishable from file itself. When a hard link is deleted, the link is removed but the contents of file itself continue to exit(that is, its space is not deallocated) until all links to the file are deteted.

Tow limitations of hard link:

  1. A hard link cannot reference a file outside its own file system. This means a link may not reference a file that is not on the same disk portion as the link itself.
  2. A hard link may not reference a directory.

Creat a hard link:
在这里插入图片描述

6.2. Symbolic links were created to overcome the limitations of hard links. Symbolic links work by creating a special type of file that contains a text pointer to the referenced file or directory.

A file pointed to by a symbolic link, and the symbolic link itself are largely indistinguishable from one another. For example, if you write some something to the symbolic link, the referenced file is also written to. However when you delete a symbolic link, only the link is deleted, not the file itself. If the file is deleted before the symbolic link, the link will continue to exist, but will point to nothing. In this case, the link is said to be broken.

Create a symbolic link:
在这里插入图片描述

发布了20 篇原创文章 · 获赞 3 · 访问量 262

猜你喜欢

转载自blog.csdn.net/qq_34515959/article/details/97613867