Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does the Linux system prevent other users from accessing the home directory

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how the Linux system prevents other users from accessing the home directory. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

The Linux system is a multi-user and multi-tasking system, so the Linux system has multiple users. In the Linux system, each user has his own folder called "home directory". Since it is a home directory and certainly does not want to be casually accessed by other users in the system, how to prevent other users from visiting your home directory?

Ls-ld / home/lori

Note: this command contains only lowercase L, not the number 1. (LCTT translation note: this is a hint for a complete rookie, and most people can ignore it.)

At the beginning of the line, the permissions for the file are listed. As we talked about in the section on Linux permissions in the article.

R means "read", w means "write", and x means "execute". Directory permissions start with "d" instead of "-". You will also notice that the weight limit occupies 10 positions. You can ignore the first one, followed by three groups, divided into three groups. The first group is owner permission, the second group is group permission, and the last group is someone else (other or world) permission.

Therefore, the owner of the home directory listed below has read, write, and execute permissions, while belonging groups and others have read and execute permissions.

To modify these permissions, enter the following line at the prompt and enter

Sudo chmod 0750/home/lori

When prompted for your password, please enter and enter.

Note: the chmod command uses octal numbers as a way to specify permissions. We used a different approach in our article on Linux permissions, which requires several steps, but may be easier to understand. Using octal numbers to specify permissions is a faster way. No matter what method you use, as long as you are comfortable with it. To learn to set permissions using octal numbers, read this article.

Press the up arrow twice and invoke the "ls-ld / home/ username" command again to check permissions. Note that everyone else's permissions are now dashes (-), which means that others will not be able to read, write, or execute anything in your directory.

However, users in your group can read and execute files and folders in your directory. If you don't want anyone other than you to access your home directory, type "0700" in the chmod command.

Note: for more information about user and group management in Linux, please check out our article

To close the terminal window, type "exit" at the prompt and enter.

Now, when other users in their system try to access your home directory, the following dialog box will pop up.

You can even let Ubuntu use the specified permissions when creating new users. To accomplish this task, you need to edit the adduser configuration file. To edit the file, enter the following command at the prompt and enter.

Gksudo gedit / etc/adduser.conf

We use gedit to edit the file, or you can use any other text editor you want.

Note: the gksudo command looks the same as the sudo command, but it is used to run graphical programs as root, while the sudo command is used to run command-line programs as root.

Enter your password in the password edit box in the pop-up dialog box and press enter or click OK.

Scroll down to the DIR_MODE command in the adduser.conf file, where the default value is "0755". Modify this value to reflect the different permissions you want to grant to various types of users (owners, groups, others) (rMagnewPhonx), such as "0750" or "0700" as we discussed earlier. Click Save (Save).

Select Quit from the gedit File menu to close gedit, or you can click the X button in the upper left corner of the window to close it.

Click the X in the upper left corner of the window to close the terminal window.

For now, files in your directory will remain private. Keep in mind that if other users are in the same group as you, you may want to remove group and public permissions for your home directory permissions.

On how the Linux system to prevent other users from accessing the home directory is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report