Linux commands to modify files: 1. "vi" or "vim" command, which can be used to modify the content of the file; 2. "mv" command, which can be used to modify the name of the file; 3. "chmod", The "chgrp" and "chown" commands can be used to modify the permissions of the file; 4. The "touch" command can modify the time of the file.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
linux modify the contents of the file
The command is: vi,vim
vi editor, equivalent to Notepad, has editing functions, but weaker
vim is a complex editor, equivalent to Windows editplus, notepad Wait
Steps:
1. Execute vi world.txt to enter the editor (default command mode),
2 , click a or i to enter the editing mode, type: hello linux world!
3. Then press the esc key on the keyboard to exit the editing mode (enter the command mode),
4. Finally, type colon:,
5. Type wq again to save and exit.
Linux changes the name of the file
The command is: mv
mv (full spelling in English :move file) command is used to rename a file or directory, or move a file or directory to another location.
Syntax:
mv [options] source dest
mv [options] source... directory
Copy after login
The format is as follows:
mv source_file(文件) dest_file(文件)
Copy after login
Change the source file name source_file to the target file name dest_file.
linux modify file permissions
The commands are: chmod,chgrp,chown
chmod command
The chmod command is very important and is used to change the access permissions of files or directories. It is used by users to control access permissions to files or directories.
Take a folder named "cc" under the main folder as an example. The following is a step-by-step introduction on how to modify permissions:
1. Open the terminal. Enter "su" (without quotation marks)
2. You will be asked to enter your password next. Enter your root password.
3. Assume that my folder is in the home directory and the address is /var/home/dengchao/cc. Suppose I want to change the file permissions to 777, then enter chmod 777 /var/home/userid/cc in the terminal and the permissions of the folder will become 777.
If you want to modify the permissions of folders and subfolders, you can use chmod -R 777 /var/home/userid/cc
The specific permissions (such as the meaning of 777, etc.) are explained below :
1.777 has 3 digits, the highest digit 7 is to set the file owner access permissions, the second digit is to set the group access permissions, and the lowest digit is to set the access permissions of others.
The permissions of each of them are represented by numbers. Specifically, there are these permissions:
r (Read, permission value is 4): For files, it has the permission to read the file content; for directories, it has the permission to browse the directory .
w (Write, permission value is 2): For files, it has the permission to add and modify file contents; for directories, it has the permission to delete and move files in the directory.
x (eXecute, execution, permission value is 1): For files, the user has the permission to execute the file; for directories, the user has the permission to enter the directory.
2. First, let’s look at how to determine the permission value on a single bit. For example, the highest bit represents the file owner permission value. When the number is 7, 7 is represented by “rwx” – {4 (r) 2(w) 1(x)=7}–And if the value is 6, use “rw-” to represent –{4(r) 2(w) 0(x)=6}–, “-” It means that it does not have permission, here it means that it does not have "execution" permission.
If we set the access rights of other users to "r–", the value is 4 0 0 = 4
Many beginners will be confused at first, but it is actually very simple. Treat rwx as a binary number. If it is present, it is represented by 1, and if it is not, it is represented by 0. Then rwx can be represented as: 111
, and 111 in binary is 7.
3. Let’s take a look at how to determine the permissions on 3 digits. If we want to set permissions for a file, the specific permissions are as follows:
The file owner has "read", "write", and "execute" permissions, group users have "read" permissions, and other users have "read" permissions. "Permissions, the corresponding letters are expressed as "rwx r– r–", and the corresponding numbers are 744
Generally, the highest digit represents the file owner permission value, the second digit represents the group user permission, and the lowest bit indicates other user permissions.
The above is the detailed content of What are the commands to modify files in Linux?. For more information, please follow other related articles on the PHP Chinese website!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)
The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.
Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.
vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.
The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.
To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.
Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.
VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.