Summary of common commands for Linux systems (i) File and directory operations

Source: Internet
Author: User
Tags parent directory

Files and directories
  Command Options Annotations Example
Basic operation of the file Ls Options File Show All files and directories Ls-al
-A (a) Displays all files and directories, including hidden files and directories (showing all files and directories, including hidden files and directories, but not realistic "." and ".." Directory View details of all files in the current directory =ll
-L Display full attribute information for files and directories
-D    
Cd + Path Change the current path Cd/etc go to the ETC directory
Pwd   Show current Path PWD Displays the current path
Mkdir + Directory Name Create a Directory MKDIR ABC create ABC directory
-P Parent directory is created when parent directory does not exist
RmDir + Directory Name Delete directory, only empty directory can be deleted RMDIR ABC delete ABC directory
Cp [Options] Source target Copying files Cp-r test/usr/Copy all content in the test directory under the current directory, including subdirectories, to the USR directory
-R Looping for directory replication
-F  
Mv SOURCE Target   MV test/usr/move the test directory under the current directory to the USR directory
Rm [Options] File name Delete RM-RF test forcibly deletes the test directory under the current directory and all its files and subdirectories
-R Cyclic deletion, commonly used for directory deletion, to delete all files in directories and directories
-F Force Delete Does not prompt
View File Contents Cat [Options] File name View File Contents Cat-nb/etc/inittab Displays the contents of the Inittab file in the ETC directory, displaying line numbers but not showing blank lines
-N Display with the Lianxing number
-B Lianxing display, but no blank lines are displayed
More + File name With cat, if the file content more than 40 lines, will be split screen display, press ENTER single line down or press ctrl+f page, press Q exit browse Usage with Cat
Head (tail) [Options] File name Show file before (after) 10 lines head-5/test
-N Specify how many rows to display Displays the first 5 lines of the test file in the current directory
Cut options [File] Select a portion of each line in the file to display Cut–d ":" –f 2 c.txt
-D To use (...). ) to split To: Split c.txt each row, showing the second column of each row in the C.txt document
-F Show the first few columns  
Link file ln [Options] Source target Set the link file to create a hard link by default when the parameter is empty ln (-D) ct.sh DLink
-S Creating Symbolic Links Create a DLink hard link in the current directory, point to Ct.sh
-D Create a hard link
Search for files and directories Find Path [Options] File name You can specify a directory and all subdirectories to search because it is slower to find the hard disk Find. –name "*.txt" –atime 1
-name file Find file named name file, wildcards available * Find A. txt file accessed within one hours of the current directory
Locate + File name Find from established database, very fast, but database content needs to be updated in real time, database can be updated manually by UpdateDB command Usage with find
which + File name Find the location of the executable file by the path under environment variable path which LS
Whereis [Options] File name Search based on a set directory, not a directory under path but a custom directory Whereis ls
-B Find only binary files  
-M Just find the documentation.  
Grep Option pattern (included string) file name Indicates that the line containing the specified content is found in the text file Grep–n 456 B.txt
-N Show line Numbers Show line numbers in B.txt that contain 456
-I. String is case-insensitive Grep–v 456 B.txt
-V Reverse, indicating that a line with no specified content is found in a text file Show rows that do not contain 456 in B.txt
File and Directory Permissions Chown [Options] User:group directory or file name Change the owner and owning group of a file or directory Chown-r Lucy:root Lamp
-R All files under the directory are changed Change the lamp directory under the current directory and the owner of all files and subdirectories files to Lucy, and the owning group to root
chmod Options [Parameters] Directory or file name Change read and write execution permissions for a file or directory 1.chmod 760 ct.sh Change the permissions of the ct.sh file under the current directory to RWXRW----
-R All files under the directory are changed 2.chmod ug=rwx,o=r ct.sh Change the permissions of the ct.sh file under the current directory to rwxrwxr--
3.chmod g-r,o+w ct.sh Remove the Read permission for the group that belongs to the ct.sh file in the current directory, and add write permission to other people

Summary of COMMON commands for Linux systems (i) file and directory operations

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.