In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what are the basic operation commands for directories and files in linux. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Today, I will formally take you to learn the common basic commands and application cases of Linux.
Basic operation of directories and files
1. Pwd
Description: the pwd command is used to display the working directory where the user is currently located.
Usage: pwd [option].
Option:-P displays the real path of the link.
[root@qll ln-test] # pwd / root/ln-test [root@qll ln-test] # pwd-P / root/test # / root/ln-test is the linked folder of / root/test. The query is as follows: [root@qll ln-test] # ll-h / root/ln-test lrwxrwxrwx. 1 root root 4 February 8 17:55 / root/ln-test-> test
2. Cd
Description: the cd command is used to switch the current work path.
Usage:
Cd.. Switch the path to one level above the current directory
Cd-returns the previous path
Cd changes directory to the current user's home directory
[root@qll opt] # cd / root/test # switch path to / root/test [root@qll test] # cd. # switch path to the directory one level above the current directory [root@qll ~] # cd-# return the previous path, and go to the / root/test directory [root@qll test] # cd # switch the directory to the current user's home directory
3. Ls
Description: the purpose of the command is to display directory and file information.
Usage: ls [option]. [file / directory]
Options:
-a shows everything, including hidden files and directories.
-d displays information about the directory itself, not the files in the directory.
-h humanized display capacity information.
-l lists document details in long format.
-I displays the inode number of each file.
-S sorts by file size
-u shows when the file or directory was last accessed.
[root@qll ~] # ls # display subfiles and directory names under the current directory [root@qll ~] # ls / usr # display / usr directory subfiles and directory names [root@qll ~] # ls-a # query all information Includes hidden file and directory information [root@qll] # ls-l # query file and directory details [root@qll] # ls-lh # humanized display capacity information [root@qll] # ls-lu / etc/passwd # View / etc/passwd Last access time
4. Touch
Description: when the file was created or modified.
[root@qll ~] # touch test.txt
If the test.txt does not exist, it is created, and if it already exists, all the time to update the file is the current system time.
5. Mkdir
Description: create a directory.
Usage: mkdir [option]. [catalogue].
Option:-p to create a multilevel directory.
[root@qll ~] # mkdir data [root@qll ~] # mkdir-p / home/123/456
6. Cp
Description: copy files and directories.
Usage: cp [option] source target
Options:
-r Recursively copies all directories within a directory and its subdirectories.
-a keep all the attributes of the source document (including permissions, time, etc.) when copying.
[root@qll ~] # cp / etc/passwd / opt # copy passwd file to / opt directory [root@qll ~] # cp / etc/passwd / opt/passwd.bat # copy passwd file to / opt directory and rename it passwd.bat [root@qll ~] # cp-r / var/log / tmp/ # copy / var/log directory to / tmp directory
7. Rm
Description: delete a file or directory.
Usage: rm [option]. A document.
Options:
-f does not prompt, force deletion.
-r Recursively delete, delete the directory and all the contents under the directory.
[root@qll ~] # rm test.txt # Delete the file test.txt [root@qll ~] # rm-rf / tmp/data # Delete the directory without prompting
8. Mv
Description: move (rename) a file or directory.
[root@qll ~] # mv red.txt red2.txt # rename red.txt to red2.txt [root@qll ~] # mv red2.txt / tmp/ # move red2.txt to / tmp directory
9. Find
Description: search for files or directories
Usage: find [command options] [path] [expression options]
Options:
-name looks up by document name
-iname looks up by document name and is case-insensitive
-mtime searches by modification time
-group search by group
-user search by user
-size searches by capacity
-type search by document type, file (f), directory (d), device (bline c), link (l), etc.
-exec executes specific commands on documents found
-an and
-o or
[root@qll ~] # find-name "pa.txt" # find the current directory named "pa.txt document" [root@qll ~] # find-iname "Pa.txt" # find the document "Pa.txt" [root@qll ~] # find / etc-name "* .deny" # find all documents ending with .deny in the / etc directory [root@qll ~] # find /- Mtime-1 # find all the documents in the computer that have been modified within one day [root@qll ~] # find /-mtime + 3 # find all the documents in the computer that have been modified 3 days ago [root@qll ~] # find /-mtime 2 # find the documents in the computer that were modified 2 days ago [root@qll ~] # find /-group qll # find all documents in the computer whose group is qll [root@qll ~] # find /-user qll # find documents owned by qll users in the computer [root@qll ~] # find / opt-size + 50m # find documents greater than 50m in the opt directory [root@qll ~] # find /-size + 500m-exec ls-lh {}\ # after finding documents larger than 500m in the calculation, list the details of the file [root@qll ~] # find /-size + 1m-a-type f # find all documents in the computer that are larger than 1m and the document type is a file
10. Du
Description: calculate the capacity of a file or directory.
Usage: du [option]. [file or directory].
Options:
-h humanized display capacity information
-s displays only the total capacity
[root@qll ~] # du-h / etc # humanized display / etc directory and subdirectory capacity information [root@qll ~] # du-sh / etc # humanized display / etc directory capacity information on linux directories and files what the basic operation commands are shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.