sudo | All About Testing https://allabouttesting.org Software Testing & Ethical Hacking Fundamentals Wed, 22 Sep 2021 11:01:02 +0000 en-US hourly 1 https://wordpress.org/?v=6.3.2 https://i0.wp.com/allabouttesting.org/wp-content/uploads/2018/02/cropped-logo-favicon.jpg?fit=32%2C32&ssl=1 sudo | All About Testing https://allabouttesting.org 32 32 135190090 sudo Command in Linux with 12 Example Usage https://allabouttesting.org/sudo-command-in-linux-with-12-example-usage/?utm_source=rss&utm_medium=rss&utm_campaign=sudo-command-in-linux-with-12-example-usage https://allabouttesting.org/sudo-command-in-linux-with-12-example-usage/#respond Sat, 08 May 2021 09:57:45 +0000 https://allabouttesting.org/?p=6334 Linux sudo command allows you to run commands with other user privileges. This command is similar to “Run as” in...

The post sudo Command in Linux with 12 Example Usage first appeared on All About Testing.

]]>
Linux sudo command allows you to run commands with other user privileges. This command is similar to “Run as” in Windows-based operating systems. In this article, we will see sudo Command in Linux with 12 Example Usage. Click Here If you are interested in knowing the Top 20 Linux Commands for Beginners.

sudo stands for “super user do!”. This command prompts for the password of the current user. The sudo command identifies an authorized user by referencing /etc/sudoers that the system administrator configures. Remember not to edit /etc/sudoers file directly instead use “visudo” command. You can check the “sudoers” file by using the below command:

sudo less /etc/sudoers

(1) List privileges

sudo -l

(2) To restart system immediately

sudo shutdown -r now

(3) To display version number of sudo

sudo -v

(4) To run sudo command in background

sudo -b <command>

(5) To change password of user

sudo passwd <username>

(6) To read files which can be read only by admin

sudo less <file-path>

(7) To run program as admin

sudo ./script.sh 

(8) To run program as another user or group

Below is the command run by user ‘alice’:

sudo -u alice script.sh 

(9) Add user account

sudo useradd <username>

(10) Add user account with an encrypted home directory

For this, first, we need to install the ecryptfs-utils package,

sudo apt install ecryptfs-utils

and then use the --encrypt-home command to encrypt the home directory. You need to add other details for the creation of the user.

sudo useradd --encrypt-home <username> 

The first time when ‘testuser’ logs in, below command need to use to generate passphrase and user need to store passphrase in a secure place.

ecryptfs-unwrap-passphrase

(11) To update the system

sudo apt-get update

(12) Display Help of sudo command

sudo --help

Conclusion

This article covers sudo command usage in great details so that you can use it easily. If I have missed any command, write in a comment box below.

The post sudo Command in Linux with 12 Example Usage first appeared on All About Testing.

]]>
https://allabouttesting.org/sudo-command-in-linux-with-12-example-usage/feed/ 0 6334