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

Common commands in Linux (1)

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

Share

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

One Linux shortcut key

Command function Ctrl + C terminates the foreground running program Ctrl + D exits Ctrl + L clear screen Ctrl + A cursor moves to the front of the command Ctrl + E cursor moves to the command back end Ctrl + K deletes all characters before the cursor Ctrl + K deletes all characters Ctrl + R search history command, using the keyword Alt +. Refer to the last argument of the previous command, which is equivalent to! $

II. Linux commands for managing files and directories

Command function PWD display current directory ls view directory contents cd change directory cp copy file touch create file mv mobile file rm delete file rmdir delete directory ln establish a synchronous link for one file in another location

1 pwd command

The command is interpreted as print working directory (print working directory) in English. Enter the pwd command, and Linux outputs the current directory.

2.ls command

The ls command is used to view the contents of the directory.

Option meaning-an enumerates all files in the directory, including hidden files-l enumerates details in the directory, including permissions, owner, group, size, creation date, whether the file is a link, etc.-h displays the size of the file in a human-readable way, such as K, M, G as units-R recursion This option recursively enumerates the contents of all subdirectories under the current directory-f enumerates the file type-s size, sorted by file size

3.cd command

The cd command is used to change the directory.

Cd / go to the root directory

Cd ~ go to the home of the user's directory

Cd. / indicates the current directory

Cd.. / represents the upper level of the current directory

4.cp command

The cp command is mainly used to copy files or directories.

Cp

Cp t.txt Document/t this command will copy the file t.txt to the Document directory and name it t.

Command function-a this option is usually used when copying a directory, it retains links, file attributes, and copies everything in the directory, which is equivalent to a combination of dpR parameters. -f overwrites an existing target file without prompting-I, contrary to the-f option, gives a prompt before overwriting the target file, asking the user to confirm whether it is overwritten, and when answering "y", the target file will be overwritten-p in addition to copying the contents of the file, also copy the modification time and access rights to the new file-r if the source file given is a directory file All subdirectories and files under that directory will be copied

5.touch command

The touch command is used to create a new file, and it can create a blank file to which you can add text and data.

Touch newfile this command creates a blank file called newfile.

6.mv command

The mv command is used to rename or move a file or directory to another location.

-I: if the specified directory already has a file with the same name, ask whether to overwrite the old file first

-f: do not give any indication when the mv operation wants to overwrite an existing target file

Set mv parameter to run the result

Command format running result Column 3mv file name change source file name to destination file name mv file name move file to destination directory mv directory name directory name destination directory already exists, move source directory to destination directory; if the destination directory does not exist, rename it

7.rm command

Used to delete a file or directory.

Grammar [option] name

Parameters.

Command function-I ask for confirmation one by one before deletion-r delete the directory and the following files one by one-f delete directly even if the original file attribute is read-only, there is no need to confirm one by one

8.ln command

Establish a synchronized link for a file in another location

Command function:

Linux file system, there are so-called link, we can regard it as an alias for the file, and links can be divided into two types: hard link (hard link) and soft link (symbolic link), hard link means that an file can have multiple names, while the soft link way is to generate a special file, the content of the file is to point to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.

Neither hard link nor soft link will make a copy of the original file and will only take up a very small amount of disk space.

-s soft links (symbolic links)

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