File management commands: ls, cd, pwd, mkdir, rmdir, cp, rm, mv, touch, cat, more, less, head, tail and so on. let's talk about it in detail (only common, not all commands) (1 ). ls command-a: All files, together with hidden files (starting. files) are listed together.
File management commands
First, I would like to sum up some commands for file management: ls, cd, pwd, mkdir, rmdir, cp, rm, mv, touch, cat, more, less, head, tail, etc, next we will give a detailed description (only common, not all commands)
(1). ls command
-A: All files, together with hidden files (starting. -A: All files, together with hidden files, but not including. and .. these two directories-d: only list the directory itself, rather than list the file data in the Directory (commonly used)-f: directly list the results, without sorting (ls will be sorted by file name by default !) -H: list the file capacity in a readable way (for example, GB, KB, etc.) (commonly used)-I: list inode numbers, inode meaning the next chapter will introduce (commonly used)-l: long data string list, including the attributes and permissions of the file and other data (commonly used)-n: list UID and GID, rather than the names of users and groups (UID and GID will be mentioned in user management !) -R: reversely outputs the sorting result. for example, if the original file name is from small to large, the reverse file is from large to small-R: it is listed together with the sub-directory content, equals to all files in the directory will be displayed (recursively speaking)-S: Sort by file capacity, rather than by file name-t: Sort by time, instead of using the file name
(2) cd command
Cd [relative path or absolute path] # The most important thing is the absolute path and relative path of the Directory. There are also symbols of some special directories! [Root @ www ~] # Cd ~ Test # indicates to go to the home directory of the user vbird, that is,/home/test [root @ www vbird] # cd ~ # Return to your home directory, that is, the/root directory [root @ www ~] # Cd # if no path is added, it still indicates returning to your home directory. [root @ www ~] # Cd .. # indicates to go to the current upper-level Directory, that is, the upper-level directory of/root means [root @ www/] # cd-# indicates to return to the directory just now, that is,/root ~ [Root @ www ~] # Cd/var/spool/mail # This is the absolute path! Directly specify the complete path name [root @ www mail] # cd .. /mqueue # This is the method of relative path, which is written by/var/spool/mail to/var/spool/mqueue.
(3). pwd command
Pwd [-P] option and parameter:-P: displays the actual path instead of the link path. Example: pwd cd/var/mailpwd? P/var/spool/mailpwd and pwd? P shows different paths!
(4). mkdir command
Mkdir [-mp] directory name options and parameters:-m: permission of the configuration file! Directly configure it. you do not need to check the default permission (umask)-p: to help you directly create the desired directory (including the upper-level directory! Example: mkdir-p test1/test2/test3/test4 (created together) mkdir-m 744 test2
(5). rmdir command
Rmdir [-p] directory name options and parameters:-p: delete the directory together with the "empty" directory at the upper level. example: rmdir-p test1/test2/test3/test4 (delete all)
(6). rm command
Rm [-fir] file or directory options and parameters:-f: indicates force. ignore nonexistent files and no warning message appears-I: interactive mode, before the deletion, you will be asked if the user is performing the action-r: Return to delete! It is most often used in directory deletion (this is a very dangerous option). it is usually used in combination, rm? Rf)
(7). mv command
Mv [-fiu] source destination option and parameter:-f: force meaning, if the target file already exists, will not ask and directly overwrite-I: if the target File (destination) if it already exists, you will be asked whether to overwrite-u: if the target file already exists and the source is newer, the update will be performed) we can also use the mv command to rename (for example, mv test. bak)
(8). touch Command
Touch [-acdmt] file options and parameters:-a: only modify access time-c: only modify the file time. if the file does not exist, do not create a new file-d: you can follow the date to be modified without the current date, or you can use -- date = "date or time"-m: to modify only mtime-t: later, we can talk about the time to be modified instead of the current time. the format is [YYMMDDhhmm]. Supplement: When we introduce the ls command (ls? L), it is mentioned that each file will record many time parameters under linux. In fact, there are three major change times. what is the significance of the three times? Here I will add the modification time (mtime): this time will be upgraded when the "content data" of this file is changed! Content Data refers to the content of a file, rather than the attributes or permissions of the file. status time (ctime): When the "status" of the file changes, this time will be upgraded. for example, if the permissions and attributes are changed, the time will be upgraded. Access time (atime): When "The content of the file is used", the access time is upgraded ). For example, if we use cat to read/etc/man. config, we will upgrade the atime of this file!
(9). cat command
Cat [-AbEnTv] option and parameter:-A: equivalent to the integration option of-vET. special characters can be listed instead of blank spaces.-B: the row number is listed, only display row numbers for non-blank rows. blank rows do not mark row numbers-E: Show the broken row byte $ at the end-n: print the travel number, along with the blank row, there will also be a row number, different from the option of-B (commonly used)-T: click the [tab] Button to display it with ^ I-v: list some special characters that cannot be seen
(10). more command
Commonly used shortcut keys: space: indicates turning one line down. Enter: indicates turning one line down./string: indicates the displayed content, search for the keyword "f": shows the file name immediately and the number of currently displayed rows. q: indicates that the file leaves more immediately and the file content is no longer displayed. "B" or "Ctrl + B": indicates turning back the page, however, this action is only useful to files.
(11). less command
Less (one page and one page flip) the difference between less and more: In the case of more, we can only look at it later, but if less is used, you can use the [pageup] [pagedown] and other key functions to navigate to and view the common file shortcut keys: blank key: flip down a page [pagedown]: flip down a page [pageup]: flip up a page/string: search down the string function? String: the function of searching up strings n: Repeat the previous search (and/or? Related !) N: Repeat the previous search (and/or? Related !) Q: Leave the less program.
(12). head command (retrieve the first few lines)
Head [-n number] file options and parameters:-n: followed by a number, which indicates the number of lines displayed (the first 10 lines by default)
(13). tail command (extract the following lines)
Tail [-n number] file options and parameters:-n: followed by a number, representing the meaning of the number of lines displayed (the default 10 rows)-f: indicates that you can view the subsequent files continuously. you need to press Ctrl + c to finish viewing the tail (tail? F is very useful. when we look at some frequently updated logs, for example, tail-f/var/log/maillog)
(14). file command (view file type)
Example: file ~ /. Bashrc -------- ASCII plain text file/usr/bin/passwd ------------ executable file/var/lib/mlocate. db --------------- data file
Summary:
After the above summary, the file management commands are summarized, including the directory operation commands (such as cd, pwdm, mkdir, rmdir, ls) directory and file copy, delete, move command (cp, rm, mv) file new and view command (touch, cat, more, less, head, tail ), there are also commands for viewing the file type. the above commands are too many to be easily remembered. you can only remember them after a lot of exercises. Now let's talk about this topic. next time we have to talk about commands related to linux file permission management!
This article is from "Share your knowledge ..." Blog, please be sure to keep this source http://freeloda.blog.51cto.com/2033581/1204512