In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Linux how to create new users and allow docker, the article is very detailed, has a certain reference value, interested friends must read it!
Create a user
1. Action
The useradd or adduser command is used to set up a user account and create a starting directory for the user, and the permission is superuser.
two。 Format
Useradd [- d home] [- s shell] [- c comment] [- m [- k template]] [- f inactive] [- e expire] [- p passwd] [- r] name
3. Main parameters
-c: add the comment text, which is saved in the remarks column of passwd.
-d: specify the home directory when the user logs in, replacing the system default / home/
-D: change the default value.
-e: specify the expiration date of the account, which is in the format of MM/DD/YY, such as 06max 30max 12. The default means permanent.
-f: specify how many days after the password expires to close the account. If the account is 0, it is disabled immediately; if it is-1, the account is always available. The default value is-1.
-g: specify the group to which the user belongs. Value can make the group name also be GID. The user group must already exist, and the period default is 100, that is, users.
-G: specifies the additional group to which the user belongs.
-m: automatically establish the login directory of the user.
-M: do not automatically create a user's login directory.
-n: cancels the establishment of a group with the user name.
-r: set up a system account.
-s: specifies the shell to be used by the user after logging in. The default is / bin/bash.
-u: specify the user ID number. This value must be unique in the system. 0room499 is reserved for system user accounts by default, so the value must be greater than 499.
4. Description
Useradd can be used to set up a user account, which is the same as the adduser command. After the account is set up, use passwd to set the password of the account. The account created with the useradd command is actually saved in the / etc/passwd text file.
5. Case
# useradd-u 544-d / usr/testuser1-g users-m testuser1
Add-m to create automatically if the home directory does not exist
6. Set the user's password
Passwd ${username} # enter the password
Create a docker user group and add users to the group
1. First create a docker user group. If a docker user group exists, it can be ignored.
Sudo groupadd docker
2. Add users to the docker group
Sudo gpasswd-a ${USER} docker
3. Restart docker
Sudo service docker restart
4. If an ordinary user executes the docker command, if prompted by get. If dial unix / var/run/docker.sock permissions are insufficient, modify / var/run/docker.sock permissions
Use the root user to execute the following command
Sudo chmod a+rw / var/run/docker.sock
My official website
Container creation and basic commands for ps:Docker
1. Use docker run to create a docker container. (all docker commands start with docker.) after installing docker, in most cases, there is no docker image on this machine. When performing docker run, check the local image first. If it is not available locally, you will automatically download the image on the Docker Hub. Docker's domain name resolution server is google, so you need to add the 8.8.8.8 and 8.8.4.4 DNS server IP to the domain name system. The action under Ubuntu is to open / etc/resolv.conf and add two lines nameserver 8.8.8.8 and nameserver 8.8.4.4.
two。 Next, create a container using the command docker run-I-t image name / bin/bash, such as
Docker-I-t ubuntu / bin/bash, where the-t argument is used to specify that an interaction is the command line
Execute this command. If there is a local image, create a container with the local image. If not, you will go to docker hub to download the image. The download time may be a bit long.
After the command is executed, a container is created and started and entered into the shell inside the container. It is exactly the same as a normal Linux operation in this container.
3. Management commands commonly used in containers
Docker run creates and launches a container, followed by the-d parameter run, and a guardian container is created to run in the background.
Docker ps-a view the containers that have been created
Docker ps-s to view containers that have been started
Docker start con_name starts the container with the name con_name
Docker stop con_name stops the container named con_name
Docker rm con_name deletes the container named con_name
Docker rename old_name new_name renames a container
Docker attach con_name attaches the terminal to the terminal of the running container named con_name, provided that the appropriate sh is specified when the container is created
After executing this command, press enter, and you will enter the container's command line Shell.
Docker logs con_name gets the container log named con_name
Docker inspect to view container details
Docker top con_name looks at the processes inside the container named con_name
Docker exec can be used to run a process in a container
Summary: docker management commands all start with docker, and add a word that is easy to understand. You are not familiar with the parameters of a command. You can use docker command-- help to check the meaning of the relevant parameters.
The above is all the content of the article "how Linux creates new users and allows docker". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.