A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service
Through the learning practice based on the VirtualBox virtual machine installed Ubuntu Graphics tutorial, started the installation of virtual machines, according to the tutorial step by step to complete.
1. In the installation of Ubuntu system software, click on the official website download page error occurred, the download did not succeed
2. When the boot disk is selected, there is no direct selection of the package, but the selected file after decompression, there is an installation error
1. By turning to classmates, we got the download resources of Ubuntu system software and successfully downloaded
2. By re-downloading Ubuntu system software and re-selecting it, the final installation is successful.Learning of the Linux commands one. Learn the ingenious method of learning Linux commands
Understand that Linux is also an operating system, as well as the architecture and learning path of this operating system.
At the beginning of the study, the Linux command, the Man command and the cheat command of the understanding is not deep, do not understand how they apply to the actual and what the meaning, just follow the text of the shortcut keys and commands to practice, the three kinds of core commands have a superficial understanding.
The Linux operating system includes the system call and the kernel two layers in the computer system.
Learn about the history of Linux and the different points of Windows and Linux. Windows is closer to our daily lives, easy to use, wide application-oriented, compatible, and Linux operating systems are more intrinsic, more secure, and support open source.
Ctrl+Alt+F1~F6to switch and press to
Ctrl+Alt+F7switch back to the graphical interface.
TabKey to complete the command, complete the directory, fill the command parameters
Ctrl+cForcibly terminates the current program
Ctrl+dKeyboard input end or exit terminal
Ctrl+sPause the current program, pause and press any key to resume running
Ctrl+zPut the current program in the background to run, restore to the foreground for command FG
Ctrl+aMove the cursor to the input wardrobe
Ctrl+eMove the cursor to the end of the input line
Ctrl+kRemove from cursor position to end of line
Alt+BackspaceDelete a word forward
Shift+PgUpScroll the terminal display up
Shift+PgDnScroll down the terminal display
Create multiple files at once:
The following sections are generally included: name, Synopsis (summary), DESCRIPTION (description), EXAMPLES (example), see ALSO
whoamiView the user name of the currently logged on user
who -aPrint all that you can print
who -dPrint the Dead process
who -mWith AM I,mom likes
who -qPrint the current number of logged-in users and user names
who -uPrint current logged in user login information
who -rPrint Run level
In the Linux system, the new/add user needs root privileges, to use
sudo This command, there are two prerequisites: one is to know the current login user's password, and the second is the current user must be in the sudo user group.
su <user>Can switch user, need to enter a password (Linux input password is not shown)
sudo <cmd>You can run the cmd command at a privileged level, require that the current user belongs to the sudo group, and require the current user password to be entered. For example:
sudo adduser lilei create a user named Lilei.
su - <user>The user is also switched, and the environment variable is changed to the target user's environment variable. For example: You
su -l lilei can switch to Lilei user login.
You can use
exit and shortcut keys as you exit the current user and exit the terminal
Method One: Use the groups command
Where the colon is preceded by the user, followed by the user group that the user belongs to. Here you can see that the Shiyanlou user belongs to the Shiyanlou user group, and each time a new user does not specify a user group, the default is to automatically create a user group with the same user name.
Method Two: View/etc/group file
The cat command reads the contents of the specified file and prints it to the terminal output.
| sortindicates that the text to be read is sorted in a dictionary and then output. At the bottom you can see the user group information for Shiyanlou. It can also be filtered and then output in the following ways.
Add other users to the sudo user group
usermod the command to add a user group to a user, which must have root privileges.
You can use the root user to add user groups to other users, or use the sudo command for other users who are already in the sudo user group to execute the command.
Use the LS command to view
$ ls -l
lsOther uses of the command
ls -AShow except '. ' (current directory), ' ... ' All files that contain hidden files except the ones above the previous directory (the file that starts with '. ' In Linux is a hidden file)
ls -dl< directory name > View the full properties of a directory instead of displaying the file attributes in the directory
Change file Owner
ls -AsShDisplays all file sizes and renders in a way that ordinary people can understand, where small s is the size of the display file and big S is sorted by file size
lilei is not in the sudoers file
sudo usermod -G sudo lileiand change the file owner
Three sets of permissions for each file (owner, user group, other user, remember this order is certain) corresponds to a "rwx", that is, a "7"
If I want to change the permissions of the file "Iphone6" to only I can do so:
$ chmod 700 iphone6
Add a user loutest, use
sudo Create file
/opt/forloutest , set to user loutest can read and write. And the operation process is written into the experimental report.
Linux is a tree-shaped directory structure to build the entire system, logically, Linux disk is "hung in" (mounted) directory, each directory can not only use the local disk partition of the file system, can also use the file system on the network.FHS Standard
FHS defines the two-tier specification, the first layer is
/ what file data should be placed in each of the following directories, such as/etc should be placed in the settings file,/bin and/sbin should be placed executable files and so on.
The second layer is defined for the subdirectories
/var of the two directories. For example,/var/log places system log files,/usr/share places shared data, and so on.
cd command to switch directories, in Linux use
. represents the current directory, the first
.. level of the directory (to
. start with the file is a hidden file, you can use the
ls -a command to view hidden files), to
- indicate the last directory,
～typically represents the home directory of the current user. Use the
pwd command to get the current path (absolute path).
The full path from the root "/" directory to the end of the directory you want to go to
/usr/local/binA directory that represents a directory in the directory under the root directory
Relative to the path to your current directory, the relative path starts at the current directory and
. ends with the directory you want to go to, in the form of:
usrDirectory is a subdirectory
/ under the directory, you can omit it,
. if it is the current directory of the previous level of directory, you need to use
.. , such as your current directory as a
home directory, the root directory should be represented as the top level directory
home directory) of the previous level directory ( c14/> directory).
In the process of directory switching can be more use of
Tab key auto-completion, to avoid input errors, press two consecutive Tab to display all candidate results
Create a new blank file
touchCreate a blank file with a command
$ touch test
Use the Make
mkdir directories command to create an empty directory or to specify permission properties for creating a directory
$ mkdir 文件名
Create a multilevel directory: using
-p parameters to create a parent directory at the same time, you can create a multilevel directory at once (this is useful when installing the software and configuring the installation path at times):
$ mkdir -p father/son/grandson
cp the (copy) command to copy a file or directory to the specified directory.
$ cp test father/son/grandson
To successfully replicate a directory requires
-r a plus or
-R a parameter that represents recursive replication:
$ cp -r father family
rmDelete a file or directory using the (remove files or directories) command: (can be forced to delete using the-f parameter)
$ rm test
$ rm -f test
As with the copy directory, to delete a directory, you also need to add
$ rm -r family
mvthe (move or rename files) command to move the file (cut). Move the file "File1" to the "documents" directory MV source directory file destination directory:
$ mkdir Documents
$ mv file1 Documents
Renaming filesRename the file "File1" to "myfile" mv old filename new file name:
$ mv file1 myfile
nl commands to view files
catis displayed in reverse order, and the
nlcommand adds the line number and prints it.
$ cat passwdYou can add the
-nparameter to display the line number.
$ cat -n passwd
lessis the content that is inherently used to "read" a file.
$ more passwd
tail commands to view files
Head only looks at the first few lines of the file (the default is 10 lines, and less than 10 lines show all) tail only a few lines.
You can look at a line more directly, plus a parameter, followed by the
-n number of rows:
$ tail -n 1 /etc/passwd
Use the file command to view the types of files:
$ file 文件名
Editing files under Linux usually we use a dedicated command line editor like (Emacs,vim,nano)
A variable is a symbol in your computer that is used to record a value (not necessarily a number, or a character or a string).
declarethe command to create a variable named tmp:
$ declare tmp
=number assignment operator to assign the variable tmp value to Shiyanlou:
Read the value of a variable: use
echo commands and
$ symbols (
$ symbols are used to denote values that refer to a variable):
$ echo $tmp
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.
Permanent effectAccording to the lifetime of the variables, the Linux variables can be divided into two categories:
If you want to add a permanently active environment variable, just open/etc/profile, and at the end add the environment variable you wantThe search path and order of the command
Search through the environment variable path in the shell. When we execute a command in the shell, the system will go through the directory in the order followed by the path set in the path, and if there is a command with the same name, execute the one found first.
Back to the top level of the directory, that is, the Shiyanlou home directory, when you want to run the two programs, you will find that the prompt command can not be found, unless the full path of the command, but it is inconvenient, how do you want to use the same system command to execute the script file or program you created? Then add the path of the command to the paths environment variable.
The paths inside the path are: as delimiters:
Note that absolute paths must be used here.
Appending the path in the PATH environment allows you to execute the two commands in any directory, taking care to remove the preceding.
The command to add a custom path to path is automatically executed each time the Shell is started.
You can simply use the following command to add content directly to
$ echo "PATH=$PATH:/home/shiyanlou/mybin" >> .zshrc
The above command
>> indicates that the standard output is redirected to a file in an append manner, noting that the previous use is to redirect to
> a file in a way that is overwritten and must be distinguished when used. A new file will be created if the specified file does not exist.
unset Delete an environment variable using a command:
$ unset temp
sourcecommands to make them effective immediately, such as:
$ source .zshrc
Search for files
sourceThe command also has an alias that is
. , notice that the point area that represents the current path is separate, although the form is different, but in the same way, the above command if replaced
. by the way it should be:
$ . ./.zshrc
Note that the first point is followed by a space, and the subsequent file must specify a complete absolute or relative pathname , which is
source not required.
Whereis Simple and fast
The search was quick because it did not look up from the hard disk, but instead queried directly from the database. Whereis can only search binaries (-B), man Help Files (-m), and source code files (-s).
Locate Fast and full
Through the "/var/lib/mlocate/mlocate.db" Database lookup, but this database is not updated in real-time, the system will use a timed task to automatically perform the
updatedb command update once a day, so sometimes just add the file, it may not be found. It can be used to find different file types under the specified directory.
If you want to only count the number can be added to the-c parameter, the-i parameter can ignore the case to find, Whereis-b,-m,-s can also be used.
which small and fine
Which itself is a shell built-in command, and we typically use which to determine if a specified software is installed because it only searches for commands from the path specified by the PATH environment variable
Find fine and fine
Can be found by file type, filename and can be searched according to the properties of the file (such as the file's timestamp, file permissions, etc.)
$ find /etc/ -name interfaces
Note the path to the Find command is the first parameter, and the basic command format is find [path] [option] [action].
findcommands to prompt for insufficient permissions
-rThe parameter indicates that the recursive package contains the entire contents of the subdirectory, and the
-q parameters are expressed in quiet mode, that is, not outputting information to the screen,
-o indicating the output file, followed by packaging the output filename immediately thereafter. Later use
du the command to view the size of the packaged file
Visible default compression level should be the highest
Note: Only absolute paths can be used here, otherwise it will not work
-e parameters to create an encrypted compressed package:
$ zip -r -e -o shiyanlou_encryption.zip /home/shiyanlou
If you want to create a zip file on Linux that has no problem after extracting it on Windows, then you need to make some changes to the command:
Extracting a ZIP file using the unzip command
$ zip -r -l -o shiyanlou.zip /home/shiyanlou
The need to add
-l parameters will be
LF converted to achieve the
CR+LF above purpose.
$ unzip shiyanlou.zip
$ unzip -q shiyanlou.zip -d ziptest
$ unzip -l shiyanlou.zip
-O the (English letter, capital O) parameter to specify the encoding type:
unzip -O GBK 中文压缩文件.zip
To create a compressed package or add a file to a compressed package from a specified file or directory:
$ rm *.rar
$ rar a shiyanlou.rar .
Note: RAR command parameters do not-if added will error.
$ rar d shiyanlou.rar .zshrc
$ rar l shiyanlou.rar
$ unrar x shiyanlou.rar
$ mkdir tmp
$ unrar e shiyanlou.rar tmp/
$ tar -cf shiyanlou.tar ~
-cRepresents creating a Tar package file that
-f specifies the name of the file to be created, noting that the file name must immediately follow the
-xparameter) to an existing directory (parameter) of the specified path
$ tar -xf shiyanlou.tar -C tardir
$ tar -tf shiyanlou.tar
Keep file attributes and follow links (symbolic links or soft links), sometimes we use tar to back up files when you restore to other hosts you want to keep the attributes (parameters) of the file
-p and the source file that the backup link points to instead of the link itself (
$ tar -cphf etc.tar /etc
To create a file in a different compressed format, we only need to add parameters based on the creation of the tar file
-z , using gzip to compress the file.
$ tar -czf shiyanlou.tar.gz ~
$ tar -xzf shiyanlou.tar.gz
We want to use other compression tools to create or unzip the corresponding file only need to change one parameter:
|compressed file format||Parameters|
To view disk capacity using the DF command
$ df -h
To view the capacity of a directory using the du command
$ du -h -d 0 ~
$ du -h -d 1 ~
Du-s #同--summarize only displays totals, listing only the last added value.Simple Disk Management Create a virtual disk
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
$ du -h virtual.img
Format a disk with the MKFS command
$ sudo mkfs.ext4 virtual.img
Mount a disk to a directory tree using the Mount command
mount [options] [source] [directory]
mount [-o [操作选项]] [-t 文件系统类型] [-w|--rw|--ro] [文件系统源] [挂载点]
The problem I'm having
Displays only the root user to perform when mounting a real disk to the directory tree
Try to use
$ sudo mount -o loop -t ext4 virtual.img /mnt
was still unsuccessful, and then learned to learn that due to the environment of the Experimental Building (the Linux kernel used in the environment did not add support for Loop device at compile time), it cannot be mounted successfully
Uninstalling mounted disks using the Umount command
$ sudo umount /mnt
Partitioning a disk using Fdisk
$ sudo fdisk virtual.img
The built-in commands are actually part of the shell program, which contains some of the simpler Linux system commands that are written in the bash source Builtins and are identified by the shell program and run inside the shell program, usually in Linux When the system loads the runtime, the shell is loaded and resides in system memory. and parsing the internal command shell does not need to create a child process, so it executes faster than an external command. For example: History, CD, Exit and so on.
External commands are part of the utilities in a Linux system, because the utility is usually powerful, so it contains a large number of programs that are not loaded into memory with the system when the system is loaded, but instead call memory when needed. Although it is not included in the shell, its command execution process is controlled by the shell. External commands are installed outside of Bash, usually on/bin,/usr/bin,/sbin,/usr/sbin, and so on. For example: LS, vi and so on.
Differentiate between built-in commands and external commands
xxx is a shell builtinbash source. def
xxx is /usr/sbin/xxxThe result is an external command, an external command in/usr/bin Or/usr/sbin, etc.
xxx is an alias for xx --xxx result is obtained, it indicates the name set by the command alias;
The help command can only be used to display information about the built-in commands
To display external commands, use the
20165230 preparatory work 3 Linux installation and learning
Start building with 50+ products and up to 12 months usage for Elastic Compute Service