Avoid typing sudo on Ubuntu Linux

Q. How do I disable sudo command? I prefer old way to become super-user i.e use of ‘su -‘ command.

A. New Ubuntu Linux v6.06 (LTS) Server is here and one of the annoying feature is use sudo (which is good for Desktop systems) for each command. On a dedicated Linux server I prefer to use su to become a super user and then run command and log out.

So after installation type following commands to setup root account:
sudo passwd root
Input root password.

Now use su for rest of your work:
$ su -
Then carry out all your work.

Please note that I personally recommend using sudo, which is much more secure and better to use. But, since you asked for it I had give you all the instructions.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 25 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
25 comments… add one
  • Anonymous Jun 11, 2006 @ 7:20

    I understand your question.

    as root , open the file /etc/sudoers
    with vi or run the command visudo

    in this file are users and groups and their permissions.

    comment with # at all lines without # (commonly user root and the group %admin and others)

    save ! :)

  • jrm Jun 12, 2006 @ 15:28

    Instead of ‘su -‘ you can use ‘sudo -s -H’ to get you root environment…

    A nifty alias would be ‘alias god=”sudo -s -H”‘. Typing ‘god’ and entering you password will give you almighty powers…

  • Rene Lindsay Sep 24, 2008 @ 14:43

    Isn’t there some way of turning off all these pointless security features in Linux?
    It only makes Linux unreliable and frustrating to use. In fact, it makes linux LESS secure. For instance, just yesterday I tried to add a new user to my Ubuntu. After rebooting, I got a recurring “Authentication failed” which prevented me from even entering a password. In the end I had no choice but to format and reinstall Ubuntu, losing all my documents and personal files in the process.
    I feel much safer using Vista now, because UAC can be turned off and Vista doesnt require a password. So, Vista and wont block me from accessing my own files or lose my data.

    • Dimi Dec 3, 2012 @ 23:54

      Sudo sucks!!!

      • ActionParsnip Dec 4, 2012 @ 11:23


        • Dimi Dec 12, 2012 @ 10:54

          Cause it just makes your life dificult and protects you from nothing. The only thing that happens is that you have to log in as root and then f*ck up everything if you want.

          • Dimi Dec 12, 2012 @ 11:18

            When I use a knife to cut bread I might cut myself but this doesn’t mean I will use a spoon to cut bread.
            In unix to cut bread you need at least a knife (root) and a fork (admin) which is ridiculous.

  • Patrick Sep 25, 2008 @ 12:36

    Hi Rene,

    That you dont know howto to use the security features in linux is not the fault of linux but a lack of knowledge on your side.
    If you where a little more knowledgeable you would have known howto restore your password without reinstalling the machine.
    You can easily achieve this by booting from your ubuntu cd mount your harddrive and replace the password.
    also you could setup key authentication to remotely login with ssh so you dont need a root password anymore.
    in short dont blame Linux for your lack of knowledge.


    • Dimi Dec 12, 2012 @ 11:05

      “also you could setup key authentication to remotely login with ssh so you dont need a root password anymore.”

      Dude! For real??? You have to remote login to your own laptop for example?
      The fact that you maybe have some more knowledge than Rene (which is just a simple user) doesn’t mean that you can write all kinds of c*ap demonstrating.
      Who said that you have to be a sysadmin to use linux? And the same applies to unix (mac users). Why you must have always 2 users in unix systems??
      This is ridiculous.

  • Rene Lindsay Sep 26, 2008 @ 10:43

    Thanks Partic, but I did not LOSE my password. A linux bug prevented me from even entering it. My Password is ‘PASS’. I keep it written down next to the PC in case someone needs access while I’m gone. My point is I DONT work for the CIA, so I dont need or want all this pointless security. And, I’m not some paranoid social outcast who needs to be elevated to ‘superuser’ status just to feel special. Linux security is buggy, unreliable, and risky. Isnt there some way of turning it off? I have never come accross any malware or spyware that is as disruptive as sudo.

  • Metavoid Sep 26, 2008 @ 13:54

    Rene Lindsay:
    Well I hate sudo too and have no need for password so I run my linux as a super user and
    have enabled auto login via KDE so the box just boots directly to the desktop.
    However, thinking that Vista will not just drop dead and block access to your data is frankly
    too naive… My linux is an old knoppix 3.3 and have not reinstalled even I have used it alot. On the other side, I have reinstalled my Xp twice and currently my vista takes ages to boot so I might have to end its suffering.
    Also, next time you get “Authentication” box, just use another shell (ctrl+alt+f1-f8) to login and fix the problem or get your data. You never need to reinstall. Thats a windows fix and luckly you have better options with linux.

  • Rene Lindsay Sep 27, 2008 @ 19:41

    Thanks for the tips, Metavoid. Enabling auto login was a good start, and gets rid of the first login. Directly after that, nm-applet wants the password again. I found I could get rid of this, by using Ubuntu’s Seahorse utility to set the keyring manager’s password to blank.
    Finally I would like to run permanently as root. How do you do this in Ubuntu?

    Ironically, the whole reason I even tried out Ubuntu in the first place, was because I didnt like how Vista’s UAC keeps nagging for permission.

  • Metavoid Sep 29, 2008 @ 9:45

    Your welcome. Glad it worked for you too.
    Ohh, didnt know seahorse could do that :) thx.

    >>Finally I would like to run permanently as root. How do you do this in Ubuntu?

    Well, I tried many times, but installing it as root makes it blow up. The xserver hates me and it stops in shell. So my best bet is to use Autologin in and the su command to raise the permissions when needed. Then you dont have to type sudo a million times, only remember to su to the shell 1 time. Not perfect but better than sudo IMHO. The about sugestion with
    ‘alias god=”sudo -s -H”‘ is also ok.
    Open shell, type god. :)

    Hehe yeah the UAC (User Annoying Control ?) is a features that can make me cry. Luckly you can turn it off.

    Well, I agree with you. Its pretty annoying that it cannot run as root when the whole linux idea is about freedom and then again, not, i guess.
    Even its not wise or anything, I still want to do it.

  • LinuxAdm Dec 6, 2008 @ 22:21

    sudo is LESS secure and specially in the default way configured by Ubuntu cause you’re making superusers everybody regular user belonging to the admin. Besides when you use sudo you don’t even need a superuser password you’re becoming root typing onling your password. Both sudo and su have some flaws because they run with user or group GID enabled, but at least when you use su, the root password is requiered and as soon as you do wan’t you need you exit the terminal or close de application.

    By the way, if you use su -c COMMAND you can run just one task, you don’t need to open a terminal….

  • Daniel Rosenstark Jan 14, 2009 @ 13:37

    I need to shut off sudo because my Ubuntu install is in a VirtualBox, not exposed to the Internet and used only by me.

    Thanks for this article. What is the minus sign for?

  • Code Jun 18, 2009 @ 21:36

    Daniel :

    The ‘-‘ is to source the $PATH variable.
    If you want to test it out.
    login as a normal user in a shell and then do ‘su root’ and try to execute service command or any other command which is included in the path. You will get a ‘command not found’.
    Then do a ‘su – root’ and then try to execute the same command. It works.

  • ActionParsnip Jun 29, 2009 @ 19:13

    This is a ridiculous guide. If yuo use it your system is significantly easier to hack as the root is a common account on all accounts. For all who think sudo is less secure, this is very wrong. If you want a root prompt, simply run:

    sudo -i

    This does not involve enabling the root account and also keeps the user prefs in your home folder, if you sudo su, you become root so all settings for apps will be in /root and not your users home. Also files accessed by sudo su after using this guide will more than likely be made the owner by root, if you start messing with files in your normal users home folder you may not be able to log in without having to boot to recovery mode and chowning

    This sort of guide only helps new users break their systems. Many Linux experts sat and discussed this new user model but hey I guess you guys know better.

  • Mohamed Oct 2, 2009 @ 3:38

    Well you can just type sudo su and put in the password and your running as root
    the alias mo=’sudo -s -H’ only works after i put in the password, but after reboot it i type in “mo” it wont work I have to type the “alias mo=’sudo -s -H'” command and type my password for it to work, is there a way to have this command and password be auto inserted when the computer boots up?
    for example in Dos, if you want to auto format a computer and add label you make a batch or executable that basically types in:
    “echo | y format c:/q”
    add this to the autoexec,bat and it should run fine, just like path = path
    is there a file like the autoexec,bat in ubuntu?

  • ActionParsnip Oct 2, 2009 @ 10:01

    If you edit ~/.bashrc you must either:
    – close all terminals and rerun them
    – reboot
    – or run: source ~/.bahrc

    to apply the alias

  • panda911 Mar 21, 2012 @ 9:11

    Is there a way to fully disable sudo it keeps mucking me up mid command and i dont need the server to be heavily secured

    • Dimi Dec 12, 2012 @ 11:27

      Unfortunately NO.

      All you can do is either:
      log in as root: “su root”

      If user root not created then “sudo passwd root”
      (and give the password for the new user root)

      Or go to sudoers file –> “sudo nano /etc/sudoers”
      and add your username for example “panda911” after the last lines
      —> “panda911 ALL=NOPASSWD:ALL”

      without the ” ” of course.


      • Dimi Dec 12, 2012 @ 11:32

        *option 3 (to prevent sudo from asking for password)

  • Pranav D Nov 6, 2013 @ 13:29

    sudo -s is the biggest tragedy in Ubuntu.
    It gives users full root privilege, and they make OS changes causing havoc on the OS, and system admins have to do all the work to undo the changes.
    Please can anyone help to disble sudo -s

    unfortunately “-s” this is only a switch, so we cannot even disable it, as we would have to disable sudo command, which would defeat the whole purpose. :(

    very sad to see major security breach feature incorporated by Ubuntu. Apart from this Ubuntu is great.

  • Blue Pilgrim Oct 24, 2015 @ 16:47

    I’m 68 and spent years as a programmer, and have used CP/M, Unix, DOS, BOS, OS/2, MVS, and various Windows and micro systems — not exactly a ‘newby’. But all I want now is a usable OS to get things done without having to hack into my system and become a guru in it (again).

    I got a new machine a year ago (Lenova Thinkserver) and still haven’t been able to get it up and working for anything real. I first installed Mint and wasn’t able to find even the programs, or back the system up (denied access). I am not worried about the cat hacking the machine. No backup; no security. If I can’t keep a complete backup of the system then when the disk crashes or the motherboard fails, it’s lost — with all the software, drivers, configurations, directories, etc. Gone.

    I put Debian Gnome live CD up yesterday and looked at a youtube video, and by the time it was done I found Linux had hijacked the machine, lock the screen and me out, and I had to cut the power to stop it from screaming at me in Arabic from the next video Youtube had automatically loaded. Locked me out of my machine — that’s not an OS — that’s malware.

    So far, after a year, all the different distros of Linux are unusable, won’t handle the sound, won’t shut down, won’t give me access to various partitions (and the install programs refuse to keep the partitions I had set up).

    I’m about ready to give up, and since Windows is garbage (and won’t let itself be backed up) that means just give up trying to use the computer — which I paid for, but operating systems think belongs to them. The age of the personal computer for a single user is over, and the user has lost control of his machine.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum