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

Linux basic commands (2)

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1 、 pwd--print working directory

Meaning: view the current working directory

Example: / / the current location is in the / root directory

2 、 cd--change directory

Meaning: switch working directory

Note: just enter cd and switch to the initial default location, which is equivalent to exiting the folder.

3 、 ls--list

Meaning: list to view the contents of the directory

Format: ls [options]... [directory or file name]

Common command options

-l: display in long format-A: except for no display. And... Directory, other same as-a-d: displays the properties of the directory itself (rather than the content)-h: provides readable units of capacity (K, M, etc.)-R: recursive display content

/ / display all the contents of the current directory

/ / display all the contents of the current directory in a long format

/ / Show Hidden Directory

/ / display the current directory properties

/ / display the current file size in readable form

/ / Recursively display all the contents of the directory

4 、 du--estimate file space usage

Meaning: evaluate the destination directory or file size

Format: du [option].. [directory or file].

Common command items-a: count all files, not just directories-h: provide readable units of capacity (K, M, etc.)-s: only count the total space occupied by each parameter

5 、 mkdir--Make Directory

Meaning: create a folder

Format: mkdir [- p] [/ path /] directory name.

Command option:-p: recursive creation

/ / create a folder list

/ / create a folder a, b in a, c in b, d in c, (a, b, c, d are all folders).

6 、 touch

Meaning: create an empty file or update a timestamp

Format: touch [file name].

7 、 cp--Copy

Meaning: copy a file or directory

Format: cp [options]... The original document. Target path

Common command options-r: recursively copy the entire directory-f: force overwrite, do not prompt (as opposed to-I)-p: keep the original file attributes unchanged-a =-rpf. / / copy to the current directory

/ / create the file a.txt, and copy the file a.txt to the directory / home/

/ / Recursively create a directory a/b/c under the current directory and copy it to / home/

Note: when forcing a file to be overwritten, it will still prompt "do you want to overwrite the file"?

This is because the command alias added by the system by default is alias cp='cp-I, and executing cp is equivalent to executing cp-I. there are two ways to solve this problem:

Method 1: add "\" to the front of the command to enforce the command

Method 2: cancel the command alias

1. Temporarily cancel the command alias, restart the system or the terminal will resume.

2. Permanently cancel the command alias, and you need to modify the configuration file / root/.bashrc

[root@localhost~] # vim / root/.bashrc

After modifying the configuration file, press shift+:, and enter wq to save the exit.

8 、 rm--Remove

Meaning: delete a file or directory

Format: rm [options] file or directory.

Common command options

-r: recursively delete the entire directory-f: force deletion without prompting (as opposed to-I)

9 、 mv--Move

Meaning: move a file or directory

Format: mv [option] original file... object file.

/ / moving the path unchanged is equivalent to renaming

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

Servers

Wechat

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

12
Report