Is "sudo su -" considered a bad practice?
Let's look your cases:
su -
will run a /bin/sh as the root user using the root environment. The root password is needed and logging MAY be logged depending on syslog settings (usually is by default to /var/log/auth.log).
sudo /bin/sh
will run shell as the root user using the current set of environment variables (with some exceptions as would be defined in the sudoers file). The password is the source user password and NOT the root user password. sudo is usually logged.
sudo su -
will run a shell (usually /bin/sh) as the root user setting up the environment as the root user. This will require the password of the source user and this will generally be logged.
Sometimes it is necessary to have the root environment over your own environment, thus su - is an appropriate method. Remember sudo will still log the use of the shell command in either case.
Related videos on Youtube
Aquarius_Girl
Updated on September 18, 2022Comments
-
Aquarius_Girl over 1 year
I tried:
db.inventory.find({},{'_id':1, 'item':1}) db.inventory.find({},{'_id':2, 'item':2}) db.inventory.find({},{'_id':2, 'item':2000})
All three produced same results as follows:
> db.inventory.find({},{'_id':1, 'item':1}) { "_id" : ObjectId("5eb67598bee5213484d45087"), "item" : "journal" } { "_id" : ObjectId("5eb67598bee5213484d45088"), "item" : "notebook" } { "_id" : ObjectId("5eb67598bee5213484d45089"), "item" : "paper" } { "_id" : ObjectId("5eb67598bee5213484d4508a"), "item" : "planner" } { "_id" : ObjectId("5eb67598bee5213484d4508b"), "item" : "postcard" } { "_id" : ObjectId("5ebfd02b3a3b38a52be04608"), "item" : "journal" } { "_id" : ObjectId("5ebfd02b3a3b38a52be04609"), "item" : "notebook" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460a"), "item" : "paper" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460b"), "item" : "planner" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460c"), "item" : "postcard" } > db.inventory.find({},{'_id':2, 'item':2}) { "_id" : ObjectId("5eb67598bee5213484d45087"), "item" : "journal" } { "_id" : ObjectId("5eb67598bee5213484d45088"), "item" : "notebook" } { "_id" : ObjectId("5eb67598bee5213484d45089"), "item" : "paper" } { "_id" : ObjectId("5eb67598bee5213484d4508a"), "item" : "planner" } { "_id" : ObjectId("5eb67598bee5213484d4508b"), "item" : "postcard" } { "_id" : ObjectId("5ebfd02b3a3b38a52be04608"), "item" : "journal" } { "_id" : ObjectId("5ebfd02b3a3b38a52be04609"), "item" : "notebook" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460a"), "item" : "paper" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460b"), "item" : "planner" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460c"), "item" : "postcard" } > db.inventory.find({},{'_id':2, 'item':2000}) { "_id" : ObjectId("5eb67598bee5213484d45087"), "item" : "journal" } { "_id" : ObjectId("5eb67598bee5213484d45088"), "item" : "notebook" } { "_id" : ObjectId("5eb67598bee5213484d45089"), "item" : "paper" } { "_id" : ObjectId("5eb67598bee5213484d4508a"), "item" : "planner" } { "_id" : ObjectId("5eb67598bee5213484d4508b"), "item" : "postcard" } { "_id" : ObjectId("5ebfd02b3a3b38a52be04608"), "item" : "journal" } { "_id" : ObjectId("5ebfd02b3a3b38a52be04609"), "item" : "notebook" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460a"), "item" : "paper" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460b"), "item" : "planner" } { "_id" : ObjectId("5ebfd02b3a3b38a52be0460c"), "item" : "postcard" } >
- What do the values 1, 2, 2000 besides the field name specify? Why are results same?
- What does the first closed curly bracket specify?**
-
Falcon Momot almost 10 yearsNot requiring everyone to actively share the root password has important security cultural advantages that should not be overlooked.
-
Kingand almost 10 yearsI completely missed the difference in environments between sudo and su. Thank you!