Review:
Shell:type,which, environment variable path
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Reference variable: ${variable name}
Variable: A named memory space that can be found directly in the shell
Use Help:
# Help Command
# command--help
# Mans [Section] command
1-8:1, 8, 5
1 g: Turn to the first line
G: Turn to the last line
Q
# info
# application comes with documentation: README, INSTALL,/usr/share/doc
# google
# official documentation of the release version
Use format for commands:
Command option Parameters
Export lang=en
New courses:
Commands for the System Management class:
shutdown [option] ... Time
-R: Restart
-H: Shutdown
-C: Cancel restart or shutdown command shutdown-c
Time Format:
Now
+#: #分钟以后
hh:mm shutdown at a specified time
Reboot
Halt-p
Poweroff
Date Time Management class command:
Date (System clock), Hwclock (Hardware clock)
# date
# Date MMDDHHMM[CC]YY.SS Month day year. seconds
[[Email protected] ~]# date 100711032015.22
Wed OCT 7 11:03:22 EDT 2015
Use this to set the system time directly
# date [+format]
%Y: four-bit year
%y:2 bit Year
%m: Month
%M: Min
%d: Day
%H: Month
%H: When
%s: Seconds
%d: Date
%F: Date
[Email protected] ~]# date +%f
2015-10-07
[Email protected] ~]# date +%y-%m-%d
2015-10-07
[Email protected] ~]# date +%f-%h-%m-%s
2015-10-07-11-31-04
The time is all uppercase, and the date is lowercase.
Unix: 1970-01-01 00:00:00
%s:timestamp
[Email protected] ~]# date +%s
1444232025
#cal View Calendars
Linux has two clocks:
Hardware clock: used when starting up
Software clock: Read hardware clock at boot time
Hc
Sys
Hwclock can set two clock synchronization:
-S: Based on hardware clock,--hctosys
-W: Based on the system clock,--SYSTOHC
[Email protected] ~]# Hwclock;d ate
Sat Oct 3 12:02:47 2015-0.787231 seconds
Wed OCT 7 11:12:49 EDT 2015
[Email protected] ~]# hwclock-w
[Email protected] ~]# Hwclock;d ate
Wed Oct 7 11:13:04 2015-0.424462 seconds
Wed OCT 7 11:13:03 EDT 2015
Summary: Man, info, help, date, Hwclock, Cal, shutdown, reboot, Halt, Poweroff, type, CD, which, DirName, BaseName, who, which, Whatis, Makewhatis, Echo, hash, TTY
/: Root partition, root file system, ROOTFS, associated partition for mount and unload operations.
Commands for the file and directory management classes:
Current directory: Working directory
Home directory, home directory CD ~ can be implemented back home directory
Shell command-line expansion: Ability to change a special character to another character;
~: Specify the user's home directory;
{,}: expand to multiple entries;
X/{a,b} = x/a, x/b
Directory:
CD ~[username] Back to a user's directory, only Root can operate
CD-: Go back to your last directory;
/usr/share/doc/yum-3.2.1
CD-=/usr/share/doc
CD-=/usr/share/doc/yum-3.2.1
CD-
Path:
In the relative path:
.: Current Directory
..: Parent Directory
Pwd:print working Directory
mkdir: Creating a Directory
-P: Create parent directory first;
-V: Displays detailed information;
mkdir/a/b/c/d
x/a, x/b, x/a/m, x/a/n
MKDIR-PV x/{a/{m,n},b} Create parent directory at the same time
[[email protected] ~]# MKDIR-PV x/{a/{m,n},b}
mkdir:created directory ' x '
mkdir:created directory ' x/a '
mkdir:created directory ' x/a/m '
mkdir:created directory ' x/a/n '
mkdir:created directory ' x/b '
A_c, A_d, B_c, B_d
mkdir a_c a_d B_c b_d
mkdir {A,b}_{c,d}
(x+y) (m+n) = xm + xn + ym + yn
RmDir: Delete empty directory is deleted directory is not a file, if there are files under the directory, you cannot delete
Rmdir-p/x/c/v refers to the deletion of V, but if the first line of only son is empty, it is all deleted.
Exercise: Creating/tmp/mylinux/usr/local/bin,/tmp/mylinux/usr/local/sbin,/tmp/mylinux/etc/sysconfig,/TMP/MYLINUX/ETC/INIT.D ,/tmp/mylinux/bin,/tmp/mylinux/sbin
# Mkdir-pv/tmp/mylinux/{usr/local/{bin,sbin},etc/{sysconfig,init.d},bin,sbin}
Execution result of the command:
mkdir:created directory '/tmp/mylinux '
mkdir:created directory '/tmp/mylinux/usr '
mkdir:created directory '/tmp/mylinux/usr/local '
mkdir:created directory '/tmp/mylinux/usr/local/bin '
mkdir:created directory '/tmp/mylinux/usr/local/sbin '
mkdir:created directory '/tmp/mylinux/etc '
mkdir:created directory '/tmp/mylinux/etc/sysconfig '
mkdir:created directory '/TMP/MYLINUX/ETC/INIT.D '
mkdir:created directory '/tmp/mylinux/bin '
mkdir:created directory '/tmp/mylinux/sbin '
Exercise: Create/tmp/a B
[[email protected] tmp]# mkdir ' A B ' can also use double quotes, and underline
[[email protected] tmp]# ls
A b yum.log
References in the shell:
': Strong reference (what value is entered to show what value), variable substitution does not
"": weak reference, ability to perform variable substitution
"(Anti-quote): command substitution, the execution result of the reference command; another symbol of the command substitution: $ (command);
Inside the inverted quote is the instruction
[Email protected] ~]# echo "Time is ' date +%t '"
Time is 12:37:06
Inverted quotes in double quotes
Variable substitution: ${variable name} gets the value corresponding to the variable name
Echo
Exercise: Create a directory with the current time command, such as 2014-02-11-16-25-20;
# mkdir ' Date +%f-%h-%m-%s '
# mkdir $ (date +%f-%h-%m-%s)
Practice:
1. Create/TMP/ETC/RC.D,/TMP/ETC/RC.D/INIT.D,/TMP/ETC/RC.D/RC0.D,/tmp/etc/sysconfig,/tmp/etc/pam,/tmp/etc/ yum.repos.d/
MKDIR-PV ETC/{RC.D/{INIT.D,RC0.D},SYSCONFIG,PAM,YUM.REPOS.D}
2. Create/TMP/ETC/RC.D,/TMP/ETC/RC.D/INIT.D,/TMP/ETC/RC.D/RC0.D,/tmp/etc/sysconfig,/tmp/etc/pam,/tmp/etc/ yum.repos.d/,/tmp/usr,/tmp/usr/share,/tmp/usr/share/doc,/tmp/usr/share/man,/tmp/usr/bin,/tmp/usr/sbin,/TMP/USR /lib,/tmp/usr/lib64
Command summary: PWD, mkdir, rmdir
Shell's three characteristics: command history
A list of commands that have been executed by bash in the past;
The current shell process is saved in a buffer;
The commands in the buffer are saved to the file when the shell exits. Bash_history
Use the UP and DOWN ARROW keys to look at previously executed commands;
History shortcut (previously entered instruction): The following direct input can be
!#: #为命令历史列表中的命令编号; can execute the # command;
!: Executes the previous command;
!-#: Executes the penultimate # command in the command history list;
!string: Executes the last command in the command history list that starts with string;
!$: Refers to the last argument of the last command; ESC.
History
-C: Empty list
-D #: Delete the specified history command
-A: Append the current session's command history to the history file;
-N: Append the history file's instructions to the list
-A: Append the list's instructions to the history file
Command history-related environment variables:
Histsize: The number of commands that can be saved in the list in the command history; Echo $HISTSIZE
Histfile: Command history file, location of file
Histfilesize: The number of commands the command history file can hold;
[Email protected] ~]# echo $HISTFILE
/root/.bash_history
[Email protected] ~]# echo $HISTFILESIZE
1000
Histcontrol: Control the generation of command history; The following 3 are the values that can be assigned to a Histcontrol
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;
Add: Another feature of the Linux file system: Files that start with a dot are hidden files; Ls-a
Variables in the shell are assigned values:
Variable name = value
Note: Variables cannot be used when assigning values;
Variable names can contain only letters, numbers, and underscores, and cannot start with a number;
Variable names are case-sensitive;
FHS: File Hierarchy Standard
/bin: All users can execute programs, executable programs, operating system to start their own operation will be used by the program
/sbin: An administrator executable program that executes programs that the operating system uses to start its own operation
/usr/bin, in order to ensure that the operating system has basic functions, the basic operating procedures provided
/usr/sbin, in order to ensure that the operating system has basic functions, the basic operating procedures provided
/usr/local/bin, which is used to install third-party programs, such as Oracle,mysql
/usr/local/sbin, which is used to install third-party programs
/boot: Storage System Boot file: Kernel, Ramfs file, bootloader (GRUB);
/dev: Device file storage directory, is a type of special files;
/etc: the directory where the configuration files are stored;
/etc/sysconfig:
/ETC/INIT.D: System service scripts, and RunLevel-related
/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 files, here are the standard library files,/bin and/sbin and/usr/bin and/usr/sbin programs require the library files are here, and/usr/local/bin is not, it has its own library file
/media: A dedicated mount location, typically used to mount a portable device, such as inserting a USB stick, whose files are mounted under media.
/MNT: Dedicated mount location, mount additional storage devices, such as adding a new hard drive
/misc: Alternate Directory
/OPT: Alternate directory, but usually used to install third-party software;
/proc: Pseudo-file system, kernel parameter mapping, which shows the kernel running state parameters, a shutdown is not, performance as a file: file name is the parameter name, content is value.
/sys: Pseudo file system, system-level parameters for configuring peripheral devices, hardware parameters, performance as files: File name is parameter name, content is value.
/SRV: Provide data storage location for service;
/tmp: temporary file system;
/usr: Shared file s:shared (files can be used on all Linux systems that follow the FSH specification), r:readonly (Read only)
/usr/include: Header File
/var: files that are frequently changed
/var/log Log
/var/lock lock file, service
/var/run
/var/cache
Normal users can create their own files only with TMP and home directories.
Linux Punch 3