Welcome to the Linux community forum and interact with 2 million technical staff. Chapter 4: ls has some common parameters. For example, we need to know all the contents of the current directory, includes hiding folders and files and all properties, as shown in [root @ ay1301_135131135089logs] # The lsboot2013-06.log uses the "-l" option of the ls command, then
Welcome to the Linux community forum and interact with 2 million technical staff> go to Chapter 4: ls has some common parameters. For example, we need to know all the contents of the current directory, includes hiding folders and files and all properties, as shown in [root @ ay1301_135131135089 logs] # ls boot2013-06.log using the "-l" option of the ls command, then
Welcome to the Linux community forum and interact with 2 million technicians>
Chapter 4:
Ls has some common parameters. For example, we need to know all the contents of the current directory, including hiding folders and files and all attributes. For example
[Root @ ay1301_135131135089 logs] # ls
Boot2013-06.log
If you use the "-l" option of the ls command, the result is output in Long Mode:
[Root @ ay1301_135131135089 logs] # ls-l
Total 8
-Rw-1 root 5975 Jun 15 :34 boot2013-06.log
Show Hidden Files:
[Root @ ay1301_135131135089 logs] # ls-
... Boot2013-06.log
Command Option Parameters
Command-options arguments
In the following example, the ls command has two options: the "l" option produces long format output, and the "t" option is sorted by the file modification time.
[Me @ linuxbox ~] $ Ls-lt
To determine the file type of a file, use the following method:
[Root @ ay1301_135131135089 logs] # file boot2013-06.log
Boot2013-06.log: ASCII text.
[Root @ ay1301_135131135089 assets] # file world.swf
World.swf: Macromedia Flash data (compressed), version 10
Use less to Browse File Content
[Me @ linuxbox ~] $ Less/etc/passwd
TODO Table 4-3: less command is required.
Tip: Remember to copy and paste it! If you are using the mouse, double-click the file name to copy it, and then press the middle mouse button to paste the file name to the command line.
Symbolic Links Symbolic Link
Hard Links
Chapter 5: Operating Files And Directories
Cp-copy files and directories
Mv-move/rename files and directories
Mkdir-create a directory
Rm-delete files and directories
Ln-I didn't understand the difference between creating a hard link and a symbolic link TODO and the Window shortcut key.
Cp-copy files and directories
Jiangge @ localhost :~ $ Cp item1 item2 # copy an item to the directory
Jiangge @ localhost :~ $ Cp file1 file2 # copy file1 to file2
Jiangge @ localhost :~ $ Cp-I file1 file2 # if this file exists during the copy process, it indicates whether to overwrite the file.
Jiangge @ localhost :~ $ Cp dir1/* dir2 # copy all files or directories in the directory to the target directory
Jiangge @ localhost :~ $ Cp-r dir1 dir2 # recursive Replication
Mkdir-create a directory
Jiangge @ localhost :~ $ Mkdir dir
Jiangge @ localhost :~ $ Mkdir dir1 dir2 dir3 # create multiple folders
Jiangge @ localhost :~ $ Mkdir-p/dir1/dir2/dir3 # recursively create a folder
Mv-move/rename files and directories
Jiangge @ localhost :~ $ Mv file1 file2 # rename
Jiangge @ localhost :~ $ Mv-I file1 file2 # if there is a prompt whether to write
Jiangge @ localhost :~ $ Mv file1 file2 dir1 # Move file1 file2 to dir1
Jiangge @ localhost :~ $ Mv dir1 dir2 # Move dir1 to dir2
Rm-delete files and directories
Jiangge @ localhost :~ $ Rm file1
Jiangge @ localhost :~ $ Rm file1 dir1
Jiangge @ localhost :~ $ Rm-r dir1 # delete a folder and recursively delete it
Jiangge @ localhost :~ $ Rm-rf dir1 force Delete
Table 5-3: wildcard examples
Pattern Matching object
* All files
G * files whose names start with "g"
B *. txt is a file that starts with "B" and has zero or any number of characters in the middle and ends with ". txt ".
Data ??? Files starting with "Data" followed by three characters
[Abc] * files whose names start with "a", "B", or "c"
BACKUP. [0-9] [0-9] [0-9] files starting with "BACKUP." and followed by three numbers
[[: Upper:] * files starting with an uppercase letter
[! [: Digit:] * files not starting with a number
* [[: Lower:] 123] Name of a file ending with a lowercase letter, or ending with "1", "2", or "3"
Table 5-4: cp options
Meaning
-A, -- archive copies files and directories and their attributes, including ownership and permissions. Normally, a duplicate has the default attribute of the file to be operated by the user.
-I, -- interactive prompts the user to confirm before rewriting an existing file. If this option is not specified, the cp command will overwrite the file by default.
-R, -- recursive Recursively copies contents in directories and directories. This option is required when you copy a directory (or-).
-U, -- update: When a file is copied from one directory to another, only the files that do not exist in the target directory are copied, or the file content is new to the existing files in the target directory.
-V, -- verbose displays detailed command operation information
Table 5-5: cp instance
Command running result
Cp file1 file2: copy the content of file file1 to file file2. If file2 already exists, the content of file2 will be overwritten by the content of file1. If file2 does not exist, file2 is created.
The cp-I file1 file2 command is the same as the preceding command. Except for the existence of file file2, you are prompted to confirm the information before file file2 is overwritten.
Cp file1 file2 dir1: Copy file1 and file2 to the directory dir1. The directory dir1 must exist.
Cp dir1/* dir2 uses a wildcard. All files in the dir1 directory are copied to the dir2 directory. Dir2 must already exist.
Copy the contents in the dir1 directory to the dir2 directory. If the directory dir2 does not exist, create the directory dir2. After the operation is complete, the contents in the directory dir2 are the same as those in dir1. If the directory dir2 exists, the directory dir1 (and the content in the directory) will be copied to dir2.
Chapter 6: Click the open link
Type-interpret a command
Which-display executable programs, and which determines the location of an executable program
Man-display command Manual
Apropos-display a list of appropriate commands
Info-display Command Information
Whatis-display a very brief description of a command
Alias-create an alias for the command
[Shijiangge @ localhost test] $ type
Type is a shell builtin
[Shijiangge @ localhost test] $ type ls
Ls is aliased to 'ls -- color = tty'
[Shijiangge @ localhost test] $ type cp
Cp is hashed (/bin/cp)
[Shijiangge @ localhost test] $ which ls # which determines the location of an executable program
Alias ls = 'ls -- color = tty'
/Bin/ls
[Shijiangge @ localhost test] $ which vim
/Usr/bin/vim
Help to get help information. Add the -- help parameter after each shell command, as shown in figure
[Shijiangge @ localhost test] $ ls -- help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default ).
Sort entries alphabetically if none of-cftuvSUX nor -- sort.
[Shijiangge @ localhost test] $ help cd
Cd: cd [-L |-P] [dir]
Change the current directory to DIR. The variable $ HOME is
Default DIR.
[1] [2] [3]