Skip to main content

Navigating The File System In Linux

In my opinion, the most important thing to learn as a newbie in the Linux system is navigating the file system. Files in Linux systems are organized in a hierarchical directory structure, that is, a tree-like pattern of directories or folders. The first directory is called the root directory and it contains files and subdirectories which contain even more files and directories.



Linux unlike Windows has a single file system tree regardless of how many storage devices or drives are attached or mounted to the computer. Storage devices are mounted at different points of the tree according to the inclination of the system administrator.

Windows on the other hand, has a separate file system for each storage device.

Current Working Directory 
To display the current working directory, we use the pwd command (print working directory).
By default, when we start a terminal session, our home directory is usually our current working directory. Each user account in a Linux system is given its own home directory and this is the only place where a regular user is allowed to write files.

Listing Directory Contents.
To list the files and directories in any directory, including the current working directory, we use the ls command. 

Changing the current working directory.
To change your current working directory, we use the cd command which is short for change directory.
To change this, type cd followed by the path name of the desired working directory. 
Pathname can be defined as the route taken to the the desired directory. They can be specified either as absolute or relative pathnames. 

Absolute pathnames
Also referred to as absolute path or full path.
It specifies the location of a file or directory from the root directory(/).
An absolute pathname begins with the root directory and follows the tree branch by branch to the desired directory or file. We'll use the example of a directory in your system where most of your system's programs are installed. The pathname is /usr/bin.

So we'll move into that directory using
cd /usr/bin



Relative Pathnames
Starts from the working directory. To do this, it uses the following special symbols to represent relative positions in the file system tree:
dot (.) - represents the working directory.
dot dot (..) - refers to the working directory's parent directory.

Helpful Shortcuts
cd  
Changes the working directory to your home directory.
cd -
Changes the working directory to the previous working directory.
cd -username
canges the working directory to the home directory of username. Example cd -eneri will change the directory to the home directory of user eneri.

Facts about Filenames
  • Filenames that begin with a period character (.) are hidden. This means ls will only list them when you type in ls -a.
  • Filenames and command are case sensitive. File12 is not the same as file 12.
  • Linux has no concept of  file extension. You may name files any way you like.
  • Limit punctuation characters to period(.) dash(-) and underscore(_). Do not embed spaces in filenames, instead use the punctuations aforementioned.
 
 

Comments