20165211 pre-Job 3 Linux installation and learning 1. Linux installation involves software: Virtualbox,ubuntu Reference Tutorial: Installing Ubuntu Graphics tutorial based on VirtualBox problems with the installation process
- After installing VirtualBox, the process of creating a virtual machine, the type is Linux, but 64-bit Ubuntu is not found in the version.
After finding some information on the Internet, I found that my computer did not turn on virtualization and should go into the BIOS to turn on virtualization. It's really going to be a bit of a win10 here. I found a lot of tutorials to find a way to get into the BIOS. This should also be related to the settings of each computer.
After you turn on virtualization, you can set the 64-bit Ubuntu to a smooth one.
- When installing Ubuntu, follow the link in the tutorial, the result, this download link is wrong, as long as Baidu found the correct link on the website can be.
Linux Learning chapter I introduction to Linux
This article mainly introduces the basic concepts of operating system, the history of Linux, the differences between Linux and Windows, and other introductory knowledge.
In this chapter, I see the whole process of Linux development is the countless computer genius of the continuous efforts to promote, with a lot of advantages.
Compared to Windows, its advantages are also obvious
Free use
High safety
High efficiency
Customizable
Wide Application scope
During the Spring Festival, I happened to also go to see a movie--------------2, one fragment of which is the Linux system blowing marvellous, can learn Linux is also very happy.
Chapter II Basic Concepts and operation
Some knowledge of the following:
Usually when we use Linux, we do not deal directly with the system, but through an intermediary program called the shell.
The Shell under the Linux operating system is both the interface of user interaction and the scripting language of the control system.
The Ubuntu terminal uses bash by default.
Create a filetouch file
Go to Catalogcd /etc/
View current directorypwd
Common shortcut keys
button |
function |
tab |
Command completion |
Ctrl + C |
forcibly terminate current program |
Ctrl+d
keyboard input end or exit terminal |
ctrl+s |
Pause the current program, pause and press any key to resume running |
Ctrl + Z |
run the current program in the background and revert to the front desk for command FG |
Ctrl + A |
move the cursor to the input outfit, equivalent to the home key |
ctrl+e |
moves the cursor to the end of the input line, equivalent to the end key |
ctrl+k |
Delete from cursor position to end of line |
alt+backspace |
Delete one word forward |
shift+pgup |
Scroll terminal display up |
shift+pgdn |
Scroll the terminal display down |
↑ |
History input Command |
Shell Common wildcard characters
character |
meaning |
* |
Match 0 or more characters |
? |
Match any one character |
[List] |
Match any single character in the list |
[!list] |
Matches a character other than any single character in the list |
[C1-C2] |
Match any single word in c1-c2 such as: [0-9] [A-z] |
{String1,string2,...} Match string1 or string2 (or more) one string
{C1.. c2}| Match all characters in c1-c2 such as {1..10}
Banner Main program
Installation
$ sudo apt-get update$ sudo apt-get install sysvbanner
Print
$ banner shiyanlou
Font Change
$ printerbanner -w 50 A
This chapter job:
Chapter III User and file Rights management
- View User
$ who am i
$ who mom likes
- Who command
Parameters |
Description |
-A |
Print all that you can print |
-D |
Print the Dead process |
-M |
With AM I,mom likes |
-Q |
Print the current number of logged-in users and user names |
-U |
Print current logged in user login information |
-R |
Print Run level |
- New user
$ sudo adduser lilei
- Switch login User
$ su -l lilei
- Exit
exit
orCtrl+d
See which user groups you belong to
1.groups command$ groups shiyanlou
2. View/etc/group/file$ cat /etc/group | sort
Filter information$ cat /etc/group | grep -E "shiyanlou"
Add another user to the sudo user group
$ su shiyanlou $ groups lilei$ sudo usermod -G sudo lilei$ groups lilei
This chapter job
Fourth Linux directory structure and file basic operation
- The difference between a Linux directory and a Windows directory
- Linux is directory-based and Windows is based on storage media
- FHS Standard
- Directory path
- Go to the top level directory
$ cd ..
- Go to your home directory
$ cd ~
- Get the current directory using PWD
$ pwd
- Absolute path: The full path from the root "/" directory to the end of the directory you want to go to
- Relative path: In the current directory. As the starting point, to the end of the directory you want to go to
- Basic operations for Linux files
- New Blank Document
touch
command
- Create a new directory
mkdir
command, using -p
the same parent directory, example$ mkdir -p father/son/grandson
- Copy file
cp
command, example$ cp test father/son/grandson
- Copy directories,
cp
plus -r
or -R
, for example$ cp -r father family
- Delete file:
rm
, Force delete-f
- Delete directory:
rm
command plus -r
or-R
Moving files: mv
, example
$ mkdir Documents$ mv file1 Documents
- To rename a file:
$ mv file1 myfile
Batch rename:
# 使用通配符批量创建 5 个文件:$ touch file{1..5}.txt# 批量将这 5 个后缀为 .txt 的文本文件重命名为以 .c 为后缀的文件:$ rename ‘s/\.txt/\.c/‘ *.txt# 批量将这 5 个文件,文件名改为大写:$ rename ‘y/a-z/A-Z/‘ *.c
- View the file,
cat
tac
nl
- Page view File
more
,less
- View file types, example
$ file /bin/ls
- Edit File, example
$ vimtutor
Chapter fifth environment variables and file search
- Creating variables
$ declare tmp
- Assigning values to variables
$ tmp=shiyanlou
- Read the value of a variable
$ echo $tmp
- Environment variables
Commands related to environment variables: set
,, env
export
Command |
Description |
Set |
Displays all variables for the current shell, including the built-in environment variables (related to shell appearance, etc.), user-defined variables, and exported environment variables. |
Env |
Displays the environment variables that are relevant to the current user, and lets the command run in the specified environment. |
Export |
Displays variables that are exported from the Shell to an environment variable, and can also be exported to an environment variable by it. |
The Linux variables are divided into, permanent and temporary.
/etc/bashrc
Store Shell variables
/etc/profile
environment variable, permanent effect
- The lookup path and order of the command
- View PATH Environment variables
$ echo $PATH
- Create a shell script file
$ gedit hello_shell.sh
- Add executable permissions to a file
$ chmod 755 hello_shell.sh
- Execute script
$ ./hello_shell.sh
- Create a C language "Hello World" program
$ gedit hello_world.c
- Use GCC to generate executables after saving
$ gcc -o hello_world hello_world.c
Create a directory and move the file to it, for example:
$ mkdir mybin$ mv hello_shell.sh hello_world mybin/
- Add a custom path to the ' path ' environment variable
Add a custom path$ PATH=$PATH:/home/shiyanlou/mybin
Add content$ echo "PATH=$PATH:/home/shiyanlou/mybin" >> .zshrc
- Modify and delete an existing variable
- Variable modification
How variables are set |
Description |
${Variable name # Match string} |
Start the match from the back to delete the shortest data matching the matched string |
${variable name # #匹配字串} |
Start the match from the back to delete the longest data matching the matched string |
${variable name% matching string} |
Match from tail forward to delete the shortest data matching string |
${variable name percent match string} |
Match from tail forward to delete maximum data matching string |
${variable name/old string/new string} |
Replace the first string that matches the old string with a new string |
${variable name//old string/new string} |
Replace all strings that match the old string with a new string |
- Variable deletion
$ unset temp
- How to make an environment variable effective immediately
source
Command, example$ source .zshrc
source
Alias of the command .
, example$ source .zshrc
- Search for files
whereis
Simple and quick, example$ whereis who
locate
Fast and full, examples $ locate /etc/sh
,$ locate /usr/share/\*.jpg
which
Small and fine, example$ which man
find
Fine and thin, for example$ sudo find /etc/ -name interfaces
- Time-related command parameters
Parameters |
Description |
-atime |
Last Access time |
-ctime |
Last time the file content was modified |
-mtime |
Last time the file properties were modified |
Sixth. Document packaging and compression
- Common Compressed Package file format
file suffix name |
Description |
*.zip |
Zip program to package compressed files |
*.rar |
RAR Program Compressed files |
*.7z |
7zip Program Compressed Files |
*.tar |
Tar program packaging, uncompressed files |
*.gz |
Gzip (GNU Zip) compressed files |
*.xz |
XZ Program Compressed Files |
*.bz2 |
BZIP2 Program Compressed Files |
*.tar.gz |
Tar packaging, gzip program compressed files |
*.tar.xz |
Tar packaging, XZ program compressed files |
*tar.bz2 |
Tar package, BZIP2 program compressed files |
*.tar.7z |
Tar pack, 7z program compressed files |
Use the Zip Package folder, for example:
$ zip -r -q -o shiyanlou.zip /home/shiyanlou$ du -h shiyanlou.zip$ file shiyanlou.zip
To set the compression level package, for example:
$ zip -r -9 -q -o shiyanlou_9.zip /home/shiyanlou -x ~/*.zip$ zip -r -1 -q -o shiyanlou_1.zip /home/shiyanlou -x ~/*.zip
viewing compressed file information$ du -h -d 0 *.zip ~ | sort
- Create an encrypted ZIP package
$ zip -r -l -e -o shiyanlou_encryption.zip /home/shiyanlou
- Unzip the file
$ unzip shiyanlou.zip
- Quiet mode decompression
$ unzip -q shiyanlou.zip -d ziptest
- View the contents of a compressed package with no pressure
$ unzip -l shiyanlou.zi
Specifying the encoding typeunzip -O GBK 中文压缩文件.zip
- Installation Tools
$ sudo apt-get update$ sudo apt-get install rar unrar
- Create a compressed package or add a file to a compressed package from a specified file or directory
$ rm *.rar$ rar a shiyanlou.rar .
- deleting files
$ rar d shiyanlou.rar .zshrc
- View unresolved files
$ rar l shiyanlou.rar
- Full path decompression
$ unrar x shiyanlou.rar
- Go to the Path decompression
$ mkdir tmp$ unrar e shiyanlou.rar tmp/
- Create a tar Package
$ tar -cf shiyanlou.tar ~
- Unpacking a file to a specified directory
$ mkdir tardir$ tar -xf shiyanlou.tar -C tardir
- View only unresolved package files
$ tar -tf shiyanlou.tar
- Preserve file attributes and follow links
$ tar -cphf etc.tar /etc
- gzip Compressed Files
$ tar -czf shiyanlou.tar.gz ~
- Unzip the *.tar.gz file
$ tar -xzf shiyanlou.tar.gz
- Other formats
compressed file format |
Parameters |
*.tar.gz |
-Z |
*.tar.xz |
-j |
*tar.bz2 |
-j |
Seventh. File system operations and Disk Management
- View disk and directory capacity
df
commands, plus easier-to- -h
read
du
command to view directory capacity
Parameters |
function |
Du-h |
With--human-readable, the k,m,g is the unit to improve the readability of the information. |
$ du-h-D |
Specify the depth of the view directory |
Du-a |
The same--all displays the size of all files in the directory. |
Du-s |
Only the totals are displayed with--summarize, and only the last plus total value is listed. |
$ dd if=/dev/zero of=virtual.img bs=1M count=256$ du -h virtual.img
$ sudo mkfs.ext4 virtual.img
- Hanging on disk to the directory tree
- To view a file system that is already mounted
$ sudo mount
- Mount the real disk to the directory tree
mount [options] [source] [directory]
- Common operations
mount [-o [操作选项]] [-t 文件系统类型] [-w|--rw|--ro] [文件系统源] [挂载点]
- Cases:
$ mount -o loop -t ext4 virtual.img /mnt # 也可以省略挂载类型,很多时候 mount 会自动识别# 以只读方式挂载$ mount -o loop --ro virtual.img /mnt# 或者mount -o loop,ro virtual.img /mnt
- Uninstalling mounted Disks
$ sudo umount /mnt
- Partitioning a disk
- View hard disk partition table information
$ sudo fdisk -l
- Enter disk partition mode
$ sudo fdisk virtual.img
p
View Results
- Establishing an associated command for mirroring and loopback devices
losetop
The steps are as follows:
- See all loopback devices
$ sudo losetup /dev/loop0 virtual.img
- Unlock Device Association
$ sudo losetup -d /dev/loop0
Installation kpartx
Tools
$ sudo apt-get install kpartx$ sudo kpartx -av /dev/loop0# 取消映射$ sudo kpartx -dv /dev/loop0
- Formatting
Create a new four empty directory to mount the virtual disk:
$ mkdir -p /media/virtualdisk_{1..3}# 挂载磁盘分区$ sudo mount /dev/mapper/loop0p1 /media/virtualdisk_1$ sudo mount /dev/mapper/loop0p5 /media/virtualdisk_2$ sudo mount /dev/mapper/loop0p6 /media/virtualdisk_3# 卸载磁盘分区$ sudo umount /dev/mapper/loop0p1$ sudo umount /dev/mapper/loop0p5$ sudo umount /dev/mapper/loop0p6
$ df -h
Command Check Results
Eighth. Help commands under Linux
20165211 pre-Job 3 Linux installation and learning