linux foundation Exercise 2

1, description of the structure and the directory structure linux directory naming convention

   linux directory structure / the total root directory. Down into secondary directory of all files and directories are in the root directory of this total

    With the ls command to view the directories and files in linux, the specific parameters refer to man ls or ls - help viewing options


The secondary directory linux

Command / bin directory binary (binary) files, this directory is stored in the system binary files and executable binaries

/ Boot startup file directory. Will import / boot directory of files stored inside the computer to boot the system after system boot files are mostly start

Abbreviation / dev device (apparatus) stored hardware devices such as hard disk directory / dev / sda, u disk hardware devices such as an optical disk information

The system file / etc linux file system in the storage position, equivalent to the windows registry

/ Home directory in the user's home directory linux home

lib lib64 Linux common library package lib for the storage location 32

/ Media / mnt two directories used as a point to mount the hard disk and u

/ Proc file directory information storage memory

Binary command / sbin system administrator using / bin sbin as a soft link pointing to / sbin

/ Tmp file for storing the common

/ Var directory to store system information and error logs

Generated when / run linux operating system file location

/ Usr directory location of the system software to install the software

/ Opt is done by the system and you need to install other software applications

 

2, display / etc directory, all ending in .d file or directory

 

ls -d /etc/*.d ls -d parameter to select the directory plus if not default into subdirectories

 


Under View / etc / directory ending in .d files

3, the display / etc directory, all .conf end, and with m, n, r, p, at the beginning of the file or directory

ls -d /etc/[mnrp]*.conf

SUMMARY parentheses or brackets represent the relationship keep wildcard matching of alphanumeric symbols plus -d


End .conf, and with m, n, r, p, at the beginning of the file or directory

4, create / app / rootdir directory, and copy / root to all files within that directory, preserving permits required

The first step is to create a directory mkdir -p / app / rootdir with -p parameter to create a subdirectory of the parent directory is not created empty folder

 

The second part with the cp command to copy / root all the files to the directory cp -a recursively copy protection and leave property

 


 

5, to expand the function using the command line, create / tmp / a1, / tmp / a2, / tmp / a1 / a, / tmp / a1 / b, create a directory in / tmp: x_y, x_z, q_y, q_z

mkdir -p /tmp/{a1/{a,b},a2}/         dirk -p /tmp/{x/{y,z},q/{y,z}}

 


Renderings

6, summed user, user group management command and demonstrate command and common usage

User Group 4 profiles. The password information of the user information / etc / passwd password information / etc / gshadow group information / etc / group / group / etc / gshadow editing command can vim cat nano, may also be used groupmems

useradd Adds a user usermod modify user information userdel to delete user information, three belong to the user group information management commands groupadd to add groupmod modify group information management for the group groupdel

useradd -u create a user and assign uid -g specified group ID 


Example 1

usermod modify user information -G increase affiliated group affiliated group delete modify -p password


Examples

 


 

userdel -r user to delete a user -r option to remove the user's home directory and mail

 

New group groupadd -g specified group id -p password specified group 

 


 

 

 

gpasswd can be used to add and delete user groups within


 

 


 

 

7, file permissions, owner, is a set of management commands what, and demonstrates the use of command and

Check the directory and file permissions with ls -l

 


Check inside the home directory file permissions

chown change file owner

 


Create a file

 


Modify user and group files

 


Modify the directory owner and user group information

chgrp Change file user group

 


Modify files User Group

chmod modify file permissions

 


Modify file permissions

 


修改目录权限为最大

suid 数字代表为4,让用户临时拥有文件所属主权限,但只针对二进制程序有效。

 


 

正常普通用户不能用cat打开passwd文件 授予suid权限之后用户有了cat所属用户root权限,可执行cat命令打开并修改passwd文件

sgid sgid让用户临时拥有文件用户组权限,只针对二进制文件,如果对目录设置文件将在目录创建文件时文件所属组都属于

 


 

新建组之后将目录所属组赋予给filegrp在给文件加上sgid权限之后新建文件的所属组便自动会继承所属目录的组。

sticky权限用于目录只能删除自己的文件,需要配合sgid权限使用

 


 

 


 

 

设置好权限之后切换另一个用户创建文件,之后再切换用户,要删除其他用户文件时会提示不能删除

当然这些权限对root无效

chttr 添加隐藏权限可以用于保护文件不被删除 用 +i 参数可以让文件不被删除修改和更新  +a 参数只能追加不能有其他动作


 

 


 

 


 

不能覆盖,删除,只能追加  

普通ls名不能查看文件隐藏权限,要用lsttr 命令查看文件特殊权限,随后可用chattr -ia 取消文件的特殊权限

ACL访问控制表,用于传统权限之外的文件控制权限

设置命令 setfacl  设置格式 setfacl -m u:用户:rwx /文件 getfacl 文件 查看文件中的acl权限

实例,创建文件并给文件授予777最大权限。


 

创建用户并限制用户权限为r可读

 


可以读。但不是能删除,修改

 


查看文件的acl权限

实例 新建目录并对目录中新建文件全部赋予acl权限

setfacl -R -m d:u:zxf:r 目录 ,将目录中所有新创建的文件对特殊用户赋予只读权限


删除acl特殊权限

 


针对单独用户删除权限

也可用 -b 选项清空文件所有针对acl设置的权限

8、创建用户gentoo,附加组为bin和root,默认shell为/bin/csh,注释信息为 "Gentoo Distribution"

useradd -G bin,root gentoo ,usermod-s /bin/csh usermod -c "Gentoo Distribution" gentoo


 

 

 


 

 


 

初学linux的菜鸟,文笔和思路都不是很好,欢迎大家指正不对之处。

 

Guess you like

Origin www.cnblogs.com/woaiyitiaochai/p/11757911.html