20165203 preparatory work 3 Linux installation and learning

Source: Internet
Author: User
Tags first string parent directory rar stdin

First, install the virtual machine

1. Download problem: When you download Ubuntu on the virtual machine, always download for a long time, and the last download failed, which makes me very distressed.
Solution: To help students, students gave me a Chinese version of the website http://cn.ubuntu.com/desktop/, this is the download. Installation of a good interface

2. The following issues occurred when installing the virtual machine enhancements:
Solution: So I query Baidu, finally in a blog found a solution:
Enter the system on the side to find the loaded virtual CD-ROM, right-click, click Eject, then you can install the enhanced function properly

Second, Linux learning notes

I can say almost a computer small white, my traditional way of learning or good memory than bad pen, I still used to see the focus of the notes down, of course, learning Linux or to first operate, and then summarize, I also want to summarize my focus on sharing to you:

1.Linux System Introduction and basic concepts and operations
    • Terminal Simulator: In order to achieve the user's input and output in a single window. The essence is the Dev/tty device on Linux. How to open the terminal: [ctrl]+[alt]+t
    • Shell: The difference in the actual experience in the graphical interface is the software < command parser that is provided to the user to use the interface, and the program that can accept users ' input commands.
    • Ubuntu Terminal uses bash by default, desktop environment is gmome or unity
    • Command-line operation:
      Input: Open terminal, press keyboard input
      Output: Returns the desired result (no result is the best result)
    • Important Shortcut keys:
shortcut Keys function
[Tab] Command completion
[Ctrl + C] Forcibly terminates the current program, but does not cause the terminal to exit
[Ctrl+d] Keyboard input end or exit terminal
[Ctrl+s] Pause the current program, pause and press any key to resume running
    • Wildcard characters: to blur a character, find a folder, use it instead of one or more real characters, or use wildcards instead of one or more real characters when you don't know the true character or lazy input full name.
    • Common wildcard characters:
Common wildcard characters function
* 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] Matches any single character in the C1-C3, [0-9],[a-z]
{string1,string2,] Match string1 or string2, one string
{C1 C2} Matches all characters in the CI-C2, such as {1 10}
    • How to get Help on the command line
      Use the man command
      Find method: Man L Find content
2. User and file Rights management
function Command
View User Who am I
Create user sudo adduser < user name >
See which user groups you belong to Groups < username > or cat/etc/group
Switch login User Su-l < user name >
Exit Current User Exit or Ctrl+d
Delete User sudo deluser < user name >--remove-< directory >
Add another user to the sudo group sudo usermod-g sudo < user name >

Linux file permissions

    • Highest privilege: root privilege, root privileges can be obtained by sudo command
    • Read permissions: You can use cat < file name > to read file contents
    • Write permissions: You can edit and modify a file
    • Owner permissions: The permissions of all users in the user group that are in the file
function Command
Output files in the current directory in a longer format (view file permissions) Ls-l
Show except ".", "..." Contains hidden files except for all Ls-a
View the full properties of a directory LS-DL < directory name >
Create a new ... File Touch ...
Show... File information ll
Modify file owner to Shiyanlou sudo chown Shiyanlou ...
Modify Permissions chmod 700 (Order corresponds to RWX) ... or chmod GO-RW (+/-) ...
3.Linux directory structure and file basic operation
    • Catalog Form

    • Path
path name Notes
Absolute path The full path starting with the root "/" directory, ending with the directory you want to/user/local/bin
Relative path to the current directory. As the starting point, take the desired directory to the end User/local/bin
Command function
Touch < file name > Create a new blank file, without any parameters, specify only one file name, creating a blank file with the specified file name
mkdir < directory name > You can create an empty directory
Mkdir-p < directory name > Create parent Directory
CP < file name > < directory name > Copy files to this directory
Cp-r or-r < directory name > Copy Directory
RM < file name > deleting files
Rm-r or-r < directory name > Delete Directory
Rm-f < file name > Force Delete
MV < file names > < directories > Move files to the directory
MV < filename 1> < filename 2> Modify file name
Cat < file name > Print file contents to Terminal (positive order display) (plus-n Display line number)
Tac < file name > Print file contents to terminal (reverse display) (plus-n Display line number)
NL < file name > Add line numbers and print
More and less Paging through files
Tail-n < digital > < files > View the tail lines of a file
Head-n < digital > < files > View the first few lines of a file
4. Environment variables and file lookup
command function
Declare temp creates a variable named temp
echo $temp Read the value of temp
set Print all environment variables
env Print the environment changes related to the current user Volume
export display variables from the shell for export or environment variables
ZS H Create a child shell in the lab environment
gedit hello_shell.sh Create a script file
chmod 755 hello_shell.sh Add executable permissions to files
. Hell o_shell.sh Run script file
gedit Hello world.c create C language Program
gcc-o Hello world Hello world.c generate executable text
    • Variable modification
How variables are set function
${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

--selected from the experimental building

Command function
unset Temp Delete environment variable Temp
source. ZSHRC Quickly make the. ZSHRC script file effective
Whereis who Search files who can only search binary files, source code files and man help documents
Locate Search for all matching files under a path
which Find out if a specified file is installed
Fine Also find files, command more powerful
sudo find/etc/-name interfaces Find a file named interfaces in the/etc/directory
Find ~-mtime 0 List files that have changed in the home directory for the day
Find ~-newer/home/shiyanlou/code List user home directory under code new file
5. File packaging and decompression
Command function
Zip-r-q-o Shiyanlou.zip/home/shiyanlou Package directory/home/shiyanlou as a file
Du Shiyanlou.zip See the size of the file Shiyanlou.zip in detail
Zip-r-9 (or-1)-q-o Shiyanlou.zip/home/shiyanlou Package directory/home/shiyanlou as a compressed file with a compression level of 9 (or 1)
Du-h-D 0 *.zip ~ View the depth of a file
Zip-r-e-o Shiyanlou.zip/home/shiyanlou Create a cryptographic package (with emphasis on the use of the-e parameter)
Unzip Shiyanlou.zip Extract the Shiyanlou compressed file to the current directory
Unzip-q shiyanlou.zip-d Ziptest Extract the Shiyanlou compressed file to the specified directory
Unzip-l Shiyanlou.zip View Shiyanlou.zip Compressed Package
RAR a shiyanlou.rar. Create a compressed file under the. Directory (A is a parameter)
RAR d Shiyanlou.rar. ZSHRC Removed from the Shiyanlou.rar compressed package. ZSHRC
Unrar x Shiyanlou.rar Full path decompression
Unrar e Shiyanlou.rar tmp\ Remove Path Decompression
TAR-CF Shiyanlou.tar ~ or tar-f shiyanlou.tar-c ~ Create a tar Package
Tar ==-x==f shiyanlou.tar ==-c== tardir Unpacking a file to a specified directory
TAR-TF Shiyanlou.tar View only unresolved package files
TAR-CZF shiyanlou.tar.gz ~ Use GIZP to compress files
Tar-xzf shiyanlou.tar.gz Unzip the file
6. File system operations and Disk Management
Command function
Df To view the capacity of a disk
Du-h View the capacity of a directory and render it in a more readable manner
Du-a Displays the size of all files in the directory
Du-s Displays a synthesis of the final file capacity
Du-h-D 0 ~ (View level 1 directory only);d u-h-D 1 ~ (view 2 level only) View Catalog
DD of=test bs=10 count=1 (or dd If=/dev/stdin of=test bs=10 count=1) Output from standard input to file with dd command
DD If=/dev/stdin of=/dev/stdout bs=10 count=1 Output to standard output
DD If=/dev/stdin of=test bs=10 count=1 conv=ucase Convert output English characters to uppercase and write to file
DD If=/dev/zero of=virtual.img bs=1m count=256 Create an empty file with a capacity of 256M from the/dev/zero device
sudo mkfs.ext4 virtual.img Virtual disk mirroring is formatted as a EXT4 file system
sudo mount Use mount to view mounted file systems
Mount-o loop-t virtual.img/mnt Mount the virtual disk image to the/MNT directory
Mount-o Loop--ro virtual.img/mnt (or Mount-o loop,ro virtual.img/mnt) Mount in read-only mode
sudo unmount/mnt Uninstalling a mounted disk using the unmount command sudo fdisk-l
7. Help commands
Command function
Type < command > See if the command was built or built out.
Help < built-in commands > Displays brief help for the built-in command
< external commands >--help Show brief help for external commands
Man < command > Display command information for help
Info < commands > Display command information for help (more details)
Third, feelings

The winter vacation is coming to an end, but for the study and exploration of Linux is not over, but also more practice, so that "do high school" to implement the entire Java learning.

20165203 preparatory work 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.