TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Linux commands

sudo Linux Command with Examples

Overview

In this tutorial, we will learn sudo Linux command with some examples. In Linux, the password for the root user( sometimes also called superuser)  is locked by default. The root user cannot log in to the system. It is not recommended to enable the root account in Linux. sudo stands for substitute user do or superuser do.

In the Terminal, we can use sudo for commands that require the root privileges to run the command. The sudo command would prompt your password to enter. The sudo command is configured and users who can run the command are maintained in the /etc/sudoers file.

sudo Linux Command

Command Format

$ sudo <command_that_requires_root_privilege>

For more information type the following command in the Terminal prompt

$ man sudo_root

The sudo command adds a log entry in the /var/log/auth.log file.

# Run commands

testingdocs@ubuntu:~$ sudo uptime
[sudo] password for testingdocs:
23:47:04 up 36 min, 1 user, load average: 0.81, 0.59, 0.69

View the auth.log file:
testingdocs@ubuntu:~$ tail -f /var/log/auth.log

 

sudo auth log entry

# Edit a system file example

We need to perform sudo for any administrative tasks in the Terminal. For example, install an application software package. To extract files, edit system files and copy or move directories, etc.

$ sudo gedit /etc/profile

In this example, we require sudo access to open and edit the system file /etc/profile. We are adding the Java environment variables to the file.

sudo edit etc profile

# Docker commands

We can use the sudo command to elevate the permissions of the user. It’s not just for running docker commands. It’s about running any commands that need elevated permissions.

For example to list the Docker images on the local repository.

$ sudo docker images

sudo Docker images command

More Information on sudo command:

https://wiki.ubuntu.com/RootSudo

–

Linux Basic Commands Tutorial page:

https://www.testingdocs.com/linux-basic-commands-tutorial/

More Information on Ubuntu Linux:
https://ubuntu.com/

Related Posts

Common File Commands in Linux

Linux commands /

Common File Commands in Linux

su linux command

Linux commands /

su Linux Command

ls linux command

Linux commands /

ls Linux Command with Examples

touch create file

Linux commands /

touch Linux Command

change directory Linux

Linux commands /

cd(Change Directory) Linux Command with Examples

‹ Common File Commands in Linux

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version