20165105 preparatory work 3 Linux installation and learning

Source: Internet
Author: User
Tags chmod gz file parent directory rar stdin file permissions

The installation process is carried out according to the graphic tutorial.

Follow the instructions provided by the teacher to download the installation of the VBox process is smooth, but in the download of Ubuntu image, English website download failed, through the cloud class in the Chinese students Wang YJ successfully downloaded the image, installed after the enhancement function encountered the following problems, find cloud class History news found a solution, is to eject the disc and click Enhance again.

Enhancements when the code, asked me "Yes or no" I answered 5 Yes after the program began to run, and finally continuously output "Y", I thought the program collapsed, it was forced to shut down ....

I do not know whether the enhanced function is successful, again knocked over the code, the result is the content shown, to the ink cloud class asked, the students said it was installed successfully.

Linux Basic Primer -- learn knowledge through experimentation

The problems encountered in the study can be answered in the cloud class, most of which is the historical news that other students have asked, and other small problems genius will answer for me.

Section I.

To understand the development of Linux, but also understand the similarities and differences between Linux and Windows, Linux has given me the most impressive is the security and stability of the system, as well as the efficiency of the use of proficiency.

Section II

After understanding the concept and sell of the terminal, it is time to start the command-line operation experiment.

Important Shortcut keys:

Tab: command completion, for my English base is poor students, this is a very important shortcut key, in I can not memorize commands, just enter the beginning, you can get the command I want to enter.

Ctrl + C: forcibly terminate the command, in case of problems in the program to avoid the program out of control.

Other common shortcut keys:

Ctrl+d Keyboard input end or exit terminal
Ctrl+s Pause the current program, pause and press any key to resume running
CTRL + Z Put the current program in the background to run, restore to the foreground for command FG
CTRL + A Move 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 Remove from cursor position to end of line
Alt+backspace Delete a word forward
Shift+pgup Scroll the terminal display up
Shift+pgdn Scroll down the terminal display

Section III:

Function

Command

View User

$ Who am I

Create user

sudo adduser (Yuehy)

Delete User

$ sudo deluser (Yuehy)--remove-home

Switch login User

Su–l Lilei

Exit Current User

Exit or CTRL + D

See which user groups belong to

Groups ... (user name) or Cat/etc/group | Sort

Filter

Cat/etc/group | Grep–e "Shiyanlou"

Add another user to the sudo group

sudo usermod-g sudo ... (User name)

Output files in the current directory in a longer format (view file permissions)

Ls-l

Show all except '. ', ' ... ' contains hidden files

Ls-a

View the full properties of a directory

LS-DL (directory name)

Show all file sizes and sort by size

Ls–assh

Create a new X file

Touch x

Modify file owner to Shiyalou

sudo chown Shiyanlou ...

Modify... Permissions

chmod 700 (Order corresponds to RWX) ... or chmod GO-RW (+/-) ...


Fourth quarter

Function

Command

Gets the current path (absolute path)

Pwd

Go to the top level directory

Cd..

Go to your "home" directory

CD ~ or cd/home/< your username >

Enter the/usr/local/bin directory as an absolute path

Cd/usr/local/bin

Enter the/usr/local/bin directory as a relative path

Cd.. /.. /usr/local/bin

Create a name called ... The Empty Directory

Mkdir...

Create parent directory at the same time

Mkdir-p Father/son/grandson

Copy a file test to the specified directory

CP Test Father/son/grandson

Copy a directory to the specified directory

Cp-r Father Family

Delete a file or directory

Rm...

Force delete using the-f parameter

Rm-f ...

Delete Directory

Rm-r ...

Move to Directory ...

MV File1 ...

Renaming files

MV Old NES

View... File

Cat ...

Look at the file and show the line number

Cat-n ...

Paging through files

More ...

Viewing files with the head and tail commands

tail/etc/passwd

Look at one line.

Tail-n 1/etc/passwd

To view the types of files with the file command

File/bin/ls

Fifth Quarter

Function

Command

Create a variable named tmp

DECLARE TMP

Assigning values to variables

Tmp=shiyanlou

Read the value of a variable

Echo $tmp

Print related environment variables

Set (all environment variables), env (variables related to the current user), export (variables exported as environment variables)

Send command output through pipelines | Sort by using the sort command and then redirecting to the object text file

Export Temp_env=shiyanlou; env|sort>env.txt;export|sort>export.txt;set|sort>set.txt

Compare the contents of several exported files

Vimdiff env.txt export.txt Set.txt

Creating a child shell based on the experimental building environment

Zsh

Temp is a variable in the shell, exported as an environment variable

Export Temp

Create a shell script file

Vim hello_shell.sh

Execute script

./hello_shell.sh

Generate an executable file with GCC

Gcc-o Hello_world HELLO_WORLD.C

Add a custom path to the "path" environment variable

Path= $PATH:/home/shiyanlou/or echo "path= $PATH:/home/shiyanlou/mybin" >> ZSHRC

Variable modification to Path

${path# string},${path% string},${path# #字符串},${path%% string},${path//old string/new string},${path/old string/new string}

Delete Variable Temp

unset Temp

Make the. zshrc file effective immediately

source. ZSHRC or. ./.ZSHRC

Search for related commands

Whereis (only binary (-B), man Help file (-m), and source code (-s)), which (determines whether a specified software is installed, only searches for commands from the path specified by the PATH environment variable), find, Locate (different file types under the specified directory)

Find all files in/etc that begin with SH

Locate/etc/sh

Find all JPG files under/usr/share/

Locate/usr/share/*.jpg


Sixth quarter

Function

Command

Use Zip to package folders

Zip-r-q-o Shiyanlou.zip/home/shiyanlou

View the size of a packaged file

Du-h Shiyanlou.zip

Set the compression level to 9 and 1 (9 max, 1 min), repack

Zip-r -9-q-o shiyanlou_9.zip/home/shiyanlou-x ~/. zip; zip-r -1-q-o shiyanlou_1.zip/home/shiyanlou-x ~/ . zip

View the default compression level, minimum, maximum compression level, and uncompressed file size with the du command

Du-h-D 0 *.zip ~

Create an encrypted ZIP package

Zip-r-e-o Shiyanlou_encryption.zip/home/shiyanlou

Make the ZIP archive created on Linux do not have any problems after extracting it on Windows

Zip-r-l-o Shiyanlou.zip/home/shiyanlou

Extract the 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

View only the contents of a compressed package

Unzip-l Shiyanlou.zip

Specifying the encoding type when extracting

Unzip-o GBK Chinese compressed file. zip

Create a compressed package or add a file to a compressed package from a specified file or directory

RM *.zip;rar a Shiyanlou.rar.

To delete a file from the specified compressed package file

RAR d Shiyanlou.rar. ZSHRC

View only unresolved files

RAR l Shiyanlou.rar

Full path decompression

Unrar x Shiyanlou.rar

Remove Path Decompression

Unrar e Shiyanlou.rar tmp/

Create a tar package (package only, do not compress)

TAR-CF Shiyanlou.tar ~

Unpack a file (-x parameter) to the existing directory of the specified path (-c parameter)

TAR-XF shiyanlou.tar-c ...

View only unresolved package files

TAR-TF Shiyanlou.tar

Keep file attributes p and follow link h (symbolic link or soft link)

TAR-CPHF etc.tar/etc

Use gzip to compress files

TAR-CZF shiyanlou.tar.gz ~

Unzip the *.tar.gz file

Tar-xzf shiyanlou.tar.gz

Unzip the *.tar.xz file

-j

Unzip the *tar.bz2 file

-j

Seventh Quarter

Function

Command

To view the capacity of a disk

Df

View disk capacity in an easy-to-read manner

Df-h

View directory capacity

Du ...

View directory capacity in an easy-to-read manner

Du-h

View Directory Depth

Du-h-D 0 ~ (View level 1 directory only);d u-h-D 1 ~ (view 2 level only)

Read user input (output to file) from standard input with dd command

DD of=test bs=10 count=1 (or dd If=/dev/stdin of=test bs=10 count=1)

(output to standard output)

DD If=/dev/stdin of=/dev/stdout bs=10 count=1

Convert output English characters to uppercase and write to file

DD If=/dev/stdin of=test bs=10 count=1 conv=ucase

Create an empty file with a capacity of 256M from the/dev/zero device

DD If=/dev/zero of=virtual.img bs=1m count=256

Use MKFS to format a vdisk image as a Ext4 file system

sudo mkfs.ext4 virtual.img

See what file systems Linux supports

ls–l/lib/modules/$ (uname-r)/kernel/fs

Use mount to view a file system that the host has mounted

sudo mount

Mount the virtual disk image to the/MNT directory

Mount-o loop-t Ext4 virtual.img/mnt

Mount in read-only mode

Mount-o Loop--ro virtual.img/mnt (or Mount-o loop,ro virtual.img/mnt)

Uninstalling mounted disks with the Umount command

sudo umount/mnt (mount point)

Partitioning a disk

Fdisk

View hard disk partition table information

sudo fdisk-l

Enter disk partition mode

sudo fdisk virtual.img (enter p to view the results after the operation is completed, and then write the W to the partition table)

To establish an association between a mirror and a loopback device

sudo losetup/dev/loop0 virtual.img

View all loopback devices

ls/dev/loop*

Remove a Device association

sudo losetup-d/dev/loop0

Creating a virtual device mapping with the Kpartx tool

sudo kpart kpartx-av/dev/loop0

de-mapping

sudo kpart kpartx-dv/dev/loop0

Once the mapping is established, it is all formatted as EXT4

sudo mkfs.ext4-q/dev/mapper/loop0p1

Create a new four blank directory in the/media directory to mount the virtual disk

Mkdir-p/media/virtualdisk_{1:3}

Mount Disk Partitions

sudo mount/dev/mapper/loop0p1/media/virtualdisk_1 (etc.)

Unmount Disk Partitions

sudo umount/dev/mapper/loop0p1 (etc.)

Eighth Quarter

Function

Command

Use the type command to differentiate whether the command is built-in or external

Type ... (Command name)

Zsh built-in without help, into bash

Bash

Enter bash built-in with help

Help LS (not possible, because it is used to show shell built-in commands)

Foreign-built orders

LS--help

Get help with Man

Man ... (command name) (Exit with Q)

Get more help with info

Info ... (Command name)

20165105 pre-Job 3 Linux installation and learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.