Linux Basics--linux File system and Bash's basic features
A. linux file system:
A file in a Linux file system is a collection of data that contains not only the data in the file but also the structure of the file system, where all Linux users and programs see files, directories, soft links, and File Protection information .
Linux file systems follow FHS (Filesystem Hierarchy Standard, File system directory standards), and most Linux versions use this form of file organization. FHS uses the tree row organization file.
FHS defines the two-tier specification, and the first layer is what file data should be placed in each directory below the directory. The second tier is defined for sub-directories of the/USR and/var directories.
Root file system: (Root filesystem)
/boot: The directory where the boot file resides, the kernel file (vmlinuz), and the boot loader (bootloader,grub) are stored in this directory.
/bin: A directory for basic commands that are used by all users. You cannot associate (mount) to a separate partition, and the program in the directory is used when the OS starts.
/sbin: The storage directory of execution commands for administrators to use. cannot be associated to a separate partition, and the OS starts with a program in the directory.
/lib: Basic shared library files and kernel module files (/lib/modules)
/LIB64:
/etc: directory where host-specific configuration files are stored (mostly plain text files)
/etc/opt: The configuration file is stored specifically for applications under OPT.
/ETC/X11: The configuration file is stored specifically for the X Protocol program. x-->xmanager--> Desktop
Home directory of users, the home directory of a regular user is here
/media: mount point for portable mobile devices
/MNT: mount point for temporary file system
/dev: storage directory for device files and special files
B:block Device: Block devices file. Devices can be accessed randomly.
C:character Device: Linear devices.
/OPT: The installation directory for third-party applications. (Storage directory for attachments)
/SRV: The storage directory of data used by services on the system.
/tmp: Temporary files, temporary files on the current system are stored in this directory
The above directories cannot be associated with directories other than/boot,/home,/media,/mnt
/usr: (Universal shared Only-read data): Global shared Read Only directory
/usr/bin: Commands that all users can use to store directories. A command that stores the system to perform some basic functions, rather than a directory of commands used at system startup, to ensure that the system has the full functionality of the application.
/usr/sbin:
/usr/lib: function library file for each application software
/USR/LIB64:
/usr/include:c the directory where the language program header files are stored. How the library file is called and opened when the header file
/usr/local: instead of/opt. The installation directory for third-party applications. This directory also has the following directories:
Bin,sbin,lib,lib64,etc,share
/usr/share: structured independent data, storing some background files, Doc,man and so on.
/usr/x11r6:xwindows system
/USR/SRC: directory where source code is stored
/var:variable data file: Variable files directory
/var/cache:application Cache Data: Application caching Directory
/var/lib: Storing variable state data
/var/local: Dedicated to storing mutable data for applications under/usr/local
/var/lock: Lock File
/var/log: Log Directory
/var/run: Running process-related data, typically used to store process PID files
/var/spool: Cache Data for Applications
/var/tmp: Directory of temporary data stores generated by system restart
/proc: Pseudo file system: A virtual file system for outputting kernel-related process information
/sys: Pseudo file system: A virtual file system for outputting information about hardware devices on the current system
/selinux:security Enhanced Linux:selinux The storage path of the relevant security policy information
Components of an application on Linux:
Binary program:/bin,/sbin,/usr/bin,/usr/sbin,/usr/local/bin,/usr/local/sbin
Library files:/lib,/lib64,/usr/lib,/usr/lib64,/usr/local/lib,/usr/local/lib64. Either a shared library or a library that you have developed for two times
Configuration file:/etc
Help file:/usr/share
Two. Bash's basic features:
(1) Historical order:
History
Environment variables:
Histsize: Number of records in the command history
Histfile:~/.bash_history
Histfilesize: The number of command bars in the command history file. You can modify this environment variable to change the history file storage
Number of bars of the command
History-d OFFSET
-C Clear Cache
-A: Manually append the current session buffer's command history to the history file.
History #: Show the recent # Command of the historical command
Shortcut keys for invoking commands:
!#: Execute number # command
!!:
!string: Executes a command that starts with the last string
Call the last parameter of the previous command
!$
Esc.
Control how the Command history is recorded:
Environment variable: Histcontrol
Ignoredups: Ignore duplicate commands, repeat and continuous
Ignorespace: Ignores all commands that start with a white space character
Ignoreboth:==ignoredups,ignorespace
Hash
Linux system will have a hash table, when you just open the machine this hash table is empty, whenever you execute a command
, the hash table records the path of the command, which is equivalent to the cache. Execute command shell interpreter for the first time
The default is to look for the path to the command from the path path, and when you use the command for the second time, the shell interpreter first
Will look at the hash table, not the command will go to the path path under the search.
(2) Order completion:
Commands executed by bash:
Internal command:
External command: Bash searches for a file with the command name from the left and right, based on the path defined by the PATH environment variable
The directory where the command to execute is found for the first time.
Direct Completion: Tab key, user given string as a single command
(3) Path completion:
Take the user-given string as the beginning of the path and search for the specified string at the beginning of its specified parent directory.
The file name, or, if the only one is complete, then tab lists the list of files
(4) Command line expansion:
~: Expand to the user's home directory
~username: Expand the home directory for the specified user
{}: Can host a comma-delimited list and hold it as multiple paths
/TMP/{A,B} ==>/tmp/a/tmp/b
/tmp/{a,b}/hi ==>/tmp/a/hi/tmp/b/hi
/tmp/{x,y}_{m,n} ==>/tmp/x_m/tmp/x_n/tmp/y_m/tmp/y_n
(5) Execution status result of the command
Successful execution: When the previous command succeeds, execute echo $ again? View execution status; 0 indicates success.
Such as:
[[email protected] ~]# ls a anaconda-ks.cfg install.log install.log.syslog [[Email PR Otected] ~]# echo $? 0
Execution failed: When the previous command executed successfully, execute echo $ again? View the execution status; 1-255 indicates a loss
Defeat. Such as:
[Email protected] ~]# lls-bash:lls:command not found [[email protected] ~]# echo $? 127
Bash uses the special variable $? To save the status result of the most recent execution command.
There are two types of program execution results:
The return value of the command execution:
Command execution status Result:
This article is from a "moment" blog, so be sure to keep this source http://zkchang.blog.51cto.com/10574636/1685358
Linux Basics--linux File system and Bash's basic features