Linux Common File Operations command

Source: Internet
Author: User
Tags parent directory

First, enter the folder

Format: CD [directory name]
Common options:

CD/Enter current directory
Cd.. Returns to the previous level of the directory.
Cd.. /.. Moves the current directory up two levels.
CD-Returns the most recently accessed directory.

Second, display the current folder under the file directory

Format:: LS [options] [directory or file]
Features: Lists all subdirectories and files in the directory for the directory, lists file names, and other information for files.
Common options:
-A: Lists all files under the directory, including the. The implied file at the beginning.
-D: Displays the directory as if it were a file, rather than displaying other files.
-I: The index information for the I node of the output file.
-K: Represents the size of a file in the form of a byte.
-L: Lists the details of the file.
-N: Replace the name with the uid,gid of the number.
-F: A character is appended to each file name to indicate the type of the file, "*" means the executable plain file, "/" for the Directory, "@" for the Symbolic Link, "L" for fifos; "=" for the socket.

Such as:

Iii. creation and deletion of files and folders

1. Creation of files:

touch [filename]

2. Folder creation
Format: mkdir [options] dirname ...
function: The mkdir command is used to create a directory.
Common options:
-p–parents can be a path name. At this point, if some of the road competition directory does not yet exist, plus this option, the system will automatically set up those that do not already exist, that is, multiple directories can be established at one time.
-m–mode=mode sets the access permission for the new directory to mode, and the access rights are expressed in the given octal digits.
3. Delete Files
Format: RM [options] File list
Function: RM command to delete files or directories.
Common options:
-f–force ignores files that do not exist and does not give prompt information.
-r-r,–recursive recursively deletes the specified directory and its subordinate levels of subdirectories and corresponding files.
-I interactively delete files.
Description: The RM command deletes the specified file, and it cannot delete the directory by default. If the file is not writable, the standard input is a TTY (terminal device). If the option-F is not given, the user is prompted to delete the file before the –FORCE,RM command is removed, and if the user does not answer Y or y, the file is not deleted.
4. Deleting a directory
Format: rmdir [options] DirName
Function: Deletes the directory.
Common options:
-p–parents recursively deletes the directory dirname, which is also deleted when its parent directory is empty after the subdirectory is deleted. If there is a non-empty directory, the directory remains.

Iv. displaying the absolute path of the current file

Format: pwd
Function: Displays the absolute path of the current working directory.

V. Open, edit, and exit files

How to open a file: Edit the file with the vi file name or VIM file name.

Exit Press ESC, enter: q! Enter.

  To view a file with a cat file name or less file name

Linux Common File Operations command

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.