Linux Learning Linux Directory

Source: Internet
Author: User
Tags system log

Types of File systems

Linux has four basic file system types: Normal files, directory files, connection files, and special files, which can be identified by the file command.

Ordinary files: such as text files, C language meta code, shell scripts, binary executable files, etc., can be used cat, less, more, VI, Emacs to see the content, with the MV to rename.

Catalog files: Include file names, subdirectory names, and their pointers. It is the only place where Linux stores file names, and LS is used to list directory files.

Connection file: Is the directory entry that points to the same index node. With LS to see Yes, the sign of the connection file starts with L, and the file face is "--" points to the attached file.

Special files: Some Linux devices such as disks, terminals, printers, etc. are represented in the file system, then a class of files are special files, often placed in the/dev directory. For example, floppy drive A is called/dev/fd0. Linux does not have a C: concept, but instead uses/dev/had from the first hard drive.

For Linux novices, one of the most confusing questions is where do files exist? Especially for those of you who turn from Windows, the directory structure of Linux looks strange. So, here's a look at the main directories under Linux and what they're all about.

/

This is the root directory. The mothership. The home field. The one and only top directory for your whole computer. everything, and I mean everything startshere. When you type '/home ' What are you ' re really saying are ' start at/and then go to the home directory. '

/

This is the root directory. For your computer, there is only one root directory. All things, I mean, everything starts here. For example: When you enter "/home" in the terminal, you are actually telling the computer to start with the/(root directory) and then go to the home directory.

/root

This is the directory of the system administrator (root user). For the system, the system administrator is like God, it can do anything to the system, even including deleting your files. Therefore, be careful with the root account.

/bin

The standard (or default) Linux tools are stored here, such as "LS", "VI" and "more". Typically, this directory is already included in your "path" system variable. What do you mean? is: When you enter LS in the terminal, the system will go to the/bin directory to find out if there is LS this program.

/etc

The system configuration files are mainly stored here. For example: You installed the Samba suite, and when you want to modify the Samba configuration file, you will find that they (config file) are in the/etc/samba directory.

/dev

The main store is the files related to the device (including peripherals) (Unix and Linux systems treat the device as a file). Do you want to connect the printer? The system starts working from this directory. There are also some disk drivers, USB drivers, etc. are put in this directory.

/home

Your personal data is primarily stored here. Each user's settings file, the user's desktop folder, and the user's data are all placed here. Each user has his or her own user directory, located at:/home/user name. Of course, the root user is excluded.

/tmp

This is the temp directory. For some programs, some files are used two times a time, they are no longer used, and files like this are placed here. Some Linux systems automatically clean up this directory on a regular basis, so don't put important data here.

/usr

In this directory, you can find additional tools that are not suitable for use in/bin or/etc directories. Like games, some of the print tools pull and so on. The/usr directory contains many subdirectories: The/usr/bin directory is used for storing programs, and/usr/share is used to store some shared data, such as music files or icons, etc./usr/lib directories are used to store those that cannot be run directly, However, it is a function library file that is necessary for many programs to run. Your package Manager (which should be "new") will automatically help you manage the/usr directory.

/opt

Here the main storage of those optional programs. Would you like to try out the latest Firefox beta? Then put it in the/opt directory, so that when you try to erase Firefox, you can delete it directly, without affecting any other system settings. The program installed in the/OPT directory, all of its data, library files, etc. are placed under the same directory.

For example: Just installed the beta version of Firefox, can be installed in the/opt/firefox_beta directory, the/opt/firefox_beta directory contains all the files needed to run Firefox, libraries, data and so on. To remove Firefox, you can simply delete the/opt/firefox_beta directory.

/usr/local

The main store is the software that is installed manually, that is, software that is not installed through "new" or Apt-get . it has a similar directory structure to the/usr directory . Let the package Manager manage the/usr directory, and put the custom script (scripts) under the/usr/local directory, I think this should be a good idea.

/media

Some Linux distributions use this directory to mount the USB interface's removable hard drives (including USB sticks), CD/DVD drives, and so on.

Add:

The commands required by the/bin system are located in this directory, such as LS, CP, mkdir and so on, and the functions and /usr/bin are similar, and the files in this directory are all executable commands that can be used by ordinary users. The most basic command required as a base system is here (/usr/bin and/usr/sbin are similar to the "/" root directory (/bin and/sbin), but not for basic booting (for example, in emergency maintenance). Most of the commands are in this directory. )。

/boot Linux kernel and the file directories required for boot system programs, such as Vmlinuz initrd.img files, are located in this directory. In general, thegrub or LILO system Boot Manager is also located in this directory .

/lost+found in the ext2 or ext3 file system, when the system crashes unexpectedly or the machine shuts down unexpectedly, some file fragments are placed here. when the system starts, the Fsck tool checks here and repairs the corrupted file system . Sometimes problems with the system, a lot of files are moved to this directory, may be repaired in a manual way, or moved to the original location of the file.

/mnt This directory is typically used to store mounted storage devices , such as CDROM directory. You can see the definition of/etc/fstab. Sometimes we can put the system boot automatically mount file system, put the mount point here is also possible. The main view is how to define the/etc/fstab, such as CD-ROM can be mounted to the/mnt/cdrom.

/OPT represents the optional meaning, and some packages are also installed here, which is the custom package, such as in Fedora Core 5.0, where OpenOffice is installed. Some of the packages we compile ourselves can be installed in this directory, and the software installed through the source package can be used through the ./configure--prefix=/opt/ directory.

The process information and kernel information (such as CPU, hard disk partition, memory information, etc.) are stored here when the/proc operating system is running. /proc directory masquerading file system proc mount directory, Proc is not a real file system, its definition can be see/etc/fstab.

/sbin is mostly involved in system management of the command store, is the super-user root executable command storage, ordinary users do not have permission to execute the directory under the command, this directory and /usr/sbin;/usr/x11r6/sbin or/usr/local/ The Sbin directory is similar ; we'll remember that all the directories sbin contain are root permissions to execute.

/usr This is a directory of system storage programs, such as commands, help files, and so on. There are a lot of files and directories under this directory. When we install a Linux distribution that is officially provided by the package, it is mostly installed here. If a server configuration file is involved, the configuration file is installed in the/etc directory. The/usr directory includes the font directory/usr/share/fonts, help directory/usr/share/man or/usr/share/doc, normal user executable file directory/usr/bin or/usr/local/bin or/usr/ X11r6/bin, the super-user root executable command to store directories, such as/usr/sbin or/usr/x11r6/sbin or/usr/local/sbin, and the program's header file to store the directory/usr/include.

/var The content of this directory is constantly changing, see the name to know, we can understand as vary abbreviation,/var under/var/log This is used to store the system log directory. /var/www directory is to define the Apache server site storage directory,/var/lib used to store some library files, such as MySQL, as well as the storage of MySQL database;

A little trick on the/opt directory

In Linux, the/OPT directory is a directory of some large software or special software, such as Google Chrome, which is installed in/opt by default. But we generally do not separate the opt in a zone, because most of the/opt is empty, even if the software is installed not too much, and some software capacity is relatively large, so that will occupy/capacity, we can in other places where you want to create a directory to the/opt "transfer" to elsewhere, For example, my/usr is separate in a district, the capacity of 50G, so large space do not waste it? and/usr is the place to install the software, so I can/usr to create a folder called OPT, and then right click on this/usr opt, select "Create link", get a "link to opt" file, and then cut this file to/from the original/opt deleted, Then the "to opt link" renamed opt on it, after we installed in the/OPT software is actually installed in the/usr/opt (actually a symbolic link).

/usr/local This directory is generally used to store the user self-compiled installation software storage directory, usually through the source package installed software, if not specifically designated installation directory, is generally installed in this directory. There are subdirectories under this directory. Check it out for yourself.

/usr/share systems are common to store things, such as/usr/share/fonts are font directories,/usr/share/doc and/usr/share/man Help files.

/var/log System log storage, analysis log to see this directory of things;

/var/spool printer, mail, proxy server, such as spool directory;

Linux Learning Linux Directory

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.