Directory:
CD: Switch directories
CD path: Switch to the file path
CD ~[username]: Switch to the user's home directory,
CD-: Switch to the directory where you first
Pwd:pring working directory: Displays the current directory
mkdir: Creating a Directory
-P: Create the parent directory first, that is, recursively create
-V: Show details at creation time
Here is a feature that expands the Bash keyword, such as
{A,b}_{c,d} After expansion is A_c, A_d, B_c, b_d, which is useful when creating multiple files or directories
RmDir: Delete Empty directory: Note that the directory to be deleted must be empty. ,
-P: Recursive delete
-V: Displays the deletion information ...
References in the shell:
"": a strong reference, a reference in which a variable reference can be added ${paht},
': weak reference, reference to the middle of the string can only be a string
': Command substitution, the command in the reference will be executed. , of course, you can also use the $ (command) Form for command substitution
Echo: Output a sentence, the script is useful, equivalent to the C language of printf, the shell also has printf
${name} This is a reference environment variable, where {} can be omitted in most cases, but as
${PATH}BBBB This situation can not be omitted, after the omission has become
#PATHbbbb, there is no such environment variable in the system.
command History of Shell features:
Bash preserves the command history in the buffer, and when the shell exits, the command history is stored in the ~/.bash_history by the buffer
Use the ↑↓ tip to look through the commands you've executed.
History Shortcuts:
!#: #为命令历史列表中的命令编号, can be used to execute the # command
!! : Executes the previous command
!-#: Execute the Countdown # command
!$: Referencing the last parameter of the previous command
You can see the history of the command in the execution, it is too long, it intercepts the last part, first look at the shortcut,
Here, I have executed this order under number No. 909.
This is the execution of the previous statement, in fact, the Echo statement is executed again,
This and!! No difference, but also the implementation of the previous statement, of course, the 1 changed to something else there is a difference.
Finally, the!$,
I started by looking at my home directory in/directory and then using CD!$ to jump directly to my home directory, where the!$ is the parameter of the previous command.
----------------------------------------------------------
History options:
-C: Clear History
-d#: Deletes the specified command history, #为命令历史的编号
-A: Append the current command history to the command history file.
Command history-related environment variables:
Histsize: The number of commands that can be saved in the command history;
Histfile: command history file;
Histfilesize: The number of commands the command history file can hold;
Histcontrol: Control the generation of command history;
Ignoredups: Ignore record duplicate command, repeat the same command for consecutive;
Ignorespace: Do not log commands that begin with a blank character;
Ignoreboth: Both of the above characteristics;
Variable assignment in Shell:
FHS: The file system directory standard, which lists what directories Linux should have, giving the role of some important directories under the root directory.
/bin: All users can execute the program
/sbin: Administrator-Executable program
/usr/bin
/usr/sbin
/usr/local/bin
/usr/local/sbin
/boot: Storage System Boot file: Kernel, Ramfs file, bootloader (GRUB);
/dev: Device file storage directory;
/etc: the directory where the configuration files are stored;
/etc/sysconfig:
/ETC/INIT.D: System service Script
/home: A normal user, by default, has a directory with the same name as the user's family directory.
/root: Administrator's home directory;
/lib,/lib64: library file;
/media: A dedicated mount location, typically used to mount portable devices;
/MNT: Dedicated mount location, mount additional storage devices;
/misc: Alternate Directory
/OPT: Alternate directory, but usually used to install third-party software;
/proc: Pseudo file system, kernel parameter mapping;
/sys: Pseudo file system, system-level parameters for configuration of peripheral secrets;
/SRV: Provide data storage location for service;
/tmp: temporary file system;
/usr:shared, ReadOnly
/usr/include: Header File
/var: files that are frequently changed
/var/log
/var/lock
/var/run
/var/cache
File:
Linux File types:
Normal File:-, file, this is equivalent to the TXT file in Windows
Catalog file: D,directory, this is equivalent to the folder in Windows.
Link file (Symbolic link): L,link, this refers to a soft connection, equivalent to a shortcut
Device files:
Character devices: C, Char, this is also called a serial device interface, such as a keyboard or something.
Block Device: B, block, this is also called parallel device interface, such as hard disk
Named pipes: P, Pipeline, not very understanding, learned to say.
Socket file: s, socket, this is also not very clear.
------------------------------------------
Linux file timestamp:
Access times, access time, atime
Modified on, modify time, Mtime
Changing time, change times, CTime
-------------------------------------------
File directory tree:
Tree command, this command general system does not own, need to install itself.
# yum Install tree, installing the tree command
------------------------------------------
Command aliases for Bash features:
# Alias alias = ' Original command name '
You can view a defined command alias when alias is not a parameter
Here also can see LS command is also an alias, ls= ' ls--color=auto ', here if you want to execute command of the original interesting can be in front of the command add ' \ ', such as,
When you cancel the command alias, LS does not display the color.
# Unalias aliases, this is used to cancel the command alias
----------------------------------------------
View of text files:
Cat file: Viewing a file in a positive order
- n Display line number
- e display line terminator
- v show nonprinting characters
- a show all characters
-s multiple contiguous blank lines are displayed as a blank line
TAC file: Contrary to cat, view a file in reverse order ...
--------------------
MORE: Displays multiple lines of files, using the same man, but automatically exits when the last line of the file is displayed.
Less: Displays multiple lines of files, using the same man, but it seems that man is implemented with little. , the difference between this and more is that it will not exit after the last line is displayed.
--------------------
Head: Displays the first few lines of the file, showing the first 10 rows by default
Tail: Displays the following lines of the file, the default is 10 lines after display
-n#: Sets the number of rows displayed, # is a number,
-------------------------
echo Command:
-e: Allow the use of an escape character similar to the C language
-N: No default output line break
-------------------------
Commands about the file
Touch: Creating a file is actually a modified timestamp. The file will be created automatically when this file does not exist.
Access time, Atime,
Modify Time, Mtime
Change Time, CTime
-C: Do not create empty files
-A: Modify access time only
-M: Modify only modified time
-T STAMP: [CC]YYMMDDHHMM.S
Access time, Atime
Modify Time, Mtime
Change Time, CTime
-C: Do not create empty files
-A: Modify access time only
-M: Modify only modified time
-T STAMP: [CC]YYMMDDHHMM.S
Create a file in an empty folder, you can use stat to view the file information.
Stat: Displays the basic information for a file.
Now let's change the file's Access timestamp:
Okay, it's been changed.
------------------------------------------------------------
Cp:copy: Copying files
SRC, DEST
CP SRC ... DEST
-R: Recursive replication
-I: Human interaction
-D: When the source is a linked file, copy the linked file itself instead of the source file pointed to
-A: equivalent to-DR
-P: Keep the original property
-F: Mandatory
If SRC is a file:
If the target is a file and exists: overwrite
If the destination file does not exist: Create a new file
If the target exists and is a directory: Copy the source to the destination directory and keep the original
If SRC has multiple files:
If the target exists and is a file: replication cannot be performed
If the target exists and is a directory: Copy the files to the destination directory and keep the original
If the target does not exist: replication cannot be performed
If SRC has only one and is a directory:-R
If the target is a file and exists: failed
If the destination file does not exist: Create a new directory
If the target exists and is a directory: Copy the source directory to the destination directory and keep the original
Copy the/etc/passwd into the current file plus the AAA file and look at the AAA file:
Copy probably on these, nothing too high-end things.
---------------------------------------------------------
Mv:move: Move files, usage and CP almost,
You can move the directory directly without the-r option;
----------------------------------------------------------
Rm:remove: Deleting files
-r: Recursive delete file, plus this option can be deleted unless empty directory, ~
-I: Human interaction
-V: Deletes the details.
-F: Forced delete, no human interaction required
---------------------------------------------------------------
Nano: A simple text editor,
Ctrl+o is saved, Ctrl+x is exited
Bash feature globbing: file name wildcard
Wildcard characters:
*: denotes any character of any length
? : Represents any single character
[]: Specify any single character within the range of characters
[xyz] x or Y or Z
[A-z] any character between A and Z
[0-9] Any one character between 0 and 9
[A-z0-9] A to Z, 0 to 9 any character
[^]: matches any single character outside the specified range of characters
[^0-9] non-numeric characters
[[: Upper:]]: All uppercase letters
[[: Lower:]]: All lowercase letters
[[: Alpha:]]: Uppercase and lowercase letters
[[:d Igit:]]: Number
[[: Alnum:]]: Uppercase and lowercase letters plus numbers
[[: Space:]]: white space characters
[[:p UNCT:]]: punctuation.
This article is from the "Serenity Indifferent" blog, please make sure to keep this source http://vrgfff.blog.51cto.com/6682480/1566913
4, File box Directory Management command, shell reference, Shell history