Linux commands for managing files and directories
Command |
Function |
Command |
Function |
Pwd |
Show current directory |
Ls |
View the contents of the directory |
Cd |
Change your directory |
Cat |
Display the contents of a file |
Grep |
Find a character in a file |
Cp |
Copying files |
Touch |
Create a file |
Mv |
Moving files |
Rm |
deleting files |
RmDir |
Delete Directory |
1.1 pwd Command
The command is interpreted in English as print working directory (print working directory). Enter the PWD command, and Linux will output the current directory.
1.2 cd Command
The CD command is used to change your directory.
CD/go to the root directory
CD ~ Go to the/home/user user directory
Cd/usr go to the USR directory in the root directory-------------absolute path
CD test goes to-------relative path in the test subdirectory under the current directory
1.3 ls Command
The LS command is used to view the contents of the directory.
Options |
Meaning |
-A |
Enumerate all the files in the directory, including hidden files |
-L |
List details in the directory, including permissions, owner, group, size, date created, whether the file is a link, etc. |
-F |
List of files showing file types |
-R |
Reverse, from the back to list the contents of the directory |
-R |
Recursive, this option recursively enumerates the contents of all subdirectories in the current directory |
-S |
Size, sorted by file size |
-H |
Display the size of a file in a human-readable way, such as K, M, G units |
Ls-l Examples.doc |
List all information about file Examples.doc |
1.4 Cat Command
The cat command can be used to merge files or to display the contents of the entire file on the screen.
Cat Snow.txt The command displays the contents of the file Snow.txt, Ctrl+d quits Cat.
1.5 grep command
The most important function of the grep command is to find a specific string in a heap of files.
grep Money Test.txt
The above command looks for the money string in Test.txt, and the grep lookup is case-sensitive.
1.6 Touch Command
The touch command is used to create a new file, and he can create a blank file where you can add text and data.
Touch newfile This command to create a blank file named NewFile.
1.7 cp Command
The CP command is used to copy files, to copy files, and to enter commands:
CP <source filename> <target filename>
CP t.txt document/t The command will copy the file T.txt to the document directory and be named T.
Options |
Meaning |
-I. |
Interactive: If the file will overwrite the target file, he will be prompted to confirm |
-R |
Recursion: This option copies the entire directory tree, subdirectories, and other |
-V |
Verbose: Show the progress of a file's replication |
1.8 MV Command
The MV command is used to move files.
Options |
Description |
-I. |
Interaction: If the selected file overwrites the file in the target, he will prompt to confirm |
-F |
Mandatory: It will go beyond interactive mode and move files without prompting, which is a very dangerous option |
-V |
Verbose: Show the progress of a file's movement |
MV T.txt document moves the file T.txt to the directory document.
1.9 RM Command
The RM command is used to delete files.
Options |
Description |
-I. |
Interactive: Prompt to confirm deletion |
-F |
Force: Replace interactive mode without prompting to confirm deletion |
-V |
Verbose: Show file deletion progress |
-R |
Recursive: Deletes a directory and all of its files and subdirectories |
RM t.txt the command to delete the file T.txt
1.10 rmdir Command
The rmdir command is used to delete a directory.
Linux basic commands (1) commands for managing files and directories