1.1 Basic Command Operation
Linux using a command, the command format is as follows:
[Options] command Parameters
Command: Command specific implementation, e.g. pwd, head, etc.
Options: command will affect the behavior of some of the operations, usually - achieve
Parameters: Object command role
1.1.1 Basic commands only --ls
Role: see which files in the current directory (list)
Syntax: ls directory / file, if no tax increases, then viewing the contents of the current directory
Common options:
-l Detailed list of files, such as author, creation time, read and write permissions list of files and so on, the long list
[root@localhost ~]# ls -l The total amount . 4 -rw -------. . 1 the root the root 1402 . 7 dated 24 08 : 49 Anaconda-the ks.cfg
The first character of the file types:
d: directory file
l: Link file
b: block device file
c: character device file
p: pipe file
-: that ordinary file
-a list all files in the directory, including the "." At the beginning of the hidden files (hidden files under linux Is beginning, if there is two point representation indicates the presence of the parent directory, a dot represents the current directory)
[root@localhost ~]# ls -a . anaconda-ks.cfg .bash_logout .bashrc .mysql_history .tcshrc .. .bash_history .bash_profile .cshrc .rediscli_history .viminfo
-d directory view (not see what's inside)
[root@localhost ~]# ls -ld /etc/ drwxr-xr-x. 74 root root 8192 7月 30 08:37 /etc/
-S size of the file to be sorted
[root@localhost ~]# ls -lS /etc/ 总用量 1056 -rw-r--r--. 1 root root 670293 6月 7 2013 services -rw-r--r--. 1 root root 19265 7月 24 10:24 ld.so.cache -rw-r--r--. 1 root root 12288 7月 24 08:53 aliases.db -rw-r--r--. 1 root root 7265 7月 24 08:42 kdump.conf -rw-r--r--. 1 root root 6545 10月 31 2018 protocols
ls -l and ll these two commands are equivalent
[root@localhost ~]# ls -l The total amount . 4 -rw -------. . 1 the root the root 1402 . 7 dated 24 08 : 49 anaconda- the ks.cfg [root@localhost ~]# ll The total amount . 4 -rw -------. . 1 the root the root 1402 . 7 dated 24 08 : 49 Anaconda-the ks.cfg
[root @ localhost ~] # type ll # ll can view type is the alias ls -l
ll is `ls -l --color = auto 'aliases
1.1.2 using aliases
Define an alias: [root @ localhost ~] # alias vimens33 = 'vim / etc / sysconfig / network-scripts / ifcfg-enp0s3'
[Root @ localhost ~] # vimens33 # can open the configuration file card
Delete an alias: [root @ localhost ~] # unalias vimens33
Set an alias permanent:
Current user
[Root @ localhost ~] # vim /root/.bashrc # add the content you want to add an alias in the file
alias vimenss33="vim /etc/sysconfig/network-scripts/ifcfg-ens33"
[Root @ localhost ~] # source /root/.bashrc # reload this file, then you can use alias
Global Use
[Root @ localhost ~] # vim / etc / bashrc # add the content you want to add an alias in the file
alias vimenss33="vim /etc/sysconfig/network-scripts/ifcfg-ens33"
[Root @ localhost ~] # source / etc / bashrc # reload this file, then you can use alias
1.1.3 basic commands only -cd
Role: Change directory (change directory)
Syntax: cd directory
Description: cd represents the direct input back to the current user's home (home) directory
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cd
[root@localhost ~]#
cd .. parent directory represents a return to the position, which is the parent directory
cd. that enter the user's current directory
[root@localhost ~]# cd /etc/
[root@localhost etc]# pwd
/etc
[root@localhost etc]# cd ..
[root@localhost /]# pwd
/
[root@localhost /]# cd /etc/
[root@localhost etc]# pwd
/etc
[root@localhost etc]# cd .
[root@localhost etc]#
cd - represents the directory before switching back
[root@localhost etc]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cd -
/etc
history 1.1.4 basic command of
Command: history
4 Quick Find linux command history of operating skills:
Method 1: up and down cursor keys
Method 2: ctrl + r - a keyword input command - to find the corresponding command, the right cursor key
Method 3 :! // digital command execution history Article N command
Method 4 :! String search command history in a recent command beginning character has xxx
1.1.5 Linux under Shortcuts
ctrl + c to terminate the program running in the foreground
Ctrl + d exit is equivalent to exit
Ctrl + l clear screen with clear functional significance
Ctrl + r search-history
! $ References on the last parameter of a command
Fill all orders using the tab key, tab can only fill all orders and documents
1.2 Time Management System
There the linux system hardware and system clocks two kinds of clock, the hardware clock refers to a clock device on the motherboard, which is typically in the BIOS clock setting screen; the system clock is the clock of the kernel; linux all relevant directives and functions are reading system clock setting, when the linux boot, the system clock back to read the hardware clock is set, then the system clock that is independent
1.2.1 two kinds of time:
View hardware time
[root @ localhost /] # hwclock
2019 Nian 07 Tuesday, 30 October 09 hours 33 minutes 17 seconds -0.753323 seconds
Check the system time:
[root @ localhost /] # DATE
2019 Nian Tuesday, 30 May 07 09:33:41 CST
Time zone:
UTC (Universal Time Coordinated): Coordinated Universal Time
GMT (Greenwich Mean Time): GMT
CST (China standard Time): China Standard Time
1.2.2 If the modification time
The date command parameters:
date --help
-s --set = STRING string of the set time period described
例:[root@localhost /]#date -s "2018-11-2 22:30"
November 2, 2018 22:30:00 CST Friday
% F complete date format, equivalent to% Y-% m-% d
[root@localhost /]# date "+%F"
2019-07-30
% Y last two digits the year
% Y Year
% M month in January
% D month meter Date
% M minute minutes
% H Hour
% S seconds
[root@localhost /]# date "+%Y%m%d"
20190730
[root@localhost /]# date "+%Y-%m-%d %H:%M:%S"
2019-07-30 09:46:31
[root@localhost /]# date "+%Y/%m/%d %H:%M:%S"
2019/07/30 09:46:39
[root@localhost /]# date "+%Y%m%d %H:%M:%S"
20190730 09:46:47
1.2.3 using the time command to test a command to run time
time effect: general commands used to measure a running time
[root@localhost /]# time ls -l /etc/
real 0m0.036s
user 0m0.010s
sys 0m0.025s
Explanation
real: the actual use of time
Time the user states used: user
Time kernel state used: sys
1.3 Help command
Add command encountered do not know the parameters, you can use the help command to view related presentations, commonly used to view the help command has the following
1.3.1 man command: see the man pages or the command description
[root@localhost /]# man find
When the man command help, but also to eat the next turn turn, search (direct input slash), quit with q
1.3.2 use -h or --help to view the command options
[root@localhost /]# find --help
1.4 switch command and 7 start level
Several commonly used shutdown and restart commands
shutdown
init
reboot
poweroff
1.4.1 Shutdown command of -shutdown
Syntax shutdown [options]
parameter:
-r Restart the computer
shutdown -h
-h time off time
E.g:
[Root @ localhost /] # shutdown -h +20 # 20 minutes after shutdown
[Root @ localhost /] # shutdown -h 23:30 # assign specific shutdown time
[Root @ localhost /] # shutdown -h now # immediately shut down
[Root @ localhost /] # shutdown -r 22:22 # specified time to restart
1.4.2 7 start level
Role: Change system run levels
Syntax: the init 0-6
Linux 7 a Start level:
0 system shutdown mode, the system default run level can not be set to 0 or does not start, turn off the machine
1 single-user mode, root privileges for system maintenance, remote access is prohibited, as safe mode of Windows logon
2 Multi-user mode without NFS and network support
3 Full multi-user text mode with NFS and network, after landing into the console command line mode
4 system is not used, reserved generally do not, in some special cases you can use it to do something. For example, when the laptop battery exhaustion, this mode can be switched to do some settings
5 graphics mode, after landing into the graphical GUI mode, X Window system
6 restart mode, the default operating level can not be set to 6, or can not start properly. Run the machine will reboot init 6
Case
[Root @ localhost ~] # init 0 # Shutdown
[Root @ localhost ~] # init 3 # 3 into the character interface level
[Root @ localhost ~] # init 5 # to enter the 5-level graphical interface
1.4.3 set the default operating sectors
centos7 no longer use the / etc / inittab file to start the default level configuration, use the more liberal than running sysvinit level of the target instead.
The first 3 replaced by run level multi-user.target.
The first 5 Run stage was replaced with graphical.target.
The third set the default start level
[root@localhost ~]# systemctl set-default multi-user.target
The fifth set the default start level
[root@localhost ~]# systemctl set-default graphical.target
[root@localhost ~]#runlevel
# 35 will switch the level 3 to level 5
View the current default start level
[root@localhost ~]# systemctl get-default
graphical.target