Basic knowledge of Linux | File directory Operations __linux

Source: Internet
Author: User
Linux Basics | file directory Operations

This article for the author to learn the contents of Linux notes. Reference is made to the following articles: Linux files and directory management

In a Linux system, the directory structure is a tree structure, the top-level directory is/, and other directories can be added to or removed from the directory. Path Interpretation

The file path is divided into absolute path and relative path. Absolute path: Path relative to/beginning: not with/beginning path, such as./xxx/xxx,xxx/xxxx, ... /xxx/xxx

Here are a few paths:./represents the current path: for example, currently in the/root directory,./bin represents the absolute path:/root/bin. /indicates the superior directory: for example, currently in the/root directory, ... /The Representation/directory command list

Common commands for working with file directories are as follows: LS list directory cd switch directory PWD display current directory mkdir create a new directory rmdir delete an empty directory CP copy file or directory rm remove directory ls command

Grammar:

ls [optional parameters] [directory (not filled in the default current directory)] 

The LS command has very many optional parameters, and only a few of the common ones are listed here:-a lists all files, including hidden files-a lists all files, but does not include. Two directory-D lists only the directory itself, rather than listing the file data in the directory------------------- -L lists the details of the file.

Note that the ls-l command has a command of the same function called ll, which means that the LL command is the same as the Ls-l command. The system defaults to a LL-ls-l alias CD command

Grammar

cd relative path or absolute path

There is nothing to say about this order. pwd Command

Grammar

PWD [P] 
-P shows the real path, because some files are a linked file, plus this parameter will show the true absolute path. mkdir Command

Grammar

mkdir [-MP] Directory name
-M can automatically create the desired directory by appending the permission to add files later. By default, only one level of directories can be created, and adding this parameter will automatically create a multi-tiered folder if you want to make an error in a multi-tiered directory. rmdir Command

Grammar

rmdir [-p] Directory name
-P deletes along with an empty directory at the top level

This command only deletes the empty directory CP command

Grammar

CP [-ADFILPRSU] src dest
-A: Rather than-pdr meaning, for PDR, please refer to the following instructions; (Common)-D: If the source file is a link file attribute (link files), then copy the link file property instead of the file itself; F: for coercion (force), if the target files already exist and cannot be opened, Then try again after the removal;-I: If the target file (destination) already exists, it will ask for the action (commonly used) in the overwrite (common)-l: Create a link file for a hard link (hard link) instead of copying the file itself; P: Copies the past along with the file's properties, Instead of using default attributes (commonly used for backup); R: Recursive continuous replication, used for directory replication behavior, (Common)-S: Copy into the symbol link file (symbolic link), or "shortcut" files;- U: If destination is older than source, upgrade destination RM Command

Grammar

RM [-fir] File or directory
-F: That means force, ignoring nonexistent files, without warning messages;-I: Interactive mode, the user is asked whether action-R: Recursive deletion before deleting. Most commonly used in the deletion of the directory. This is a very dangerous option ... MV Command

Grammar:

MV [-FIU] source destination
MV [options] source1 source2 source3 ... directory

Options and Parameters:-f:force The meaning of coercion, if the target file already exists, will not be queried and directly overwritten;-I: If the target file (destination) already exists, it asks if it is overwritten. -U: Upgrade (update) to view file commands if the target file already exists and source is relatively new

There are several commands for viewing files in Linux: Cat displays file contents from the first line TAC and cat instead, display file contents from the last line NL computed file line number more one page display file content less page to show file contents Tail display the tail of a file a few lines of cat command

Grammar

Cat [-ABENTV] filename
-A is equivalent to the-VET consolidation option, which lists some special characters instead of Blank-B list line number-E to display the end of the break byte $-n lists the line numbers, blank lines also have line numbers-T to display the TAB key, and V to list some special characters TAC Command

As opposed to cat commands, you can see the writeback nl command of CAT

Grammar

NL [-BNW] filename
-b Specifies how the line number is displayed,-B-a identifies the line number showing the blank line,-B-T does not show the line number of the empty line-n lists the line number display, and-n is displayed on the left, and the number of digits occupied by the-W line More Command

Grammar

More filename

In more program running process, there are several keys can press: space down a page enter down a line/string down to find: F Display file name and number of rows Q leave more program B turn back page less command

Less runtime can enter the command: Blank key: Scroll down a page; [PageDown]: Scroll down a page; [PageUp]: Scroll up one page;/string: Search Down "string" function;? string: Search up the "string" function; N: Repeat the previous search (with/or?) about. N: Reverse repeats the previous search (with/or?). Q: Leave less this program; Head

Remove the previous lines from the file

Grammar:

Head [-N number] File 

Options and Parameters:-N: followed by a number that represents the meaning of a few lines tail

Remove a few lines behind a file

Grammar:

tail [-N number] File 

Options and Parameters:-N: followed by a number that represents the meaning of a few lines.-F: Indicates that the file name that is being followed is continuously detected, until the [Ctrl]-c will end tail detection.

Related Article

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.