Starting today, my platform has officially migrated to Linux. It’s a new beginning, and although it came a bit late, I’m still very happy. Moving platforms was a major goal I’ve had ever since I entered the computing field. I’m very optimistic about Linux’s development prospects, and unsurprisingly, its growth momentum has been incredibly fierce these past years. A large user base has created even larger market prospects. Which high-end software doesn’t now consider supporting the Linux platform? For me, making up for lost ground and improving my skills and knowledge in this area means it’s time to push forward and work hard!
Starting from now!
User Access Authorization Under LINUX — Author: skyzip
1. Create an Account
a. It is recommended to use the useradd command
Usage: useradd username
Example:
To create the account: skyzip
useradd skyzip
b. Set a Password
Use the command: passwd
Usage: passwd password
Example:
Assuming the password is: 123456
passwd skyzip [Enter]
New UNIX password: 123456 [Enter]
BAD PASSWORD: it does not contain enough DIFFERENT characters 'System prompt
Retype new UNIX password: 123456 [Enter]
passwd: all authentication tokens updated successfully 'System prompt
2. Assign a User to a Specified Location
Usage: vi etc/passwd
Example:
Open passwd
Modify the line related to the new user. In the modified line, ‘abc’ is the target folder.
Original: google: x:507:507::/home/html google:/bin/bash
Modified: google: x:507:507::/var/web/www/html/abc:/bin/bash
3. Create the Target Directory
Use the command: mkdir
Usage: mkdir directoryname
Example:
Create a folder in the appropriate location: mkdir abc
At the /var/web/www/html/ location, mkdir abc
4. Change the Owner of the Target File
a. Change file and folder owner
Use the command: chown
Usage: chown -R username:groupname directoryname
This means changing the owner of all files and folders in this directory.
Example:
chown skyzip:skyzip abc
Note: You must use this command format one level above the abc directory.
After completion, you can use ls -l to check if the owner has been changed.
b. Enter the abc directory and enter the following command to change permissions
chown -Rf username.groupname directoryname
5. Change Folder Read/Write Permissions
Use the command: chmod
Usage: chmod [specific permission value] directoryname (This only changes the permissions of directoryname, not the permissions of the folders and files inside it)
chmod -Rf [specific permission value] directoryname (This changes the permissions of directoryname and all folders and files it contains)
Example:
chmod 777 abc
Note: At this point, the current location is /var/web/www/html, which is one level above abc. It is set to 777, readable and writable, because I will be uploading and modifying files in this folder.
chmod -Rf 777 abc
Note: At this point, the current location is /var/web/www/html, which is one level above abc. It is set to 777, readable and writable, because I will be uploading and modifying files, and all files and folders inside abc are also set to readable and writable. This is not recommended; it is very dangerous!
6. You Can Test the Login with the Newly Created User
Operation complete!