Scroll Top

Running Linux Su and Sudo Commands to Work As Root and Viewing the Linux Root User Home Directory

Example of Using the Linux su Command

Run the Linux su command with the dash option, as in “su -” (but not quotes). Then type in the password for the root user and press Enter. If you’re using Ubuntu, see the alternate steps below.

Now type in the pwd command and press Enter to see your “path to (current) working directory”.

If the su (superuser) command above worked, you should see the directory path of /root which indicates that you are now working as the root user at the Linux command line.

Type in exit and press Enter to go back to working as a “regular” user.

Example of Using the Linux sudo Command

If you’re using Ubuntu or a variation, such as Kubuntu or Edubuntu, then run “sudo -i” (again, without the quotation marks) to start working at the command line prompt as the root user. You will need to type in the password of the first Linux user created on your system (during installation) and press Enter after running the sudo command. The far right character in of your command prompt likely changed from $ to # to indicate you are working as the root user.

Now run pwd (by itself) to see the current directory path of your current user. If the sudo command above worked, your directory path will be /root and this shows you that you are now working at the Linux command line as the root user.

The Linux concepts and commands here apply to ALL Linux distributions, including Ubuntu, SUSE, openSUSE, Debian, Red Hat, Fedora and Slackware Linux.



AUTOPOST by BEDEWY VISIT GAHZLY

Related Posts

Privacy Preferences
When you visit our website, it may store information through your browser from specific services, usually in form of cookies. Here you can change your privacy preferences. Please note that blocking some types of cookies may impact your experience on our website and the services we offer.