Linux Learning Notes (v) system directory structure, ls command, file type, alias command

Source: Internet
Author: User
Tags aliases readable

First with Xshell landing Centos7,

First, the system directory structure

In the Command window, enter


LS is an abbreviation for list that lists the specified directory or file

/is the root directory of the Linux operating system, all files and directories under it;

This will display the following

/bin:bin is the abbreviation for binary, which is the most commonly used command in this directory.

/boot: This directory contains some of the core files used when starting Linux, including some connection files and image files.

/dev:dev is the abbreviation for device (devices). This directory is where Linux external devices are stored. In Linux, the way you access your devices is the same way you access files.

/etc: This directory contains all the required configuration files and subdirectories for system management.

/home: This is the user's main directory. In Linux, each user has a directory of their own, which is typically named after the user's account name.

/lib and/lib64: These two directories are the most basic dynamic connection shared libraries in the system, which act like DLL files in Windows, and almost all applications need to use these shared libraries. The directory where the library files for the/lib64 are 64-bit packages.

/media: The system will automatically identify some devices (such as USB flash drives, optical drives, etc.), and when identified, Linux will attach the identified devices to the directory.

/MNT: This directory is provided by the system to allow users to temporarily mount other file systems. We can attach the optical drive to the/mnt/and then go to the directory to view the contents of the CD drive.

/OPT: This is the directory that is set up for the host to install additional software, which is empty by default. For example, if you want to install an Oracle database, you can put it in this directory.

/proc: This directory is a virtual directory, is a mapping of system memory, we can obtain the system information through direct access. The contents of this directory in memory, we can directly modify some of the files inside. For example, you can use the following command to block the host's ping command, so that other people cannot ping your machine. Follow, in your daily work, you will often use similar usage.

/root: The directory is the user home directory of the system administrator.

/run: This directory in fact and/var/run is the same directory, which is stored in some of the service PID, a service after the start, there is a PID file. As for why the same directory, Linux is how to do, follow-up we introduce.

/sbin:s is the meaning of super user, which is the system administrator used by the System Manager.

/srv: This directory holds data that needs to be extracted after some services have been started.

/sys: This directory holds information related to hardware drivers.

/tmp: This directory is used to store some temporary files.

/usr: This is a very important directory, similar to the Program Files directory under Windows, where many of the user's applications and files are stored in this directory. In the following chapters, we will use this directory multiple times.

/usr/bin: This directory holds applications that are used by system users.

/usr/sbin: This directory holds the more advanced hypervisor and system daemon used by super users.

/USR/SRC: This directory is the default drop directory for the kernel source code.

/var: This directory is stored in a constantly expanding and often modified directory, including various log files or PID files, just mentioned/var/run is under the/var directory

In the Linux system, there are several important directories to be aware of, do not mistakenly delete or arbitrarily change their internal files.

The/etc directory is a system configuration file, and changing a file in that directory may cause the system to not start properly.

The/bin,/sbin,/usr/bin, and/usr/sbin directories are the placement directories for system-Preset execution files, where the/bin and/usr/bin directories are instructions for use by the system user (except for the generic accounts other than root), while/sbin and/usr/ The Sbin directory is the command for root use. For example, the LS command is stored in the/bin/directory.

/Var is also a very important directory, the log that is generated when running each program on the system is recorded in that directory (i.e. the/var/log directory), and the default of the mail instruction is placed here.

Second, ls command


Mans LS

You can view the specific use of LS

Look at this more abstract, especially for my English is not very good people, below to give a few examples to execute

The above practice is explained as follows:

    • No option followed by directory name or file name: Lists the files and directories in the current directory, and does not contain hidden files;

    • Add-a option, no directory, or file name: Lists the files and directories in the current directory, including hidden files;

    • Add-l option, no directory or file name: The details of all files and folders except hidden files in the current directory are listed, including their permissions, user, owning group and file creation date and time;

    • No option followed by file name only: The file is listed, usually with-L, to view the file details;

    • No option followed by directory name: Lists files and directories in the specified directory

The following is a description of usage:

  • -A: Displays all files and directories (ls default file name or directory name is ".") As a shadow, not listed);

  • -A: Displays the Save Shadow file "." and ".." List of all files except;

  • -C: Multi-column display output results. This is the default option;

  • -L: In contrast to the "-C" option, all output information is output in a single-column format and not output as multiple columns;

  • -F: Append the type identifier of the file after each output item, meaning: "*" means a normal file with executable permissions, "/" for the Directory, "@" for the symbolic Link, "|" Represents a command pipeline FIFO, and "=" represents a sockets socket. When the file is a normal file, do not output any identifiers;

  • -B: Outputs the non-output characters in the file with the backslash "" and the character encoding;

  • -C: When in use with the "-lt" option, the output directory content is sorted according to the file status time, sorted by the CTime field in the index node of the file. When in conjunction with the "-l" option, the ordered sentence is the time of the file's state change;

  • -D: Displays only the directory name, not the list of contents under the directory. Displays the symbolic link file itself without displaying the list of directories it points to;

  • -F: The effect of this parameter is the same as specifying the "AU" parameter, and the effect of the "LST" parameter is turned off;

  • -I: Displays the file index node number (inode). An index node represents a file;

  • --file-type: The function is the same as the "-f" option, but does not display "*";

  • -K: Displays the file size in kilobytes (Kbytes);

  • -L: Displays a table of contents in a long format. The output information includes file name, file type, permission mode, number of hard connections, owner, group, file size, and last modification time of file, etc. from left to right.

  • -M: The name of each file and directory separated by the "," area;

  • -N: Replace its name with user identification code and group identifier;

  • -R: The list of directory contents is sorted and output in reverse order of file name;

  • -S: Displays the size of files and directories, in chunks;

  • -T: Sorts the file and directory change times;

  • -L: If you encounter a file or directory with a symbolic link, directly list the original file or directory that the link points to;

  • -R: Recursive processing, all files and subdirectories under the specified directory are processed together;

  • --full-time: Lists the full date and time;

  • --color[=when]: Use different colors to highlight different types of.

Iii. Types of files

Input Ls-l

The first character of the first column is the file type

    • ' d ' indicates that the file is a directory;

  • '-' indicates that the document is an ordinary document;

  • ' L ' indicates that the file is a linked file (Linux file) and the soft link mentioned above is the type;

  • ' B ' means the file is a block device, such as/DEV/SDA.

  • ' C ' indicates that the file is a serial port device, such as a keyboard, mouse.

  • ' s ' means that the file is a socket file (socket) for interprocess communication.

  • Behind the 9 bits, each of the three is a group. is a combination of rwx three parameters. where R stands for readable, W stands for writable, and X represents executable. The first three bits are the permissions of the owning master (user), the middle three are the permissions of the owning group, and the last three bits are the permissions of the other non-native groups (others). Let's take a concrete example to illustrate this.

  • The property of a file is '-rwxr-xr–. ', which means that the file is a normal file, the file owner can read and write executable, the file belongs to the group to its readable and non-writable executable, other users are only readable. For a directory, open this directory to execute this directory, so any directory must have X permission to open and view the directory. For example, a directory whose properties are ' drwxr–r–. ' is root, so users other than root cannot open this directory.

  • About the last one in the first column. There is no such point in the previous CentOS 5, mainly because the new version of LS adds selinux or ACL attributes, when the file or directory only uses the SELinux context attribute, here is a point. If an ACL is set, it will be followed by a plus sign ' + '. About SELinux and ACLs

  • The 2nd column, which represents the node (inode) used for the link, [1] is a directory that is usually related to how many directories are still under the directory.

  • The 3rd column, which represents the owner of the file.

  • The 4th column, which represents the group to which the file belongs.

  • The 5th column, which represents the size of the file.

  • Columns 6th, 7th and 8th are the most recent modification dates for the document, namely the date of the month and the time, the so-called Mtime.

  • 9th column, file name.

Common file types are

1) ordinary files (regular file): is a generic type of file, when viewing a directory with Ls-l, the first attribute is '-' the file is a regular file, or called ordinary files. Regular files can also be divided into plain text (ASCII) and binary (binary) files. Plain text files are available through the cat, more and less tools to view content directly, while binary files do not. For example, we used the command/bin/ls this is a binary file.

2) directory: This is easy to understand, is the directory, with Windows folder under a meaning, but in Linux we do not call a folder, but called a directory. Ls-l View the first attribute is ' d '.

3) Link file: Ls-l View the first property is ' L ', similar to a shortcut under Windows. This kind of file is very common in Linux, and it is used in a lot of routine system operation, so we should pay attention to this kind of file.

4) Device: Some files related to the perimeter of the system are usually concentrated in the/dev directory! There are usually two types of blocks: a block device: A device that stores data to provide system access, simply a hard drive. For example, your hard drive code is/DEV/SDA1, the first property is ' B ', and the other is the character (character) device: the interface device for some serial ports, such as a keyboard, mouse, etc., the first property is ' C '.

Iv. alias Command


Visible ll is the alias of Ls-l, which is a new command combined with the command plus option.

Enter the alias command to see what aliases are in the system.

Below to manually specify aliases

, specify the LS-L alias Chinantfy

by which Chinantfy

You can see that Chinantfy is an alias for Ls-l,

You can use Unalias chinantfy to cancel aliases

Then enter CHINANTFY to display the command not found, the alias has been successfully canceled

Linux Learning Notes (v) system directory structure, ls command, file type, alias command

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: 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.