Linux Root System Directory – Ls (List Directory) Command Examples – Quick Tips

linux37 Linux Root System Directory   Ls (List Directory) Command Examples   Quick Tips
Clyde E. Boom asked:

Listing the Linux root Directory Contents – A System Directory Below The / Directory

The directory named “root”, is located below the / directory and is one of the many Linux system directories, such as boot, bin, sbin and etc that are located below the / directory.

Now look at the contents of the /root directory contents and learn what Linux uses this directory for.

Listing the System Directories and the /root Directory – Linux ls Command Examples

The following ls command uses the “pattern” of r* to list all directories beginning with r and uses the options of -l (long) and -d (directories only).

$ ls -ld /r*

This command shows the /root directory, which is the “home” directory of the user named root.

Linux Commands Training Tips: The root user is also referred to as the Superuser and sometimes this is abbreviated as su. The Linux su and sudo commands are used at the command line prompt to change from working as a “non-root” user to working as the root user.

Viewing the Contents in the root Directory

Now look at the contents of the home directory of the Superuser.

$ ls -la /root

If you are not logged in as the root user, you will see a message similar to “permission denied” because you don’t have access to this path.

Run the su command with the – (dash) option to do the equivalent of logging in as the root user (unless you are using Ubuntu or a variation of this distro).

Or, run the sudo command with the -i option to do the same as above if you are using Ubuntu, Kubuntu or another variation of this distro.

Your prompt may show a ~ to represent the home directory of the current user (instead of the name of the current directory).

The pwd command below displays the “path to working directory” (which is the current directory).

Now use a ; (semicolon) to run two commands at once and list the contents of the current directory and then see the path to it.

$ ls -la ; pwd

The -l for “long” and -a for “all” (including hidden files) options are used above to see every file in the root user’s home directory.

Now run the same command, but without the -a option, to see only the “non-hidden” files.

Press the up arrow key and then backspace to remove the -a option and then press Enter to run the command.

$ cd /root ; ls -l
The root Home Directory of the User By the Same Name

Immediately after installing some Linux distributions, this directory may be completely empty – and on others, there may be lots of files, including configuration files.

For example, after installing Red Hat Linux, /root contains a file named anaconda.cfg that is used to configure installation settings and also several hidden files that are prefixed with a dot that configure the Linux desktop.

The Linux root system directory concepts and command examples shown here apply to ALL Linux distributions, including SUSE, openSUSE, Ubuntu, Debian, Fedora, Slackware and Red Hat Linux.

Caffeinated Content

Related Posts

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment