Virtual machine Installation
Linux Learning
Section I.
- Linux: is an operating system, mainly system calls and two layers of the kernel.
- The role of the operating system in the entire computer system
- Learning Path:
Section II
- Terminal: This is done through a middle program called the Shell, in the graphical interface, in order for us to complete the user input and display output in a single window.
- Common terminal simulators: Gnome-terminal,konsole,xterm,rxvt,kvt,nxterm and Eterm.
- Shortcut keys:
Key |
effect |
ctrl+d |
Keyboard input end or exit terminal |
ctrl+s |
pause for future After pausing, press any key to resume running |
Ctrl + Z |
put the current program in the background to run, revert to the foreground command FG |
Ctrl + A |
moves the cursor to the input outfit, which is 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 |
Ctrl + C |
break or end command |
Tab |
for command completion, complete directory, fill command parameters, etc. |
ctrl+alt+f1~f6 |
Switch User login |
ctrl+alt+f7 |
switch back to graphical interface |
shift+n |
previous keyword |
- Wildcard: A special statement that has an asterisk (*) and a question mark (?) to make a fuzzy match to a string (such as a file name, parameter name).
character |
meaning |
* |
Match 0 or more characters |
? |
Match any one character |
[List] |
Match any single character in the list |
.... |
... |
Create a good command to switch to the newly created user
Note: The password entry for Linux does not show any content
- User group View Method:
- To delete a user:
- Linux file permissions
To view file permissions commands and procedures:
$ ls-1
Change file owner:
If the previous command to delete the Lilei user has been performed, recreate it here.
Assuming that the Lilei user is currently logged in, create a new file named "Iphone6":
$ Touch IPhone6
The visible file owner is Lilei:
Now, to change back to the Shiyanlou user identity, change the file owner to Shiyanlou using the following command:
Now check to see that the file owner was successfully modified to Shiyanlou:
Mode 1:2 binary numbers indicate:
$ echo "echo" Hello Shiyanlou "" > Iphone6
$ chmod iphone6
Mode two: Add and subtract assignment operations:
$ chmod GO-RW iphone6
Fourth quarter
- Linux directory structure
- FHS Standard:
FHS defines the directory as four interactive forms, as shown in the following table, depending on whether the file system is frequently used or not, and if the user is allowed to make arbitrary changes:
- Directory route by:
Command |
function |
$ CD. |
Current directory |
$ CD. |
Go to the top level directory |
$ cd ~ |
Go to Home directory |
$ pwd |
Get current path |
$ cd/usr/local/bin |
Absolute path |
$ CD. /.. /usr/local/bin |
Relative path |
- Basic operations for Linux files
Command |
function |
$ Touch User Name |
Create a blank file |
$ mkdir Mydir |
Create an empty directory |
$ mkdir-p Father/son/grandson |
Create a Multilevel Catalog |
$ CP Test Father/son/grandson |
Copy a file to the specified directory |
$ cp-r Father Family |
Recursively replicating directories |
$ RM Test |
Delete a file |
$ rm-f Test |
Force Delete Files |
$ rm-r Family |
Delete a directory |
$ mkdir documents + $ MV file1 documents |
Move the file "File1" to the "Documents" directory |
$ mv File1 myfile |
Rename the file "File1" to "myfile" |
$ cat passwd |
View "passwd" file |
$ cat-n passwd |
can display the file line number |
$ more passwd |
Open the "passwd" file |
$ tail/etc/passwd |
View "passwd" file |
$ tail-n 1/ETC/PASSWD |
Just see the first few lines. |
$ file/bin/ls |
View File types |
Fifth Quarter
- Environment variables
Variable: The shell variable, the so-called variable that is used in the computer to record a value (not necessarily a number, or a character or a string), and these symbols will be used in different operations processing.
The scope of a variable is the valid range of a variable (such as a function, a source file, or a global scope), where there can be only one variable with the same name. Once left, the variable is invalid, as if the variable does not exist in general.
Command |
function |
$ DECLARE variable name |
Create a variable |
$ Tmp=shiyanlou |
Assign a value to the TMP variable |
$ echo $tmp |
Read the value of a variable |
Note: Not all types of variable names are available, the variable name can only be English letters, numbers, or underscores, and cannot begin with a number.
- Environment variables:
- Classification:
- The current shell process private user-defined variables, such as the TMP variable we created above, are only valid in the current shell.
- The built-in variables of the Shell itself.
- An environment variable exported from a custom variable.
- Linux variables:
- Permanent: Need to modify the configuration file, the variable is permanently effective;
- Temporary: Using the Export command-line declaration, the variable is invalidated when the shell is closed.
- The lookup path and order of the command:
Command |
function |
$ echo $PATH |
View the contents of the PATH environment variable |
$ gedit hello_shell.sh |
Create a shell script file |
$ chmod 755 hello_shell.sh |
Add executable permissions to a file |
$./hello_shell.sh |
Execute script |
To add a custom path to the "path" environment variable:
$ path= $PATH:/home/shiyanlou/mybin
- To modify and delete an existing variable:
Modify:
$ path= $PATH
$ echo $path
$ path=${path%/home/shiyanlou/mybin}# or use wildcards to represent any number of any character
$ path=${path%/mybin}
Delete:
$ unset Temp
About Searching for files
Search-related commands are commonly used with whereis,which,find and locate.
$whereis who
$ locate/etc/sh
$ locate/usr/share/*.jpg
$ which man
$ sudo find/etc/-name interfaces
- Homework:
Sixth quarter
- Zip file suffix
> file suffix |
description |
*.zip
Zip program Packaging compressed Files |
*.rar |
RAR program compressed file |
*.7z |
7zip Program compressed Files |
*.tar |
tar program packaged, uncompressed file |
*.gz |
gzip Program (GNU Zip) compressed Files |
*.xz |
XZ Program compressed file |
*.bz2 |
bzip2 Program compressed Files |
*.tar.gz |
tar packaging, gzip compressed files |
*.tar.xz |
tar package, XZ program compressed file |
*.tar.bz2 |
tar package, bzip2 program compressed file |
*.tar.7z |
tar package, 7z program compressed file |
- Zip Compression Packager
- Package folder
- [] set compression level and view level
- extract zip file
-
Extract Shiyanlou.zip to the current directory
$ unzip shiyanlou.zip
-
Use Quiet mode to extract files to the specified directory
$ unzip-q shiyanlou.zip-d ziptest
-
Viewing the contents of a compressed package
$ unzip-l shiyanlou.zip
- rar Packaging compression command
Installing RAR and Unrar 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.
To delete a file from the specified compressed package file
$ rar d Shiyanlou.rar. ZSHRC
View unresolved files
$ rar L Shiyanlou.rar
Extracting RAR files using Unrar
$ unrar x Shiyanlou.rar
Create a tar Package
$ TAR-CF Shiyanlou.tar ~
Package a file (-x parameter) to the existing directory of the specified path (-c parameter)
$ du-h Shiyanlou.tar
Unpack
$ TAR-ZXVF Something.tar
To create a virtual image file using the DD command
$ dd If=/dev/zero of=virtual.img bs=1m count=256
$ du-h virtual.img
Format the disk with the MKFS command (we are here to create the virtual disk image ourselves)
$ sudo mkfs.ext4 virtual.img
Mount a disk to a directory tree using the Mount command
$ sudo mount
Uninstalling mounted disks using the Umount command
Command format sudo umount mounted device name or mount point, such as:
$ sudo umount/mnt
PS: Because of problems with our environment (the Linux kernel used in the environment did not add support for Loop device at compile time), you will not be able to mount a successful
Partitioning a disk using Fdisk
$ sudo fdisk-l
Enter disk partition mode
$ sudo fdisk virtual.img
Eighth Quarter
Help command: ZSH has built-in and does not have the Enable command, we can go into bash and have the command built into bash
$ bash
Help LS//for built-in commands
LS--help//For out-of-build commands
Man command: No distinction between built-in and external commands
Mans LS
Info command: Bash comes with commands
Info ls
20165330 preparatory work 3 Linux installation and learning