linux-tutorial

LINUX Directory Management Overview

LINUX/UNIX uses some well-defined, hierarchical structure to maintain or organized files and directories for the system. You can commonly relate it to the tree structure. Like a tree it has a single root node, it does not start with /. and all other directories are contained below it.

We can store child directories and files in a directory.

Home Directory

A home directory is a directory or folder commonly given to a user on a network or Unix or Linux variant operating system

You will be doing much of your work in your home directory and subdirectories that you’ll be creating to organize your files.

You can type the below command to go to the home directory.

$cd ~

~ indicates the home directory. for going to other users home directory, use the following command −

cd ~username

/bin – Binaries

The ‘/bin’ directly contains the executable files of many basic shell commands like ls, cp, cd etc. Mostly the programs are in binary format here and accessible by all the users in the Linux system.

/dev – Device files

This directory only contains special files, including those relating to the devices. These are virtual files, not physically on the disk.

Some interesting examples of these files are:

/dev/zero: contains an infinite sequence of 0

/dev/random: contains an infinite sequence of random values

/etc – Configuration files

The /etc directory contains the core configuration files of the system, used primarily by the administrator and services, such as the password file and networking files.

If you need to make changes in system configuration (for example changing the hostname), this is where you’ll find the respective files.

/usr – User binaries and program data

in ‘/usr’ go all the executable files, libraries, source of most of the system programs. For this reason, most of the files contained therein is read­only (for the normal user)

/lib – Shared libraries

The /lib directory holds the libraries needed by the binaries in /bin and /sbin directories.

Libraries needed by the binaries in the /usr/bin and /usr/sbin are located in the directory /usr/lib.

/sbin – System binaries

This is similar to the /bin directory. It can run by root or a SUDO user. You can think of the ‘s’ in ‘sbin’ as super or sudo.

/tmp – Temporary files

As the name suggests, this directory holds temporary files. Many applications use this directory to store temporary files. Even you can use directory to store temporary files.

After restart /tmp directory cleaned. LINUX systems also delete old files automatically so do not store anything important here.

/var – Variable data files

Var, short for variable, is where programs store runtime information like system logging, user tracking, caches, and other files that system programs create and manage.

The files stored here and NOT cleaned automatically. Checking the login history of the Linux system, just check the content of the file in /var/log/wtmp.

/boot – Boot files

The ‘/boot’ directory contains the files of the kernel and boot image,. It is often advisable that the directory resides in a partition at the beginning of the disc.

/proc – Process and kernel files

The ‘/proc’ directory contains information about currently running processes and kernel parameters.

Absolute/Relative Pathnames

Directories are arranged in a hierarchy with root (/) at the top. The position of any file within the hierarchy is described by its pathname.

examples of absolute file names.

/etc/cpuinfo

/etc/passwd/

/bin/user/Subhajit

A pathname can also be relative to your current working directory. Relative pathnames never begin with /

chem/notes

personal/res

To find the path of where you are standing – use the command shown below-

pwd

/bin/user/Subhajit

Listing Directories

ls <Dir name>

Create a Directory

mkdir <dirname>

Remove a Directory

rm -rf <dirname>

RECOMMENDED ARTICLES





Leave a Reply

Your email address will not be published. Required fields are marked *