Basic LINUX commands-general Linux technology-Linux technology and application information. For details, refer to the following section. This document is very practical. It is not about the specific meaning of a command parameter, but about what commands are required to complete the task from the perspective of actual work.
File System operations are the most basic operations. Without a file system, the operating system cannot run at all.
Below are some of the things we often do. The meanings of the following parameters are not explained.
You can query the help documentation of this command.
1. Create a directory
Mkdir
NO1. create a level-1 directory in the current path
[Root @ rehat root] # mkdir test
NO2. create a multi-level directory in the current path
NO3. grant permissions to the newly created directory while creating the Directory
[Root @ rehat root] # mkdir-m 777 testmod
In this way, anyone has any permission for this directory.
2. Copy files and folders
Cp
NO1. copy the files in the specified directory to the current directory and rename
[Root @ rehat root] # cp ~ /. Bashrc bashrc_bak
NO2. force copy the file from the specified directory to the current directory, regardless of whether the current directory contains the file
[Root @ rehat root] # cp-f ~ /. Bashrc
NO2. copy the specified directory to the current directory
[Root @ rehat root] # cp-r/root/test.
[Root @ rehat root] # cp-r/root/test /.
The two have the same effect. When copying a directory, all the last-level directories in the source path will be copied, including the directory itself.
NO3. copy files from the specified directory to the specified directory
[Root @ rehat root] # cp ~ /. Bashrc/bak/. bashrc
NO4. during replication, all the attributes of the source file are also copied. If no parameter is specified, the properties of the target file and the source file may be inconsistent.
[Root @ rehat root] # cp-~ /. Bashrc/bak/. bashrc
NO5. if two folders need to be synchronized, one file is changed and the other file is changed, but ensure that the files of both files are up-to-date.
3. Create a link file, including hard links and soft links.
Ln
NO1. create a shortcut similar to Windows
[Root @ rehat root] # ln-s test.txt _ slnk
NO2. if you want to back up a file with insufficient space, you can create a hard connection for the file. In this way, even if the original file is deleted
If the linked file is not deleted, it is still not deleted in the bucket.
[Root @ rehat root] # ln-l test.txt _ hlnk
4. delete an object
Rm
NO1. delete files in the current directory
[Root @ rehat root] # rm test.txt
NO2. force delete the file in the current directory. No prompt is displayed.
[Root @ rehat root] # rm-f test.txt
NO3. force Delete the entire directory, including deleting all directories and files. administrator permissions are required.
NO7. to find and sort all directories in the current File System
[Root @ rehat root] # find.-type d | sort
NO8. to find all rmt tape devices in the system
[Root @ rehat root] # find/dev/rmt
17. display the file/folder list
Ls/dir
NO1. display all files, including hidden files starting.
[Root @ rehat root] # ls-
NO2. display file details
[Root @ rehat root] # ls-l
NO3. display information about the current directory and all subdirectories
[Root @ rehat root] # ls-Rl
NO4. display directories in chronological order, which is useful for finding the latest file
[Root @ rehat root] # ls-tl
NO5. sort by file size
[Root @ rehat root] # ls-Sl
NO6. display the file size and sort by size
[Root @ rehat root] # ls-s-l-S
18. Move or change the file/folder name
The usage of mv and cp commands is similar.
NO1. if the target file already exists, back up the original directory file before moving it.
[Root @ rehat root] # mv-B test.txt test2/
In this way, there will be two test.txt and text.txt ~ files under test2 ~
Test.txt ~ Is the hosts file. test.txt is the new file.
NO2. if the target object already exists but you do not want to overwrite it
[Root @ rehat root] # mv-f test.txt test2/
NO3. when both the source and target have the same file, if the source file matches the new object, the object will be moved; otherwise, the object will not be moved.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.