1.1 By modifying the file (/etc/fstab), you can set the file system to mount automatically when booting.
Automatically mount disk on boot
The Etc/fstab directory is more important
[Email protected] zuoti]# Cat/etc/fstab
#
#/etc/fstab
# Created by Anaconda Onthu Mar 16 19:04:22 2017
#
# Accessible Filesystems,by Reference, is maintained under '/dev/disk '
# See mans Pages Fstab (5), Findfs (8), mount (8) and/or Blkid (8) for more info
#
UUID=04AB4849-6234-463A-BF98-D38F64A15F69/EXT4 Defaults 1 1
Uuid=cdc3df9e-e37a-4081-a4f5-5b0dcd08ede7/boot EXT4 Defaults 1 2
Uuid=5ceb9219-7505-4a54-991c-41eefda2cd61swap Swap Defaults 0 0
TMPFS/DEV/SHM TMPFS Defaults 0 0
Devpts/dev/pts devpts gid=5,mode=620 0 0
Sysfs/sys Sysfs Defaults 0 0
PROC/PROC proc Defaults 0 0
Unique identification code file device name for first-column UUID device
Second column: mount point
Third column: File system type
Fourth column: Default command
Fifth column: The first 0 represents a backup of 1 on behalf of
Sixth column: Second 0 disk Self test
1.2 Topic 2Linux After the system starts loading the hardware driver and the file system, the kernel will start the program named (INIT), which is the first program that the kernel runs after the boot process, we can modify the default boot to (3), so that the system restarts automatically after the command line mode login.
This topic explains:
This problem, about our Linux startup process
1.BIOS Self Test
2.MBR Boot
3.GRUB Menu
4. Loading the kernel
5. Run the first program Init
#内核加载第一个程序是init, our default startup RunLevel is 3 (multi-user mode, command-line mode)
1.3 Topic 3 in Linux systems, when there are no conditions within the LAN to establish a DNS server, but want to let users within the LAN can use the computer name to access each other, should be configured (/etc/hosts) file (please write the full path)
This topic explains:
/etc/hosts local IP Domain name resolution
See this question first to see clearly, no conditions to establish DNS so we need to establish a local LAN DNS server
So in etc/hosts
Conditionally establish DNS that's in etc/resolv.conf.
1.4 Create the directory/data/kaile,/etc/passwd the first 20 rows to the/data/kaile/kaile.txt file.
#第一步: Creating a test environment
Mkdir/data/kaile-p
# #head取头文件内容前15行 Redirect to/data/kaile/kaile.txt
HEAD-N15/ETC/PASSWD >/data/kaile/kailetxt
# #awk取小于等于前20行内容 and redirect to/data/kaile/kaile.txt
awk ' nr<=20 '/etc/passwd >/data/kaile/kaile.txt
# #sed good at swapping for row-n cancel default output p (print) printing
Sed-n ' 1,20 ' >/etc/kaile/kaile.txt
1.5 redirect 5-15 rows from the/etc/passwd file to/tmp/kaile/test.txt (at least two methods)
# #第一步首先搭建测试环境 # #创建好我们的kaile目录
Mkdir/tmp/kaile
# # SED specializes in exchanging lines
# #取出我们etc/PASSWD 5, 15 lines redirect output to file
[Email protected]/]# sed-n ' 5,15p '/etc/passwd > Tmp/kaile/kaile.txt
echo$ (sed-n ' 5,15p '/etc/passwd) >/tmp/kaile/kaile.txt
This topic explains:
$ () = = "Anti-quote #先执行括号里面的命令 inside the command
1.6 Require command not found when using RM command, how do I implement (alias)?
# #临时修改别名 [[email protected]/]alias rm= ' echo command NotFound '
# #永久设置别名 Global Variables for ~.BASHRC users/etc/profile the global variables of the system
[[Email protected]/]# echo ' Alias rm= ' echo command not found ' >> ~.BASHRC
[[Email protected]/]# echo ' Alias rm= ' echo command not found ' >>/etc/profile
# # Test Results
[[Email protected]/]# rm/zhao/
Commandnot found/zhao/
To cancel an alias:
Unaliasrm
Command Description:
Alias setting aliases
Ualias Canceling aliases
1.7 Replace All Haoyi in the/data/kaile/directory with Bingbing.
# #首先找到 the file under/data/kaile and then sed to replace the contents of the file
[[Email protected]/]# find/data/kaile/-type F | Xargs sed-i ' s#kaile#bingbing#g '
# # $ () now execute the contents of the parentheses and replace the contents of the file
[[email protected] kaile]# sed-i ' s#bingbing#kaile#g ' $ (find/data/kaile/-typef)
Description: Note that this is the file name that is not found
Idea: Find all the files in the/data/kaile directory first
find/data/kaile/-type F
Command Description:
Find File
-type file type F file d directory
-name viewing files through file commands
-mtime can be modified by the time
-size by File size
-perm to find files through permissions permission
1.8 Delete all files except the passwd file in the/tmp/kaile/directory.
Method One:
# #之前修改过别名 all use absolute paths, or use a crowbar to take off your vest.
[Email protected]]# find/tmp/kaile/-type f! -name ' passwd ' | /bin/rm-f
Method Two:
RM-RF $ (find/tmp/kaile/-type f!-name ' passwd ')
Rm-rf ' find/tmp/kaile/-type f! -name ' passwd '
Method Three:
find/tmp/kaile/-type F! -name ' passwd '-exec rm-rf {} \;
Here is a description of-exec mate {} end \;
Give the find find file to-exec processing command {Inside find found content} \; end
1.9 Please say what you know the following characters in Linux can represent the meaning of
~ Current user's home directory
. Current directory
.. Top level directory of current directory
| Pipe or (regular expression)
> Output redirect appends to the last line of the file, emptying the original file contents
>> Append output Redirect to the last line of the file does not empty the contents of the file
< input redirection
<< Append input Redirection
# Root Super User #注释的意思
1.10 describes several of the startup/RunLevel levels of Linux and what they mean.
System Run Level
0: Turn off the machine
1: Single user mode, user maintenance cracked root password
2: Multi-user mode, but no NFS mode
3: Multi-user mode, command-line mode, our common mode
4: Useless
5: Graphical mode
6: Restart
To modify a run-level configuration file/etc/inittab
Note: Do not modify the operating sector 0 or 6
1.11 Find all the files in the/kaile directory that are 7 days old, ending with log and larger than 1M, and move the files to/tmp.
To create a test file:
[Email protected]/]# mkdir-p kaile && cd kaile
[Email protected] kaile]# cat/etc/services >>/kaile/haobao
[Email protected] kaile]# LS-LH
Total 1.9M
-rw-r--r--1 root root 1.9M Apr 15:37 Haobao
[[email protected]/]# date-s "+20 Day"
Mon May 15:40:34 CST 2017
Method One:
[Email protected] kaile]# find/kaile/-type f-mtime +7-size +1m
/kaile/haobao-exec MV {}/tmp \;
Method Two:
[Email protected] kaile]# find/kaile/-type f-mtime +7-size +1m | Xargs-i MV {}/tmp
Method Three:
Find/kaile-type f-name "*.log"-size +1m-mtime +7 |xargs mv-t/tmp
Method Four:
MV $ (find/kaile-type f-name "*.log"-size +1m-mtime +7)/tmp
Method Five:
Find/kaile-type f-name "*.log"-size +1m-mtime +7-exec mv {}/zhao \;
There are many ways to do it: no more summarizing
1.12 How do I see if I turn on port 80 and see if the sshd process exists?
NETSTAT-LNUTP |grep 22 # # View Port
SS-LNUTP |grep22 # # View 22 ports
[Email protected]/]# NETSTAT-LNUTP |grep # #查看80web端口
[Email protected] kaile]# NETSTAT-LNUTP | grep 22
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1136/sshd
TCP 0 0::: $:::* LISTEN 1136/sshd
TCP connection IP address 22 port listening State SSH
1.13 Lists the common Linux Packaging Compression tool and its compression decompression parameters.
Tar compression command
Common parameters
X gzip Compression
C Creating a compressed package
F Specify the command to compress the package
X Unzip the file
command in conjunction with
Tar XCVF packing Compressed files
Tar tf view packaged compressed files
Tar XF Unzip package file
Tar XF Compression pack name-c/tmp Specify unzip directory
This article is from "Ah Kai" blog, please be sure to keep this source http://kaile.blog.51cto.com/12459560/1920488
Linux Getting Started second exam question