Common Linux operations on the server and linux on the server
When I went to college at the modern Software Institute, I once served as a representative of the Linux class. Because I learned a lot at that time, I still have some Linux basics, the cloud servers used in the company happen to be in the Linux environment, so I feel it is time to learn about Linux again.
Let's talk about some common Linux commands:
Common Linux commands
Mkdir folder name: Create a folder
Touch file name to create an empty file
Ls to view the content in the current path
Cd/go to the root directory
Cd .. back to the upper-level directory
Enter the current user's home with a cd Space
Rm-rf file name or directory name delete file or directory
Clear Screen
Linux Permissions
The granted permissions are divided into three types: UGO. The u table shows normal users, g indicates all users in a group, and o indicates their users. Permissions are divided into three types: r, w, and x, which are read, write, and execute. Different permissions correspond to different numbers. Their corresponding relationships are as follows:
R w x
Read/write execution
4 2 1
The following three questions are used to explain how to use Linux permissions.
1. What are linux permissions?
R, w, x
2. Who should I grant permissions?
U, g, o
3. How to grant permissions
Use the chmod command
For example, you can grant the write permission to a file:
Chmod u + w file name
Grant read and write permissions to users in a group for a file:
Chmod g + rw file name
Grant execution permissions to others for a file:
Chmod o + x file name
You can also grant permissions to users, groups, and others for a folder. After the permission is granted, all files in the folder have the same permissions as those in the folder.
You can use chmod to grant permissions in three ways: +-=, where + adds the corresponding permissions,-minus the corresponding permissions, = is to make a file or folder only have the permissions currently granted.
After reading these three steps, you may feel that the permissions are so simple. Indeed, it is not difficult to grant permissions, but it is difficult to manage permissions in multiple groups, if there are more than one user, it will become difficult. Therefore, it is recommended that you add remarks when grouping users. With this knowledge, you can execute shell files.
Execute shell files
Command:
①./File name ② sh file name
Run the shell file (. sh file). Before executing the. sh file, you should first check whether the file to be executed has the execution permission for the current user. The command is:
Ll file name. sh
If you have the execution permission, you can execute the file. Here, you need to interpret the query results to determine whether the file has the permission, the following is a script file in my project:
-Rwxr-xr-x1 root 250 Apr 29 2016 restart. sh
File Name When uploading the file size of the user group to which the number of files in the permission zone belongs
-Rwxr-xr-xThese letters have many meanings. The file type and permissions of all users are displayed. Let's take it apart.
The first field indicates the file type. The values include-, d, l, and p. The relationship is as follows:
-Common files
D directory file
L link file
P Pipeline
The second to fourth rwx indicate the permissions of the file owner.
The fifth to seventh r-x represents the user permissions in the same group as the file owner.
The eighth to tenth places r-x indicates the permissions of other users.