What Is the Full Path to the Directory That Contains Data Files That Change Constantly
To effectively manage your compute environment in the cloud, you lot need to understand the Linux directory structure, also as key environs variables such as the PATH
variable. Knowing the default locations for certain files or software, and how your machine locates software using the PATH
environment variable tin help you lot troubleshoot many common errors. This blog mail service will introduce you to the Linux directory structure and discuss the importance of the PATH
variable.
The Linux Directory Structure
Linux file systems accept a standard construction that is defined by the Filesystem Hierarchy Standard (FHS), also as some other additions. Nosotros will go through this structure and the main features of each directory below.

The Root Directory: /
The root directory /
is the acme-level directory, significant everything on your Linux system is located underneath this directory. This is why y'all often run into paths and filenames that beginning with /
; this is an unambiguous manner of specifying a file location. If yous navigate to this directory (cd /
) and list the contents (ls
) you volition encounter all of the standard directories as follows:
ubuntu:@ip-10-0-X-XYZ/$ ls bin lib32 proc sys boot lib64 root tmp dev lost+found run usr etc media sbin var dwelling house mnt snap lib opt srv
Nosotros volition now have a closer look at each directory and what each is used for.
User Information Directories
Users often store "user data", such equally analysis inputs or outputs, or program source packages and other files that have been downloaded from the internet, in their home directory. Alternatively, users may store information on a carve up storage drive which they attach to a motorcar, particularly if they need more infinite or if the data need to be moved from one machine to another.
/habitation
- Users home directory
Contains a home folder for each user, eastward.one thousand. /home/ubuntu
. The user home directory is the default directory that the user will showtime in upon login/connexion to the machine.
/root
- Root home directory
The home directory for the root user (instead of /home/root
). See this blog mail service for more information well-nigh the root user.
/mnt
- Mountain directory for storage volumes
A standard location to mount file systems of attached storage volumes (though these tin exist mounted anywhere on the organization if desired). For example, storage volumes that are added during auto creation in RONIN are automatically mounted in /mnt
(e.1000., /mnt/volume1
).
Software Directories
Many standard Linux directories contain software that is either required by the operating system, or primarily used past users. Each Linux distribution contains a diversity of standard, base of operations software packages that are automatically included on every arrangement. Additional software tin be installed by the user in the default software directories via parcel managers such as apt for Debian-based distributions like Ubuntu, YUM for Red Hat Enterprise Linux-based distributions, or snap, an app store for Linux.
/bin
- Essential user executables
All the executable programs (executable files) required during booting and standard operation, including many of import, basic commands, eastward.g. cat
, wc
. This directory is called /bin
, short for "binary", because historically most of the programs hither have been compiled into binary executables, although now y'all can discover readable scripts here.
/sbin
- System assistants executables
Contains executable programs, required by whoever administrates the computer, for maintenance. Note that many of these commands must exist executed using sudo
, and may non even be in your PATH unless you are root
.
/lib
- Essential libraries
Contains libraries (pre-compiled pieces of code that can be reused past software) needed by the executables in the /bin
and /sbin
binder.
/usr
- User executables and information
Contains executables and files used by users, as opposed to excutables and files used past the system. For example, non-essential applications (such as your favorite editor) are located within the /usr/bin
directory instead of the /bin
directory, and non-essential arrangement administration binaries are located in the /usr/sbin
directory instead of the /sbin
directory. Libraries for each are located within the /usr/lib
directory. The /usr/local
directory is designed to exist a place where users can install their own software outside the distribution'southward provided software without worrying about overwriting whatever distribution files.
/opt
- Optional packages
Contains subdirectories for optional software packages. This directory is used past proprietary/third party application software that doesn't obey the standard file organisation hierarchy. With package managers to install software it is relatively rare to encounter heavy use of /opt
.
/snap
- Snap packages
Files and folders from installed snap packages.
Note: Computing clusters created with RONIN often have boosted software and user data directories such as the/apps
and/shared
directories. These directories are mounted by each compute node in the cluster, so they can access a single re-create of programs and data. For more data, refer to this weblog mail service.
Other Arrangement Directories
These directories comprise data that is relevant for running and configuring the Linux organisation and user applications. With the exception of /tmp
and possibly /var
, you won't typically need to venture into these directories, but it is still helpful to know what they are for:
/boot
- Boot files
Files required when booting the organisation.
/dev
- Device files
Files used to stand for hardware devices on the system, eastward.g. the root drive and attached storage drives.
/etc
- Configuration files
System-wide application configuration files, due east.g. the startup, shutdown, kickoff, stop script for programs that manage things most the system in the background.
/lost+plant
- Recovered files
Any files that are recovered by the fsck
utility after impairment to the file organisation.
/media
- Removable media
Subdirectories created for removable media devices, e.yard. cdrom.
/proc
- Kernel and process files
Contains information on the organization and running processes.
/run
- Application run files
Transient file storage for application runtime files.
/srv
- Service data
Information for services provided past the system, e.g. website files.
/sys
- sysfs filesystem
A virtual filesystem, which stores and allows modification of the devices connected to the system.
/tmp
- Temporary files
Stores temporary files for the users or organization. Files are either deleted by arrangement utilities or upon reboot of the machine. This directory is a useful places for you to write small temporary files as you create your scripts. This is a good habit to go into; it is easy to discover these to delete them, and you will be certain that these directories are never shared across compute nodes.
/var
- Variable information files
Writable counterpart to the /usr
directory. It includes spool directories and files, administrative and logging information, and transient and temporary files (such every bit those in/usr/tmp
). This is a good identify to await if y'all are trying to find system logging information if something is going wrong with your car. For example, /var/log
on the head node of a cluster contains information about any failures in cluster configuration.
Linux Environment Variables
Now that you empathize the Linux file organization a bit better, it's also of import to know that there are a number of default environment variables that are used by the system.
To view all of the environment variables that are assail your arrangement, run the command printenv
Some mutual environment variables include:
USER
= The current logged in user
Dwelling house
= The home directory of the electric current user
PATH
= A list of directories to be searched when executing commands. When yous run a control without specifying a path, the system will search those directories in this order and use the first found executable.
The $PATH
Variable
The PATH
variable is ane of the about important environment variables to know about when managing your ain software in the cloud, only what exactly does this variable do?
Well, whenever you lot need to specify a particular file or directory in a control, you ofttimes utilise an absolute path (i.e. the complete path starting from the root directory e.yard. /home/ubuntu/inputs/myfile.txt
) or a relative path (i.east. a path starting from the current directory). These paths specify the location of the file or directory and then that the command can find it.
To execute a command, nosotros can also phone call upon software executables. We can tell the organization what command to execute in the same mode, by providing a path, but this is a lot of typing! For example, imagine having to type/usr/bin/cd
every time you wanted to change directories, instead of simply cd
. The PATH
environment variable overcomes this effect past providing a listing of directories that contain program executables yous may wish to execute.
By default, the path variable is always set to include some standard directories described in the section above such as /bin
, /sbin
, /usr/bin
, /usr/sbin
and /usr/local/bin
. Yous can come across what directories are listed in your PATH
variable by running echo $PATH
(each directory is separated by a :
). Y'all can also view the exact path to any command or executable that is within your PATH
using the which
control. For case, to find where the grep
executable is located, use which grep
.
Annotation: If you have previously worked with shared computing clusters, yous may be used to themodule load
command when wanting to use a particular program. This control works by modifying yourPATH
and other environs variables (if required) so that your program is set up for yous to use.
If you lot have installed a new program on your machine simply you are getting a "command non plant" mistake (or if the which
control cannot observe your executable), it is probable that your new software is located somewhere outside those directories listed in your current PATH
. So, to ensure your new program tin can be plant without always having to specify the path to the programme, y'all can either motion or copy the program executable to a directory that is already listed in your path variable, OR add together a new directory to your PATH
that contains the programme.
There are ii ways to add a new directory to your PATH
. The starting time is a temporary solution where you only re-consign the PATH
variable with the added directory included. For instance, if you lot wanted to add the directory /home/ubuntu/myprogram/bin
to the Terminate of your PATH
, you would run: export PATH=$PATH:/home/ubuntu/myprogram/bin
. Alternatively, to add the directory to the START of your PATH
, you would run: export PATH=/dwelling house/ubuntu/myprogram/bin:$PATH
(encounter Note about directory social club below). This method will only change your PATH
in the current session and then the changes will not be saved if you open another session. If you want the changes to be made permanently, you volition need to add together the same export
command to your ~/.bashrc
file. That way the consign command volition be run whenever you launch a new session.
Note: The gild of directories in yourPATH
is of import because if the aforementioned program (or executable with the aforementioned name) is found in two dissimilar directories, the one that is institute first in your path will be used. And then go along this in listen when adding new directories to your path to decide where they should sit in the listing of directories in yourPATH
. It is also important to know that each user will take their ainPATH
variable, so the root user may not search through the same directories every bit the standard user.
With your newfound cognition of the Linux file system, and the highly important PATH
variable, you should now experience more confident in managing your compute environment in the cloud. Your Linux machine is no longer a blackness box of directories with magical commands that appear out of nowhere.
Now get and deal with those pesky "control not plant" errors!

Source: https://blog.ronin.cloud/linux-directories-paths/
0 Response to "What Is the Full Path to the Directory That Contains Data Files That Change Constantly"
Postar um comentário