Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic operation commands of Linux file

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the basic operation commands of Linux files". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn what are the basic operating commands of Linux files.

1. Switch directory [root@localhost ~] # cd [relative path or absolute path]

Special symbols for the cd command

The special symbol acts as ~ represents the home directory of the currently logged in user ~ the user name indicates switching to the specified user's home directory-represents the last directory. Represents the current directory.. Represents the superior directory 2. Show the current operation path

Pwd command, which displays the working directory where the user is currently located

[root@localhost] # pwd3. View the file [root@localhost ~] # ls [option] directory name under the directory

Common options and functions of ls command

Option function-a displays all files, including hidden files (beginning with. Is also listed together, which is one of the most commonly used options. -A shows all files, along with hidden files, but does not include. With; with. These two directories. -d lists only the directory itself, not the file data within the directory. -fls sorts by file name by default, and using the-f option lists the results directly without sorting. -F add an indication of the file type after the file or directory name, for example, * for runnable files, / for directories, = for socket files, | for FIFO files. -h displays the file or directory size in a way that is easy for people to read, such as 1KB, 234MB, 2GB, etc. -I displays inode node information. -l lists file and directory information in a long format. -n is displayed with UID and GID instead of file user name and group name, respectively. -r outputs the sort result in reverse, for example, if the original file name is from small to large, the reverse is from large to small. -R is listed together with the contents of the subdirectory, which means that all the files in that directory are displayed. -S is sorted by file capacity size, not by file name. -t is sorted by time, not by file name. -- color=never

-- color=always

-- color=autonever means that the color display is not given according to the characteristics of the file.

Always represents the display color, which is the default for ls.

Auto says let the system decide whether or not to give color according to the configuration. -- full-time outputs in full time mode (including year, month, day, hour, minute)-- time= {atime,ctime} outputs access time or change permission attribute time (ctime) instead of content change time. 4. Create a directory (folder) [root@localhost ~] # mkdir [- mp] directory name

The-m option is used to manually configure permissions for the created directory instead of using the default permissions.

The-p option recursively creates all directories. Take creating / home/test/demo as an example. By default, you need to create each directory layer by layer, while using the-p option, the system will automatically create / home, / home/test and / home/test/demo for you.

5. Delete empty directory [root@localhost ~] # rmdir [- p] directory name

The-p option is used to recursively delete an empty directory.

6. Move the file or modify the file name [root@localhost ~] # mv [option] source file destination file

-f: force overwrite, if the target file already exists, do not ask, force overwrite directly

-I: move interactively, if the target file already exists, ask the user whether to overwrite (default option)

-n: if the target file already exists, the move will not be overwritten and the user will not be asked

-v: displays the process of moving a file or directory

-u: if the target file already exists, but compared with the two, the source file is updated, the target file will be upgraded

7. Copy files and directories [root@localhost ~] # cp [options] source files and destination files

-a: equivalent to the collection of-d,-p,-r options, which we will introduce one by one

-d: if the source file is a soft link (not valid for hard links), the copied target file is also a soft link

-I: ask, if the target file already exists, whether to overwrite

-l: establish the target file as a hard-linked file of the source file instead of copying the source file

-s: establish the target file as a soft link file for the source file instead of copying the source file

-p: the copied destination file retains the attributes of the source file (including owner, group, permissions and time)

-r: recursive replication, used to copy directories

-u: if the destination file is different from the source file, use this option to update the target file, which can be used to upgrade and standby the file.

8. Delete files and directories [root@localhost ~] # rm [options] files or directories

-f: force deletion (force), contrary to the-I option, use-f, the system will no longer ask, but directly delete the target file or directory.

-I: on the contrary, before deleting a file or directory, the system will give you a prompt, and using-I can effectively prevent the accidental deletion of useful files or directories.

-r: recursive deletion, mainly used to delete directories, you can delete the specified directory and all its contents, including all subdirectories and files.

At this point, I believe you have a deeper understanding of the "Linux file basic operation commands", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report