Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 40

Thread: What is the each command's different merit between su and sudo?

  1. #21
    Join Date
    Mar 2007
    Location
    Denver, CO
    Beans
    7,958
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: What is the each command's different merit between su and sudo?

    Code:
     doug@s15:~/sudo/test$ printf '%s ' *.txt | xargs --max-procs=6 --max-args=1000 sudo rm
    Seems like a lot of extra overhead here -- honestly it just seems easier to become the root user and and do a simple rm command.

  2. #22
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: What is the each command's different merit between su and sudo?

    Quote Originally Posted by kevdog View Post
    Code:
     doug@s15:~/sudo/test$ printf '%s ' *.txt | xargs --max-procs=6 --max-args=1000 sudo rm
    Seems like a lot of extra overhead here -- honestly it just seems easier to become the root user and and do a simple rm command.
    Yes, agreed. However that particular example was for when even that doesn't work, because the number of files even exceeds the regular (not sudo) limit. Example (200,000 .txt files and 6 .save files that I want to keep):

    Code:
    root@s15:/home/doug/sudo/test# ls -l | wc -l
    200006
    root@s15:/home/doug/sudo/test# rm *.txt
    bash: /bin/rm: Argument list too long
    root@s15:/home/doug/sudo/test#
    root@s15:/home/doug/sudo/test# printf '%s ' *.txt | xargs --max-procs=6 --max-args=1000 rm
    root@s15:/home/doug/sudo/test# ls -l | wc -l
    6
    root@s15:/home/doug/sudo/test#
    EDIT: at the risk of self embarrassment, here is the script I use for to remove the files after my many many files types tests. The old way is still there, but commented out:

    Code:
    doug@s15:~/c$ cat rm_many_files
    #!/bin/dash
    
    # rm_many_files 2020.03.24.
    #       Seems I should have been using xargs
    #       for this all along.
    #
    # rm_many_files 2019.05.26.
    #       Add some progress feedback.
    #       Try other, faster, method.
    #
    # rm_many_files 2018.08.19.
    #       Someimtes, for tests, I have so many files
    #       that rm doesn't work due to "Argument list too long"
    #       break it doen into smaller chunks.
    
    # COUNTER2=0
    # while [ $COUNTER2 -lt 10 ];
    # do
    #   COUNTER1=0
    #   while [ $COUNTER1 -lt 10 ];
    #   do
    #     echo "Deleting: *$COUNTER2$COUNTER1???.txt"
    # #   time rm *$COUNTER2$COUNTER1.txt
    # #   time find . -name "*$COUNTER2$COUNTER1.txt" -delete
    #     time rm *$COUNTER2$COUNTER1???.txt
    #     COUNTER1=$(($COUNTER1+1))
    #   done
    #   COUNTER2=$(($COUNTER2+1))
    # done
    
    printf '%s ' *.txt | xargs --max-procs=6 --max-args=1000 rm
    Last edited by Doug S; March 27th, 2020 at 07:42 AM.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  3. #23
    Join Date
    Mar 2020
    Beans
    16

    Re: What is the each command's different merit between su and sudo?

    Hi!

    I finished reading many pages,
    then I have come back now!


    What I understood that...


    ·Running as always the root privilege user is
    extreamly dangerous, so Ubuntu does not allow
    the user use the root account in default.


    ·In default, the user can not use su command,
    because the root account is not made in
    the installation.

    ·The root account does not exist in default,
    so it has no possibility to be taken over
    by anybody.


    .sudo requires the users to type THEIR OWN password.
    It is cashed for 15minutes, which could be changed
    for the user's preference.


    ·In Linux, users do not use su command,
    but sudo. It is better to carefully run
    command after sudo, though it expires in
    15 minutes, but during that time the novice
    use may run destructive commands.


    ·sodo leaves log that tells the users
    what they have done, which is useful for
    troubleshooting.


    ****

    To kevdog


    Thank you for tell me your experience!


    In some case, two commands are not
    interchangeable.


    The each power is sometimes different
    between sudo and su.


    It is a interesting point!


    ***


    To Tadaen_Sylvermane


    Thank you for a subjective opinion!


    Su allows the users do anything,
    but sudo could be limited for
    the range on the situation.


    Very important point for deploying
    the Linux machine.



    ***


    To TheFu #8 #10 Reply



    A document I read says
    same as you tell me.


    The sudo is also good to
    manage user accounts.


    Short procedure, better for
    the long run manage.


    "Lots of Linux distros don't
    for the use of sudo like Ubuntu does."
    from #10 reply


    I knew the new fact that in the RHEL family
    the user use su.
    Does Ubuntu go along the more secure way?
    It is nice!

    ***

    I will also reply for others next time!
    Thank you, the members of the community for a lot of supports!

  4. #24
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: What is the each command's different merit between su and sudo?

    Quote Originally Posted by Captain Cookie View Post
    ·In default, the user can not use su command,
    because the root account is not made in
    the installation.
    Incorrect. The default user, the one made during the install, will be in the sudo'ers list and can use the su command.

    Quote Originally Posted by Captain Cookie View Post
    ·The root account does not exist in default,
    so it has no possibility to be taken over
    by anybody.
    Incorrect. It exists, but you can not login as root directly.
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  5. #25
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: What is the each command's different merit between su and sudo?

    If you want to know the differences between su and sudo, then start with the basics.

    Start learning about Unix/Linux file permissions (including setuid bits).

    Did you know that a simple `ping' command must run as root? Or when you change your password you are escalating your privileges to root!

    Most people on a modern Unix/Linux distro don't even realize when they are acting as root.


    And there is PAM and polkit ....

  6. #26
    Join Date
    Feb 2011
    Location
    Coquitlam, B.C. Canada
    Beans
    3,515
    Distro
    Ubuntu Development Release

    Re: What is the each command's different merit between su and sudo?

    Quote Originally Posted by sisco311 View Post
    Did you know that a simple `ping' command must run as root?
    Disagree.

    Example:

    Code:
    doug@s18:/media$ ping google.com
    PING google.com (172.217.3.174) 56(84) bytes of data.
    64 bytes from sea15s11-in-f14.1e100.net (172.217.3.174): icmp_seq=1 ttl=57 time=21.8 ms
    64 bytes from sea15s11-in-f14.1e100.net (172.217.3.174): icmp_seq=2 ttl=57 time=22.2 ms
    64 bytes from sea15s11-in-f14.1e100.net (172.217.3.174): icmp_seq=3 ttl=57 time=22.1 ms
    64 bytes from sea15s11-in-f14.1e100.net (172.217.3.174): icmp_seq=4 ttl=57 time=22.2 ms
    ^C
    --- google.com ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3004ms
    rtt min/avg/max/mdev = 21.763/22.057/22.168/0.170 ms
    Any follow-up information on your issue would be appreciated. Please have the courtesy to report back.

  7. #27
    Join Date
    Mar 2020
    Beans
    16

    Re: What is the each command's different merit between su and sudo?

    Thank you, Doug S!
    Now I have checked replies.
    I have assumed that ubuntu does not make the root account.
    But Just impossible to log in directly.
    I got it!

  8. #28
    Join Date
    Mar 2020
    Beans
    16

    Re: What is the each command's different merit between su and sudo?

    Hello, sisco311.


    I have learnt command and scripts from scratch. People around me, nobody uses any Linux and Unix-like OS, so the community is only one that I can rely on.


    Thank you!

  9. #29
    Join Date
    May 2010
    Beans
    3,242

    Re: What is the each command's different merit between su and sudo?

    Quote Originally Posted by TheFu View Post
    man su
    man sudo

    It is all about the options, timeframe, which password is needed, security, groups, and flexibility.
    If you want to allow someone to run 1 command with exactly x, y, z options and nothing else, then su doesn't allow that. sudo does.
    If you want to change the current userid into joesuser because you are joesuser to access some of your files while using a terminal window on a workstation someone else is using, then sudo won't allow that. Only su - joesuser will work.

    In a typical environment today, sudo provides all the capabilities that any home user would need, plus logging of all sudo run commands, so sudo would be the less complex choice. Plus, sudoedit is the best, safest, way I know to edit system files. Every time I see some article somewhere with sudo gedit I cringe a little. Doing that can break a system, if the userid running it hadn't already used gedit before WITHOUT sudo. Actually, this applies to almost any GUI program and sudo or su. In general, don't use either with GUI programs is the best advice. Sure, there are exceptions and techniques to get around the issues caused, but noob-users need to learn much more BEFORE those exceptions can make sense.
    sudo vi file

    Too safe?

  10. #30
    Join Date
    May 2010
    Beans
    3,242

    Re: What is the each command's different merit between su and sudo?

    Quote Originally Posted by Captain Cookie View Post
    Thank you, Doug S!
    Now I have checked replies.
    I have assumed that ubuntu does not make the root account.
    But Just impossible to log in directly.
    I got it!
    There is a root account. It's just disabled for logins

Page 3 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •