• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

?‍?User Account Management in Linux... The Cool Way to Add, Switch, and Delete Users

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
So, you just spun up a Linux machine (maybe on a VM or in the cloud), and now you want to act like a sysadmin.

Oh just me? Well, I'm here to humble us both because there's a long road ahead...

Still, one of the first things you'll need to know is how to manage users like a pro.

Let's dive into some essential commands: useradd, passwd, su, and userdel.

Think of these commands as your User Control Panel ... but Super Powered, no need for that GUI stuff. ?

? Table of Contents

  • Create New Users (useradd)
  • Set Passwords (passwd)
  • Switch Users (su)
  • Delete Users (userdel)
  • Pro Tips
  • Windows Comparison
  • Wrapping Up


? useradd – Create New Users


useradd is like the “Create Account” option in Windows, but with style.

Basic Syntax:


sudo useradd [options] username
Common Options:

OptionWhat it does
-mCreate the user’s home directory
-d /custom/homeSet a custom home directory
-s /bin/bashSet the user’s default shell
-u UIDAssign a specific user ID
-g groupnameSet the user’s primary group
-G group1,group2Add the user to supplementary groups
-e YYYY-MM-DDSet account expiration date
-c "Comment"Add a user description
Example:


sudo useradd -m -s /bin/bash -c "Web Developer" alice


? passwd – Set or Change User Passwords

Syntax:


sudo passwd username
Example:


sudo passwd alice


? su – Switch User

Syntax:


su - username
Example:


su - alice

? Note: You can use sudo su - to become root, but tread carefully, with great power comes great responsibility... though let’s be real, Peter Parker probably isn't reading this, ?️ So maybe just steer clear unless you really know what you're doing!


? userdel – Delete Users

Syntax:


sudo userdel [options] username
Common Options:

OptionWhat it does
-rRemove the user’s home directory and mail spool
Example:


sudo userdel -r alice


? Pro Tips

  • Want to see all user and system accounts?

cat /etc/passwd
  • Want to check details for a specific user?

grep <username> /etc/passwd
  • Want to see what groups a specific user belongs to?

groups <username>
  • Want to check group membership or definitions?

cat /etc/group
  • Or filter for a specific group:

grep <groupname> /etc/group
  • Need to modify an existing user (like changing their shell or adding them to groups)?

sudo usermod [options] username

? Note: usermod is a powerful command with lots of options, enough to deserve its own article! From changing usernames to assigning new shells or managing group memberships, it’s a whole-nother rabbit hole. Stay tuned, maybe I'll cover that later.


? Quick Windows Comparison

Windows ActionLinux Command
Add a new user (GUI)useradd -m username
Change password (Ctrl+Alt+Del)passwd username
Switch user (Start > Switch user)su - username
Delete useruserdel -r username


? Wrapping Up


That’s your crash course on user management! Whether you're building out a secure dev server or managing a personal VM, these commands are must-know tools in your Linux toolkit.

Have fun managing users responsibly. ?

? Let’s Connect


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.




Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу