Sixth, use yum installed, uninstall packages
yum source is divided into: the local source, the network source
- Local sources are divided into: the source hard disk, CD-ROM source, using the file protocol;
- Network Source: use http, ftp protocol, network environment but need support
This example uses a local source (disc source), the network source not understand
1, modify the file repository yum, yum determine the source
- /etc/yum.repos.d yum repository file is located in the directory, file name suffix .repo
As follows:
- By default there are three files, you can remove the two, one can be retained.
- Use gedit editor warehouse file rhel-source.repo
- Warehouse document reads as follows:
Explained as follows:
[]: Define Warehouse, base my warehouse name can be arbitrary;
name: a short text description of the warehouse;
baseurl: warehouse location, file: // indicates the local path, / mnt local CD-ROM path, network path: http, ftp
enabled: whether to enable warehouse, 1 to enable, 0 to disable
gpgcheck: check whether GPG signatures (used to verify whether the installation package for the Red Hat official)
gpgkey: Specifies the keys GPG signature file storage path
2, hang up the Linux system CD
3, yum function test
Command: yum list (listed warehouse rpm package)
Similar to the following message appears, indicating that the normal function yum
4, the software installation package
Command: yum install package names
5, uninstall packages
Command: yum erase package names
6, automatically resolve dependencies problem
6.1> install software
6.2> Uninstall software
Seven, mount USB storage devices
1, Linux virtual machine using a USB storage device
1.1> Make sure the keyboard, mouse occupied by a virtual machine system (with a click of the mouse in the virtual machine system);
1.2> U disk insertion or removable disks;
插入U盘后,U盘只出现在物理机Windows系统中,而未进入Linux虚拟机,解决办法;
如下图所示:
执行该操作后,虚拟机Linux系统中会出现类似下面的提示:
…
Disk /dev/sdb: 131 MB, 131989504 bytes
16 heads, 32 sectors/track, 503 cylinders
Units = cylinders of 512 * 512 = 262144 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 503 128752 6 FAT16
…
如果看不到以上信息,可能是虚拟机版本问题,或是Linux系统不支持该U盘!
1.3> 使用“ fdisk -l ”命令也可以查看U盘的设备名
本例中的U盘设备名为:sdb,分区编号为1,具体情况以命令结果为准。
1.4> 使用 mount,umount 命令进行挂载、卸载U盘(和光盘的使用相同),如下所示:
- 挂掉U盘:
命令1:mount /dev/sdb1 /mnt
命令2:ls /mnt (可查看U盘中的文件或目录)
- 卸载 U 盘
命令:umount /mnt 或者 umount /dev/sdb1
2、Linux物理机中使用USB储存设备(从上面的第二步开始即可)
八、文件的归档、压缩操作
1、tar命令
常见选项:
-c:创建归档
-x:解归档
-v:显示过程
-f:指定文件名
-C:指定解归档的目录路径
-z:将打包文件压缩gzip格式
-j:将打包文件压缩bzip2格式
1.1> 归档:即打包,常用于备份某个重要的目录
(1)只归档不压缩:
命令:tar -cvf 创建的归档文件名及路径 要归档的目录
(2)即归档,又压缩(gzip、bzip2压缩格式)
- 命令:tar -czvf 创建的归档压缩文件名及路径 要归档的目录
- 命令:tar -cjvf 创建的归档压缩文件名及路径 要归档的目录
1.2> 解归档
- 解归档到源路径
命令:tar -xvf 归档文件名及路径
- 解归档到指定路径:
命令:tar -xvf 归档文件名及路径 -C 指定解归档的目录路径
- 解压缩、解归档
(1) 解压缩、解归档到源路径
- 命令1:tar -xzvf 归档压缩文件名及路径
例如:tar -xzvf /backup/root.tar.gz- 命令2:tar -xjvf 归档压缩文件名及路径
例如:tar -xjvf /backup/root.tar.gz
(2)解压缩、解归档到指定路径
- 命令1:tar -xzvf 归档压缩文件名及路径 -C 指定解归档的目录路径
例如:tar -xzvf /backup/root.tar.gz -C /backup- 命令2:tar -xjvf 归档压缩文件名及路径 -C 指定解归档的目录路径
例如:tar -xjvf /backup/root.tar.bz2 -C /backup2
2、gzip、bzip命令
常见选项:
-d:解压
2.1>解压
- gizip
- bzip
2.2> 解压缩
- gzip
- bzip
九、用户和组
相关概念:
- 运行程序需要一定的用户身份,且具有一定的操作权限;
- 用户也可以加入到某个组中以继承组的权限;
- Linux系统中有私有组和附加组之分;
- 私有组是用户自己的组,该组不需单独建立,在创建用户时由系统自动创建,私有组的组名与用户相同。
- 附加组是私有组以外的其他组,用户可隶属于多个不同的附加组,具有多个组的权限;
- 每一个不同的用户和组都有一个唯一的名称(用户名、组名)
- 用户和组分别存放在 /etc/目录下的passwd和group文件中。
1、创建用户和组
1.1>创建用户(useradd)
- 不指定附加组:
命令:useradd 新用户名
例如:useradd zhangsan
- 指定附加组
命令:useradd -G 附加组组名 新用户名
-G:指定用户所属的附加组(改组必须存在)
例如:创建用户 test1,并将其加入到student组中
1.2> 创建组(groupadd)
命令:groupadd 新组名
例如:groupadd admin
1.3>设置用户的登录密码
设置密码时,屏幕上将不显示任何信息(连星号 * 也没有)
命令:passwd 用户名
2、删除用户和组
2.1> 删除用户(userdel)
- 只删除用户,不删除宿主目录
命令:userdel 用户名
- 用户和宿主目录同时删除
命令:userdel -r 用户名
-r:删除宿主目录
2.2> 删除组(groupdel)
命令:groupdel 组名
例如:groupdel admin
3、用户和组权限
文件和目录的权限问题请参考:(四、文件和目录操作中[ls -l])
3.1> change the file, directory permissions: chmod
- ugo operation
Command: chmod ugo ± file permissions you want to change or directory path
u: user that is the owner of the file directory ( the owner of the rights )
G: group that is attached to the file directory group ( group permissions )
O: other users ( other user rights )
For example: test1 user logged into the system, created in the home directory test.txt file, the owner of the file as test1, test1 membership group but also for (private group)
As follows:
- Octal operation
- 4:r
- 2:w
- 1:x
- 0: No permission
For example: 660 ugo order and sequence identical meanings, namely: owner permissions 6 (rw), group permissions 6 (rw), other permissions to 0 (no permissions)
3.2> change the file, directory owner: chown
- Change only the owner
Command: chown username file or directory path
- Only change group membership
Command: chown: group name the file or directory path
- At the same time change the owner and group membership
Command: chown user name: Group name file or directory path
- -R option: You can recursively change owner of the directory tree or group membership
Command: chown -R username: group name directory name
For example: chown -R & lt test1: test1 / Pub
Pub directory and its subdirectories owner and membership of the group are replaced by the root private test1 test1 users and groups;