20165327 preparatory work 3 Linux installation and learning one, learn to install Ubuntu Graphics tutorial based on VirtualBox virtual machine, install Linux operating system on your own notebook, pay attention to use the latest version of VirtualBox and Ubuntu as far as possible
The installation of the virtual machine may be the reason for the notebook itself, so only 32-bit systems are installed.
Just a bit of a problem when installing Ubuntu, so the experiment was done in the lab building environment.
If you go back to school and solve
Second, learn the learning method of Linux commands by practicing the ingenious learning method of Linux commands.
First of all, solve the doubts in my heart, what is Linux? is an operating system!
Another feature of the Linux learning application is the use of the command line.
Operating system operating system for you to complete all "hardware-related, application-independent" work, to give you convenience, efficiency, security. Operating system features I conclude with two points: housekeeper and waiters:
Steward: Three important abstractions for managing your computer's CPU, memory, and I/O devices through processes, virtual memory, and files.
Waiter: Provide a shell for the user and provide system calls to the programmer.
Third, the practice of Learning Basic Linux Basics (new) course, Master Common Linux commands, the focus is 3/4/5/6/7/8 section. (i) Introduction to Linux Systems (ii) Basic concepts and Operations (iii) User and file Rights management
1. View Users
Enter the command:
$ Who am I
Or
$ who mom likes
- Other common parameters of the WHO command:
-A print all that can be printed
-D Print dead process
-M with AM I,mom likes
-Q Print The current number of logged in users and user name
-U print current logged in user login information
-R print Run level
2. Create user
su< user> (Note: There is no space in the middle, the basic grammatical problem that is not solved temporarily, the same as below) can switch to user users
sudo < cmd> can run cmd command at privileged level, requires the current user to belong to the sudo group
The Su-< user> command also switches the user, and the environment variable is changed to the target user's environment variable.
$ ls/home This command not only adds users to the system, but also creates a home directory for new users by default
Use the following command to switch the logged in User:
$ su -l lilei $ sudo adduser lilei
3. How do you know which user groups you belong to in Linux?
Method One: Use the groups command
$ groups shiyanlou
Method Two: View /etc/group file
$ cat /etc/group | sort
Use the commands to filter out some of the results you don't want to see:
$ cat /etc/group | grep -E "shiyanlou"
4. Use the Shiyanlou user to execute the sudo command to add Lilei to the sudo user group so that it can also use the sudo command to gain root privileges:
$ su shiyanlou$ groups lilei$ sudo usermod -G sudo lilei$ groups lilei
5. Delete users
$ sudo deluser lilei --remove-home
Change file Owner
$ touch iphone6
Visible file owner is Lilei
Now, to change back to the Shiyanlou user identity, change the file owner to Shiyanlou using the following command:
$ cd /home/lilei$ ls iphone6$ sudo chown shiyanlou iphone6$ ll iphone6
6. Modify File Permissions
mode 1:2 binary digit representation
To demonstrate, add the contents to the file first:
$ echo "echo \"hello shiyanlou\"" > iphone6
Then modify the permissions:
$ chmod 700 iphone6
Now, other users can't read this iphone6 file anymore.
(iv) LINUX directory structure
1, FHS Standard
$ sudo apt-get update$ sudo apt-get install tree$ tree /
2. Directory path
Use the CD command to switch directories and use them inside Linux. Represents the current directory,.. Represents the previous level of the directory (in. The files at the beginning are hidden files, so the two directories must also be hidden, you can use the LS-A command to view the hidden files,-the last directory, ~ usually represents the current user's home directory. Use the PWD command to get the current path (absolute path).
Go to the top level directory:
$ cd ..
Go to the home directory:
$ cd ~
Get the current path using PWD:
$ pwd
3. Create a new blank file
$ touch test
New Catalog
Create an empty directory named "Mydir":
$ mkdir mydir
Use the-p parameter to create the parent directory at the same time (if the parent directory does not exist):
$ mkdir -p father/son/grandson
4. Copying files
$ cp test father/son/grandson
Copy Directory
$ cp -r father family
5. Delete Files
$ rm test
Force Delete File :
$ rm -f test
Delete Directory
$ rm -r family
6. Moving files
Move the file "File1" to the Documents directory:
$ mkdir Documents$ mv file1 Documents
7. Renaming files
Rename the file "File1" to "myfile":
$ mv file1 myfile
8. Batch Rename
Use wildcards to create 5 of files in bulk:
$ touch file{1..5}.txt
Rename the 5 text files with a. c suffix to the file in bulk:
$ rename ‘s/\.txt/\.c/‘ *.txt
Batch The 5 files, the file name to uppercase:
$ rename ‘y/a-z/A-Z/‘ *.c
9. View Files
viewing files using the CAT,TAC and NL commands (where cat is a positive sequence display, TAC is displayed in reverse order)
For example, to view passwd files:
$ cat passwd
You can add the line number with the-N parameter:
$ cat -n passwd
Viewing files using the head and tail commands
$ tail /etc/passwd
See only one line:
$ tail -n 1 /etc/passwd
To view file types:
$ file /bin/ls
(v) Environment variables and file search
1. Create a variable
$ declare tmp
The variable TMP is assigned a value of Shiyanlou using the "=" Number assignment operator:
$ tmp=shiyanlou
Read the value of the variable, using the Echo command and the $ symbol:
$ echo $tmp
2. Environment variables
Create a Shell script file:
$ gedit hello_shell.sh
Add the following in the script to save and exit:
#!/bin/bashfor ((i=0; i<10; i++));do echo "hello shell"doneexit 0
To 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#include <stdio.h>int main(void){ printf("hello world!\n"); return 0;}
After saving, use GCC to generate the executable file:
$ gcc -o hello_world hello_world.c
Create a Mybin directory in the Shiyanlou home directory and move the above hello_shell.sh and Hello_world files to it:
$ mkdir mybin$ mv hello_shell.sh hello_world mybin/
You can now run the two programs you just created in the Mybin directory:
$ cd mybin$ ./hello_shell.sh$ ./hello_world
3. Variable deletion
$ unset temp
4. Search for files
Whereis Simple and fast:
$whereis who
Locate Fast and full:
$ locate /etc/sh
Find all JPG files under/usr/share/:
$ locate /usr/share/\*.jpg
Which small and fine:
$ which man
Find Fine and fine:
$ sudo find /etc/ -name interfaces
(vi) document packaging and compression
1, Zip compression packaging Program
To use the Zip Package folder:
$ zip -r -q -o shiyanlou.zip /home/shiyanlou$ du -h shiyanlou.zip$ file 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
Then use the DU command to see the default compression level, the lowest, the highest compression level, and the size of the uncompressed files, respectively:
$ du -h -d 0 *.zip ~ | sort
Create an encrypted ZIP package
Use the-e parameter to create an encrypted compressed package:
$ zip -r -e -o shiyanlou_encryption.zip /home/shiyanlou
2. Unzip the zip file using the unzip command
Unzip the shiyanlou.zip to the current directory:
$ unzip shiyanlou.zip
Use Quiet mode to extract the files to the specified directory:
$ unzip -q shiyanlou.zip -d ziptest
3. rar Package Compression command
Install RAR and Unrar tools:
$ sudo apt-get update$ sudo apt-get install rar unrar
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 .
To delete a file from the specified compressed package file:
$ rar d shiyanlou.rar .zshrc
To view the unresolved files:
$ rar l shiyanlou.rar
Extract RAR files using unrar full path decompression:
$ unrar x shiyanlou.rar
Remove Path Decompression:
$ mkdir tmp$ unrar e shiyanlou.rar tmp/
4. Tar Packaging tools
Create a tar package:
$ tar -cf shiyanlou.tar ~
Unpack a file (-x parameter) to the existing directory of the specified path (-c parameter):
$ mkdir tardir$ tar -xf shiyanlou.tar -C tardir
To view only the unresolved package file-T parameter:
$ tar -tf shiyanlou.tar
Keep file attributes and follow links:
$ tar -cphf etc.tar /etc
To create a file in a different compressed format:
Add the-z parameter to the build of the tar file and use gzip to compress the file:
$ tar -czf shiyanlou.tar.gz ~
Unzip the *.tar.gz file:
$ tar -xzf shiyanlou.tar.gz
- Summarize the zip command and tar command
* * Zip
Package: Zip something.zip Something (directory please add-r parameter)
Unpacking: Unzip Something.zip
Specify path:-d parameter
tar**
Package: TAR-ZCVF Something.tar Something
Unpacking: TAR-ZXVF Something.tar
Specify path:-C parameter
(vii) file system operations and Disk Management
1. Basic operation
DF command to view disk capacity
du command to view the directory's capacity
Plus- h parameter to display in an easier-to-read manner
$ du –h
The- d parameter specifies the depth of the view directory
2. Simple Disk Management
To create a virtual image file using the DD command
Convert to uppercase and write to file
Format a disk with the mkfs command
Use the Mount command to mount a disk to a directory tree
Uninstalling mounted disks using the umount command
Partitioning a disk using fdisk
Using the losetup command to establish an association between a mirror and a loopback device
(eight) help commands under Linux
1. Built-in command and external command
Use the type command to differentiate whether the command is built-in or external
$ type exit
Or
$ type service
2. Use of HELP commands
help command
The help command is used to display a brief helpful message for the shell built-in command. If it's an external command, there's basically a parameter -help
$ ls -- help
Man Command
The resulting content is more detailed than help, and man has no distinction between built-in and external commands.
Info Command
If you feel that the information displayed by man is not enough to meet the needs, try the Info command (most detailed)
Some small homework after class
20165327 preparatory work 3 Linux installation and learning