Avatar of naseeam
naseeamFlag for United States of America

asked on 

Why can't I view contents of my home directory when logged in as root?

I have Ubuntu 18.04 LTS (64-bit) laptop. Did I setup my root account properly?  When I login to my 'root' account, I cannot view contents of my home directory?  I cannot access /root directory?
User generated image
LinuxLinux SecurityUbuntuLinux OS DevLinux Distributions

Avatar of undefined
Last Comment
naseeam
Avatar of arnold
arnold
Flag of United States of America image

one option is that /root does not exist.

ls -l / | grep -i root
su root does not reinitialize the login
su - root
should reinitialize the user's parameters and place the account at the root's home dir as defined in /etc/passwd
grep -i root /etc/passwd
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

User generated image
User generated image
User generated image
Avatar of arnold
arnold
Flag of United States of America image

The /root directory is empty.

Run ls -la to see the hidden files.
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

User generated image
Avatar of arnold
arnold
Flag of United States of America image

Cd /root
ls -la

User directories do not have files within on install outside the hidden settings from /etc/skel
Commonly .bashrc, .profile .login in order to see them, you gave to use the -a option to ls.
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

User generated image
Avatar of arnold
arnold
Flag of United States of America image

What are you expe ting to see?

The location is empty...

What where you expecting?
Avatar of David Favor
David Favor
Flag of United States of America image

1) In all the above, I see no pwd command to show where you've logged in.

Use pwd to show your the exact directory.

2) You can find the dir Linux will use for your home directory by posting the output of...

grep ^root: /etc/passwd

Open in new window

3) Also to actually move into the root director at login, you must simulate a real login with su, as in...

su - root

Open in new window


Notice the "-" which simulates a login.

If you do a plain su, no "-" specified, then your environment + current working directory remain the same, reflecting values based on your initial login, not your su command.
Avatar of David Favor
David Favor
Flag of United States of America image

Start by posting pwd before you su.

Then do a "su - root".

Then post pwd after your su command.
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

>> What are you expe ting to see?
I wrote simplest device driver (Hello World!), which includes some header files.  I was expecting to see header files in /root/include/linux directory.

User generated image
Avatar of arnold
arnold
Flag of United States of America image

When did you do that, how did you do that..
If you su root you remained where you were before with fewer privileges.

Data dies not normally go into /root unless the driver was built but period to that was configured with --prefix=/root as an option

You may have run make install, but often the destination is /usr/local or /usr depending on the platform and package of the source......
Avatar of arnold
arnold
Flag of United States of America image

The other option
Make BASEDIR=/root install
Will redirect the install directives into /root the above option in some can be used to create a package...
Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

>> When did you do that
Sorry I didn't write this driver yet.  I saw this driver in a book.  
I didn't write the driver yet because I didn't see any header files in my system that are included in this driver.
SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of serialband
serialband
Flag of Ukraine image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

To find out where your source files are, use locate. E.g.
locate helloworld.c

Open in new window

Avatar of naseeam
naseeam
Flag of United States of America image

ASKER

Thank you very much for great information and solutions.
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo