GNU/Linux >> Linux の 問題 >  >> Linux

Ubuntuでsudoユーザーを作成する

この記事では、Ubuntu®オペレーティングシステムの新規または既存のユーザーにsudoアクセスを許可する方法について説明します。

新しいユーザーを作成する
  1. adduserを使用する コマンドの後に新しい<username>が続きます :

    root@server-01:~# adduser newuser
    Adding user `newuser' ...
    Adding new group `newuser' (1001) ...
    Adding new user `newuser' (1001) with group `newuser' ...
    Creating home directory `/home/newuser' ...
    Copying files from `/etc/skel' ...
    
  2. プロンプトで、新しいユーザーのパスワードを2回入力して設定し、確認します。

    New password:
    Retype new password:
    passwd: password updated successfully
    
  3. 新しいユーザーの連絡先情報を追加する場合は、プロンプトで入力し、 ENTERを押します。 デフォルトを続行します。終了したら、yと入力します 入力した情報が正しいことを確認するには:

    Changing the user information for newuser
    Enter the new value, or press ENTER for the default
      Full Name []: New Hire
      Room Number []:
      Work Phone []:
      Home Phone []:
      Other []:
    Is the information correct? [Y/n] y
    
新規または既存のユーザーにroot権限を付与します。
  1. visudoを使用する sudoersを編集するには ファイル。

    root@server-01:~# visudo
    
  2. 次の例のようなテキストが表示されます:

    GNU nano 4.8                       /etc/sudoers.tmp
    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # Please consider adding local content in /etc/sudoers.d/ instead of
    # directly modifying this file.
    #
    # See the man page for details on how to write a sudoers file.
    #
    Defaults        env_reset
    Defaults        mail_badpass
    Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:>
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root    ALL=(ALL:ALL) ALL
    
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    
    # Allow members of group sudo to execute any command
    %sudo   ALL=(ALL:ALL) ALL
    
    # See sudoers(5) for more information on "#include" directives:
    
    #includedir /etc/sudoers.d
    
  3. 下矢印を使用します キーを押して次のセクションにスクロールします:

    # User privilege specification
    root    ALL=(ALL:ALL) ALL
    
  4. <username> ALL=(ALL:ALL) ALLを挿入して、新しく作成したユーザーを追加します 次の例に示すように、ユーザー特権セクションの最後にあります。

    # User privilege specification
    root    ALL=(ALL:ALL) ALL
    newuser ALL=(ALL:ALL) ALL
    
  5. Ctrl xを押します 出る。 yと入力します 保存するには、 ENTERをクリックします 終了します。

権限の変更を確認する
  1. suを使用する 続いて<username> 新しいユーザーアカウントに切り替えるには:

    root@server-01:~# su - newuser
    newuser@server-01:~$ 
    
  2. sudo -iを使用します ユーザーアカウントが権限を昇格できることを確認します。プロンプトで、新しいユーザーのパスワードを入力します。

    newuser@server-01:~$ sudo -i
    [sudo] password for newuser:
    root@server-01:~#
    
  3. whoamiを使用する 現在rootユーザーであることを確認するには:

    root@server-01:~# whoami
    root
    

コメントや質問をするには、[フィードバック]タブを使用します。私たちと会話を始めることもできます。


Linux
  1. UbuntuがSudoersにユーザーを追加

  2. RockyLinux8でSudoユーザーを作成する方法

  3. CentOSでsudoユーザーを作成する

  1. CentOS、Ubuntu、DebianでSudoユーザーを作成する方法

  2. DebianでSudoユーザーを作成する方法

  3. su - ユーザー対 sudo su - ユーザー

  1. DebianでSudoユーザーを作成する-ステップバイステップのプロセス?

  2. CentOS7でsudoユーザーを作成する方法

  3. Ubuntu に Qt をインストールする