File commands for common Linux commands

Source: Internet
Author: User

Ls: List Directories

Name: ls
Description: displays the contents of a specified working directory (list files and subdirectories contained in the current working directory ).
-A: displays all files and directories. (If the file name or directory name starts with "." is specified in ls, it is regarded as a hidden file and will not be listed)
-L in addition to the file name, the file type, permission, owner, and file size are also listed in detail.
-R: Display files in reverse order (originally in alphabetical order)
-T list archives in the order of creation time
-A is the same as-a, but does not list "." (current directory) and ".." (parent directory)
-F Add a symbol after the name of the file to be listed. For example, add "*" to the executable file and add "/" to the directory "/"
-R if the directory contains files, the following files are listed in sequence.
Example:
List all files whose names start with "s" in the current working directory:
Ls-ltr s *
List all the following directories and file details in the/bin directory:
Ls-lR/bin
List all files and directories under the current working directory. Add "/" after the directory name, and add "*" after the executable file name "*":
Ls-AF

Ls-al: used to format and list hidden files

Cd dir: Change the directory to dir

Cd: change to home directory

Name: cd
Usage: cd [dirName]
Note: change the working directory to dirName. DirName can be an absolute or relative path. If the directory name is omitted, it is changed to the user's home directory (that is, the directory where the login is located). In addition ,"~ "It also indicates the home directory," .. "indicates the current directory, and" .. "indicates the previous directory at the current directory location.
Example: Skip to/usr/bin /:
Cd/usr/bin
Jump to your home directory:
Cd ~
Jump to the top two layers of the current directory:
Cd ../..
 

Pwd: displays the current directory
Mkdir dir: create directory dir
Rm file: delete file
Rm-r dir: delete directory dir
Rm-f file: Force delete file
Rm-rf dir: Force Delete directory dir *
Cp file1 file2: Copy file1 to file2

Cp-r dir1 dir2: Copy dir1 to dir2; Create dir1 if dir2 does not exist

Name: cp
Usage:
Cp [options] source dest
Cp [options] source... directory
Note: copy one file to another or copy several files to another directory.
Calculation:
-A tries its best to copy the file status, permissions, and other materials as they are.
-R if the source contains the directory name, the files under the directory are also copied to the destination in sequence.
-F if the destination already has an archive with the same file name, delete it before copying.
Example:
Copy the file aaa (already exists) and name it bbb:
Cp aaa bbb

Copy all C language programs to the Finished subdirectory:
Cp *. c Finished
 

Mv file1 file2: Rename or move file1 to file2; If file2 is an existing Directory, move file1 to file2
Ln-s file link: Creates a symbolic link for a file.
Touch file: create a file
Cat> file: add standard input to file
More file: view the file Content
Head file: view the first 10 rows of file
Tail file: view the last 10 rows of file
Tail-f file: view the file content from the last 10 lines

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.