Linux file system

Linux file system:

 

Before working with Linux / Unix files, the most important thing to know –

 

Linux / unix always case sensitive!

 

That is, they consider the uppercase and lowercase letters different.

 

Each of the following files is considered as a different file in Linux

 

README

readme

Readme

ReadMe

 

Everything in Linux is considered as a file. When you type something on the screen and shows you it actually writes it in a file. When it sends a data with the help of a modem, it actually thinks that he is just writing in a file – nothing more than that. So whatever hardware you have on your machine, including ports, hard drives, video cards, etc., they are shown as files in the Linux file system or not. There are directories/folders for files in the file system’s root paths. You can find numerous files related to hardware in this folder. Just like a device driver in Windows, the files in Linux work for the device driver. This device driver works with the real hardware and communicates with the program.

 

It is a good idea to know how Linux identifies IDE harddisks. If I do not know, I have already said that, for most systems, there are two IDE channels, one of which is called primary and the second is secondary. On each channel, you can connect two hard drives, one of which is called Master and the other is Slave. That’s why you have to look at the jumper settings while installing a hard drive. Linux drives the drives as follows:

 

Primary Master-hda

Primary Slave-hdb

Secondary Master-hdc

Secondary Slave-hdd

 

Presently the new hard drives are shown as sda, sdb, sdc, instead of hda, hdb, hdc etc, depending on the saturation. If there is more than one partition on the hard disk, each partition is marked with a number at the end of the drive name mentioned above. For example: if you have a hard disk and have three partitions, then the first drive (c 🙂 would be hda1 or sda1. Then there are three more drive letters reserved for the primary part of the partition, so the next drives will show the serial number 5. That means the remaining two partitions will be displayed as hda5 / sda5, hda6 / sda6. To access these partitions, they must be mounted, although they are currently mounted in several distro versions. The partitions that will be created during installation are automatically mounted during Linux boot.

 

Command to see the hard disk partitions:

 

fdisk -l

 

Since DVD-ROM is a removable device, so it can not get it immediately after entering it. You may need to mount the first mount with the mount command to view the DVD. Since my system has a hard drive mounted on the SATA drive, it is the first drive on the first IDE channel. As a result, the command to mount it will be as follows:

 

mount -t iso9660 / dev / hda / cdrom

 

The top command may seem a little unfamiliar at first, but it is actually very simple. Let’s look at the options at a glance.

 

* mount turns a device into a part of the file system

 

* -t iso9660 refers to the mounted file system’s format. (The standard format for data CDs and most DVD iso9660 but if we mount the floppy drive it will be msdos)

 

* / dev / hda The path to the device file of the DVD / CDROM drive. This is the first hard drive’s first IDE channel by hda a. SCSI Hard Drive For DVD On My Machine DVD ROM shows scd.

 

* / cdrom refers to a directory or folder of the system where it will be mounted and accessed. It must be pre-built, but it can be made anywhere in any name. For this, create a folder by using the mkdir command such as yourname and the above command instead of / cdrom / yourname – as you want.

 

 

Mount the DVD ROM drive in the / cdrom directory (which is basically installed during the installation) with the mount command above. In order to enter a directory that is mapped to a device, call him a mount point. So when mounted on a DVD ROM, just enter the following command to enter the mount point that is mounted:

 

cd / cdrom

 

And use the ls command to display files. If you get the message like the line below

 

kernel does not recognize / dev / hda

 

Then your DVD-ROM is probably connected to the primary ID channel as a slave (ie / dev / hdb).

Debian usually generates the / cdrom directory during installation. In other distributions, it is usually under the / mnt directory. To change the target directory for mounting on these systems, the following is as follows:

 

mount -t iso9660 / dev / hda / mnt / cdrom

 

The way you mount for removable drives, the same way they are unmounted after the work. Press the Eject Button to use the unmount command, so that the DVD ROM may not be too long. For this, type umount and type the file system mount points

 

umount / mnt / cdrom

One important aspect of the Linux file system is that file extensions do not point to the operating system here. The typical file name in Windows usually involves the extension of three characters with a period (.) Sign indicating its function – for example, it is a program (.exe) or a common MS Word file (.doc). There is no such extension in Linux. A file can have a period (.) But it is not considered as an extension to Linux.

However, in some applications of Linux, they can mark their data files with extensions such as the Apache Web server, finding files with .htm, .html, and .shtml, and they may think that the extension. Technically but they are not at all and they have nothing to do with Linux / UNIX operating systems.

 

You may have a file name like this.is.a.file if you want. The operating system is all about one. So how can Linux understand that this file is a program/application? Linux has exclusive permissions for each file that is read-write, write and execute. You only have to set the execute permissions to a file/script, then it is an executable program that will understand the operating system. In this case, you can not execute a program or script file and execute permissions, but in that case, the operating system will try to run it as a shell script command. As a result, you can get any error messages – just because of the text inside the file, you can get an empty hard disk as a result!

 

I do not want to discuss a comprehensive discussion of file permissions here. Just want to discuss some basics.

 

If you are working in DOS, then typing the following command at a shell prompt can make Linux easier to work with:

 

alias dir = “ls -laF”

 

It allows the dir command used in DOS to access the file list instead of Linux’s ls command. Although I used to be Linux version more frequent, I did a mistake in Windows sometimes with ls command. Except for any parameter, only the ls command provides a simple list, which is not even a file and no directory. To see a better list, you have to give command ls -laF but you have to type it every time. So, after giving the above command, you just need to type dir.

 

drwxrwxrwx 3 keith web 4096 Aug 8 03:59 ./

dr-xr-sr-x 3 keith web 4096 Aug 6 13:56 ../

-rw-r – r– 1 keith web 17181 Aug 6 16:04 bdl21dlx.zip

-rwxr-xr-x 1 web 15818 Aug 6 16:04 bdlogger.cgi *

-rw-r – r– 1 keith web 1 Aug 6 16:04 history.log

-rw-r – r– 1 keith web 1 Aug 6 16:04 pagehits.cnt

-rw-r – r– 1 keith web 1 Aug 6 16:04 period.log

-rw-r – r– 1 keith web 30586 Aug 6 16:04 readme.txt

-rw-r – r– 1 keith web 1 Aug 6 16:04 trigger.dat

drwxrwxr-x 2 keith web 4096 Aug 8 03:59 zips /

 

After a “zips /”, a directory that indicates it is (just as indicated by the left d of the permissions block at the beginning of the line). After the bdlogger.cgi file * it is directed to an executable file with *. In the permutation block of the bdlogger.cgi file -rwxr-xr -x (which is basically octet as 755) (x) with the help of flags and it is understood that it is an executable file.

 

Here’s a point to note that Linux only uses a special purpose period for file names. Files that start with a period of time are usually a configuration file. There is a file named .profile in the Linux / UNIX home folder of every user. This file is used to set up a user’s environment (such as the default shell, environment variables, etc.). It works like a DOS config.sys file. vi Text Editor has its own configuration file (.vimrc). There are more such character-based programs for telnet and ftp and these programs can be automated by using their configuration files. For example, you can set up an FTP’s profile and instruct the cron scheduler program to download a log file from your website every night. If the ls command is given only when the list of files that start with a period (.) Can not be seen because we used the command ls -laF in the above command.

 

Regarding the home directory, it is said that every time a new user is created, a personal home directory/folder is created and simultaneously created. This folder is named after the username which is in the / home directory path. If you want to return to the home directory from any location on the Linux file system, type cd and press enter.

 

Within this context, a special folder named pub (public download files) on an FTP server is actually located in the / home / ftp folder.

 

Learning Linux’s file system structure can take a little while and find out where a specific file is first, it seems a bit difficult at first. But there are two commands to help you. So hopefully they will not get much velocity if they learn.

 

If you have experience working on a DOS operating system, then there will be ideas about the path to yours. Path (PATH) is only a list of directories that are called folders in Windows and called. If DOS gives commands to run a program, then it first tries to find it in the current folder. If the program does not find it, then it searches for it in the predefined path and every one of the directories mentioned in the path searches for the .exe extension file. If found, the program runs from that place. If DOS does not find it at all, then it will display the famously known message in front of us which we are familiar with,

 

Bad command or file name

 

This means that the file may be somewhere else on the drive, but it is not in the current directory, or there is no directory listing in the path, so you got the above message.

 

There are Linux / UNIX and its own path. In fact, every user has his own path, which he can customize according to his own needs. The directory lists that are in this path are mainly the sum of standard locations in order to save the program files. Standard directories/folders are stored in executable binary files respectively

• / bin

• / usr / bin

• / usr / sbin

The where is command lets you find out if there are any files in the directories specified in the path.

 

where is ls

The result of the above command will be:

 

ls: / bin / ls

 

Which means the ls file is located in the / bin directory. If it does not find anything then it will provide the following results

 

ls:

 

With the where is find out if there is a file (usually program files) in the directory specified in the path. It can not work on UNIX machines (instead of what you use).

 

The command can show some paths rather than one that shows that the program is installed in some places (maybe different versions). For example, a Web server company may install two versions of Perl Interpreter simultaneously to provide a total support to CGI scripts. However, this list will show you where you have multiple copies of the program. If you run a program in the shell prompt, it is not possible to understand which one is actually running. To understand this, you need to look at the sequence of directory paths. It needs to be remembered, the system runs the program from which you can find the first folder in the directory listed here. Let’s see if there is a detailed discussion on the path at this time. For this, command:

 

echo $ PATH

 

Use the find command to find any type of file, including the program file, on the hard disk anyway (without paths and everywhere). This command requires a starting point and a partial or full name for the file that will be searched. For example, if you want to find the whole hard disk, start the route (/) directory – just like the following:

 

find / -name ‘ls’

 

The directory that is in the directory and if you want to search only in its subdirectory, the command will be as follows:

 

find -name ‘ls’

 

. (A period) with the current directory in Linux / UNIX is summarized and it can also be used when giving commands. Two levels (..) are one level top parent directory, and this is also the time when the command is complete

 

If there is a lot of files in a directory, most files will not be visible if you command ls, but if you piping the commands above and then you will stop after showing one screen and wait for the next list to show. The pipe character (|) is located on top of the keyboard \ symbol.

 

This is a very simple example. You can do a lot of automation with the help of Linux command. For this, you can see the grep and sort command manuals, which can be used to apply some more automation tricks.

 

Another important tool for automation is “Redirect”. Everything that is commonly seen on the screen can be redirected to a text file or a device like a printer or a modem where Linux considers everything as a file. Greater (>) sign is used for this. For example, if you want to print the command to see a list of files, print the command

 

ls> lp0

 

If you want to save in a text file, output the command:

 

ls / etc> output

 

Here the output is the file name. You will see a file called output in your home folder, where you can see whatever is in the / etc folder in any text editor.

 

Piping and redirection, as well as rich commands used in Linux, can be used to create a system that will do everything yourself at the time of your coffee.

 

The Linux / UNIX file system supports another type of file named Symboiled Links which is commonly referred to as Simlinkx. It works like shortcuts in Windows. It is used to create symlinks for binary executable files and data files so that they appear to have many places on the hard disk at the same time. But you can also create a symlink for a directory so that the directory can be accessed from different places on the file system. The biggest advantage of this is that when you make a change to a file or directory, all those changes related to it will be automatically updated. Not all copies of a file are needed to be modified in all places.

 

Create a soft symlink in the document folder in your home folder with the following commands on the desktop:

 

ln -s / home / zahid / documents / / home / zahid / Desktop /

 

 

Now you can access the document folder by clicking on the link directly from the desktop.

 

Two types of symmetric links are seen – Hard and soft – soft Symbolic links are our most familiar and widely used. Windows shortcuts are similar to Linux’s soft Simulink. On the other hand, hard symlink creates a real copy of a file/directory. When you use ls command -> sign can be easily said that it is a symlink because it points to the original file with a symbol. A symlink is more used in the startup directory. When the system starts at a specific run level, it runs the bootup shell scripts in the Startup directory. There are different directories for each run level. Many scripts are run without the run level. Instead of copying scripts separately to each run level startup directory (for example, /etc/rc0.d, /etc/rc1.d, /etc/rc2.d etc), all scripts are placed in a directory (/etc/init.d) and According to the demand of specific run levels (such as rc2.d), only the scripts have their symlinks placed.

 

For example shell scripts are called cron for cron background scheduler and it is all running at run level. It is located in the /etc/init.d directory, where there are all startup scripts. “init.d” is a short form of the Greek word “start daemon”. If you have the command to see the file list in the start-up directory /etc/rc2.d of the run level 2 with the command ls, then you will see the soft symlink for the cron startup.

 

S89cron -> ../init.d/cron

 

If you need to change the cron script here, then only the original cron script will be changed. All changes will be updated at all run levels. It is also a good solution to save disk space. One important thing is that in this symlink, the file has to be set to work permit. They do not use the original file permissions for themselves. If a symlink points to an executable script, then those symlinks must be set similarly executable permissions.