Size = 13px] This document is very practical. It does not mean the parameters of a command, but considers 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 specific parameter meanings below are not explained. For more information, see this command help document 1. create 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 [root @ rehat root] # mkdir-P mytest/test1/ test1_1 NO3. grant the [root @ rehat root] # mkdir-M 777 testmod permission to the new directory while creating the directory. copy the file and the folder CP no1. copy the file 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 the files in the specified directory to the specified directory [root @ rehat root] # CP ~ /. Bashrc/bak/. bashrc no4. during the copy, 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 the two folders need to be synchronized, change one file and change the other, but ensure that the files of both files are up-to-date. [Root @ rehat root] # cp-U/src /. bashrc/bak_src/bashrc 3. create a link file, including a hard link and a soft link ln no1. create a shortcut similar to Windows [root @ rehat root] # ln-s test.txt _ slnk NO2. when you want to back up a file, but the space is not enough, you can create a hard connection for the file. In this way, even if the original file is deleted, as long as the linked file is not deleted, it is still not deleted in the bucket. [Root @ rehat root] # ln-l test.txt _ hlnk 4. delete the file RM no1. delete the file in the current directory [root @ rehat root] # rm test.txt NO2. force delete the file in the current directory, [root @ rehat root] # rm-F test.txt NO3. force Delete the entire directory, including deleting all directories and files, administrator permission required [root @ rehat root] # rm-r-F Test 5. delete the folder rmdir no1. delete an empty directory [root @ rehat root] # rmdir emptydir NO2. Delete the multi-level empty directory [root @ rehat root] # rmdir-P emptydir/D1/D11 6. mount the file system and detach the file system mount/umount no1. mount the optical drive [root @ reha T root] # Mount-T iso9660/dev/CDROM/mnt/CDROM NO2. attach the optical drive. Support for Chinese [root @ rehat root] # Mount-T iso9660-O codePage = 936, iocharset = cp936/dev/CDROM/mnt/CDROM NO3. mount Windows partition, FAT file system [root @ rehat root] # Mount-T vfat/dev/hda3/mnt/CDROM no4. mount Windows partitions, NTFS file system [root @ rehat root] # Mount-t ntfs-O iocharset = cp936/dev/hda7/mnt/had7 no5. mount the ISO file [root @ rehat root] # Mount- o loop/ABC. ISO/mnt/cdro M no6. mount the disk [root @ rehat root] # Mount/dev/fd0/mnt/Floppy no7. mount the flash disk [root @ rehat root] # Mount/dev/sda1/mnt/CDROM no8. mount the shared folder [root @ rehat root] # Mount-T smbfs-O username = guest, password = guest // machine/path/mnt/CDROM no9. display the mounted file system [root @ rehat root] # Mount [root @ rehat root] # Cat/etc/fstab Display System start the automatically loaded file system [root @ rehat root] # Cat/etc/mtab to display the currently loaded file system 7. check disk space DF no1. show all storage system space usage Situation, the file system type s [root @ rehat root] # DF-at NO2. displays the space usage of the specified file system [root @ rehat root] # DF-T ext3 NO3. display the size of each bucket in a user-friendly manner [root @ rehat root] # DF-Ah no4. network file systems are sometimes mounted, if you only want to view the local file system, run the following command [root @ rehat root] # DF-ahlt no5. view disk usage of a file system [root @ rehat root] # DF-H/ dev/CDROM 8. check the directory space size du no1. view the current folder size [root @ rehat root] # Du-SH NO2. view the size of the subfolders in the current file and files [root @ rehat root] # Du -Ch NO3. view the file size [root @ rehat root] # Du-H test1.txt no4. view the size of multiple files simultaneously [root @ rehat root] # Du-H test1.txt test2.txt 9. in Linux, disk fragment is basically not required. It will be automatically organized at intervals of 10. create/change file system no1. Create File System Type [root @ rehat root] # umount/dev/sdb1 [root @ rehat root] # mkfs-T ext3/dev/db1 [root @ rehat root] # Mount/dev/sdb1/practice 11. change the file or folder permission chmod no1. set your note to read [root @ rehat root] # chmod go-rwx test.txt or [root @ rehat root] # chmod 700 test.txt NO2. simultaneous repair Modify the permissions of multiple files [root @ rehat root] # chmod 700 test1.txt test2.txt NO3. modify the permissions of a directory, including its subdirectories and files [root @ rehat root] # chmod 700-r test 12. change the file or folder owner chown. Only root can use no1. to change the owner of a file [root @ rehat root] # chown JIM: usergroup test.txt NO2. change the owner of a directory, the subdirectory [root @ rehat root] # chown JIM: usergroup-r test 13. view the text file content cat no1. view the file content, and add the line number [root @ rehat root] # Cat-N test.txt NO2. in front of each line to view the file content, add the row number [root @ Re Hat root] # Cat-B test.txt NO3. merge the content of the two files [root @ rehat root] # Cat test1.txt test2.txt> test_new.txt no4. the content of both files is complete, return to a file [root @ rehat root] # Cat test1.txt test2.txt> test_total.txt no5. clear the content of a file [root @ rehat root] # Cat/dev/null> test.txt no6. create A new file [root @ rehat root] # Cat> new.txt press Ctrl + C to end the input 14. edit file VI no1. Create File [root @ rehat root] # vi newfile.txt NO2. Modify file [root @ rehat root] # vi Test.txt there are two working modes of NO3. VI: Command mode, edit mode no4. after entering VI, Enter command mode, press insrt to enter edit mode, and Press ESC to Enter command mode, the command mode cannot be edited. You can only enter the command no5. common command in command mode: W to save the current document: Q to exit VI: WQ. Save it first and then exit 15. path Operation cd pwd no1. display the current path [root @ rehat root] # PWD NO2. return to the user's home directory [root @ rehat root] # Change CD NO3. change to another path [root @ rehat root] # CD/etc no4. return to the upper-level directory [root @ rehat root] # CD .. no5. return to the root directory [root @ rehat root] # cd/16. query files or folders find no1. find all files in the current user's home directory [Root @ rehat root] # Find ~ NO2. grant the file owner in the current directory the read and write permissions, and the users in the file group and other users have the read permissions. [root @ rehat root] # Find. -Perm 644-exec LS-l {}\; NO3. to find all common files with a length of 0 in the system and list their full paths; [root @ rehat root] # Find/size 0-type F-exec LS-l {}\; no4. search for common files that were modified seven days ago in the/var/logs directory and ask them before deletion; [root @ rehat root] # Find/var/logs-mtime + 7-type F-OK Rm-I {}\; no5. find all the files in the root group in the/system. [root @ rehat root] # Find/-group root-exec LS-l {}\; no6. F The IND command will delete the admin with a numeric Suffix from the last seven days. log File [root @ rehat root] # Find. -Name "Admin. log [0-9] [0-9] [0-9] "-atime-7-OK RM {}\; no7. in order to find all directories in the current file system and sort [root @ rehat root] # Find. -type D | sort no8. to find all the RMT tape devices in the system [root @ rehat root] # Find/dev/RMT 17. show file/folder list ls/DIR no1. show all files, including. hidden file [root @ rehat root] # ls-A NO2. detailed information of the displayed file [root @ rehat root] # ls-l NO3. display information of the current directory and all subdirectories [root @ rehat root] # ls -Rl no4. display the directory in chronological order, [root @ rehat root] # ls-Tl no5. sort by file size [root @ rehat root] # ls-Sl no6. display the file size, [root @ rehat root] # ls-S-l-S 18. move or change the file/folder name MV and CP command usage similar to no1. if the target file already exists, before moving, back up the original directory file [root @ rehat root] # mv-B test.txt Test2/so that there will be two files test.txt and text.txt ~ in Test2 ~ Test.txt ~ Test.txt is the new file NO2. if the target file already exists but you do not want to pop up the overwrite prompt, directly overwrite [root @ rehat root] # mv-F test.txt Test2/NO3. when both the source and target have the same file, the source file will be moved if it is a new object, otherwise, do not move [root @ rehat root] # mv-u test.txt Test2/no4. change the file name [root @ rehat root] # mv test.txt test2.txt no5. change the directory name [root @ rehat root] # mv/Test2/test2_2 [/size]
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service