/etc/skel目录
Linux中的/etc/skel目录(skel是skeleton的缩写,意为骨骼、框架。)是用来存放新用户配置文件的目录,当我们添加新用户时,这个目录下的所有文件会自动被复制到新添加的用户的家目录下;默认情况下,/etc/skel目录下的所有文件都是隐藏文件(以.点开头的文件);通过修改、添加、删除/etc/skel目录下的文件,我们可为新创建的用户提供统一、标准的、初始化用户环境。
演示:让每个新用户都可以看到hi.txt的文档
[root@w ~]# ll /etc/skel/ -al 查看/etc/skel/下的文件
total 20
drwxr-xr-x. 2 root root 4096 Feb 23 14:39 .
drwxr-xr-x. 59 root root 4096 Apr 19 12:03 ..
-rw-r--r--. 1 root root 18 Jul 18 2013 .bash_logout
-rw-r--r--. 1 root root 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 root root 124 Jul 18 2013 .bashrc
[root@w ~]# cd /etc/skel/
[root@w skel]# ll 默认查看都是隐藏的
total 0
[root@w skel]# vi hi.txt 创建一个hi.txt的文件,写入hello
hello
[root@w skel]# ll
total 4
-rw-r--r--. 1 root root 6 Apr 21 11:22 hi.txt
[root@w skel]# useradd test1 新建test1的用户
[root@w skel]# ll /home/test1/ -al 查看test1的家目录
total 24
drwx------. 2 test1 test1 4096 Apr 21 11:23 .
drwxr-xr-x. 5 root root 4096 Apr 21 11:23 ..
-rw-r--r--. 1 test1 test1 18 Jul 18 2013 .bash_logout
-rw-r--r--. 1 test1 test1 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 test1 test1 124 Jul 18 2013 .bashrc
-rw-r--r--. 1 test1 test1 6 Apr 21 11:22 hi.txt 看到刚才创建的hi.txt文件
[root@w skel]# cat /home/test1/hi.txt 可以看到里面的hello内容
hello
模拟删除test1用户/etc/skel/目录下的文件后的恢复
删除:/etc/skel/下的文件
[root@w skel]# su - test1
[test1@w ~]$ ls -al
total 24
drwx------. 2 test1 test1 4096 Apr 21 11:23 .
drwxr-xr-x. 5 root root 4096 Apr 21 11:23 ..
-rw-r--r--. 1 test1 test1 18 Jul 18 2013 .bash_logout
-rw-r--r--. 1 test1 test1 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 test1 test1 124 Jul 18 2013 .bashrc
-rw-r--r--. 1 test1 test1 6 Apr 21 11:22 hi.txt
[test1@w ~]$ rm -f * 直接删除不管用
[test1@w ~]$ ls -al 文件还在
total 20
drwx------. 2 test1 test1 4096 Apr 21 11:51 .
drwxr-xr-x. 5 root root 4096 Apr 21 11:23 ..
-rw-r--r--. 1 test1 test1 18 Jul 18 2013 .bash_logout
-rw-r--r--. 1 test1 test1 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 test1 test1 124 Jul 18 2013 .bashrc
[test1@w ~]$ rm -f .* 删除以.开头的文件
rm: cannot remove `.‘: Is a directory
rm: cannot remove `..‘: Is a directory
[test1@w ~]$ ls -al .bash等文件已删除
total 8
drwx------. 2 test1 test1 4096 Apr 21 11:52 .
drwxr-xr-x. 5 root root 4096 Apr 21 11:23 ..
[test1@w ~]$ su - test1 切换到test1用户
Password:
-bash-4.1$ 出现这种是因为/etc/skel/下的文件没了
-bash-4.1$
-bash-4.1$ logout 恢复/etc/skel/文件
[root@w ~]# cd /etc/skel/ 切换到root,打开/etc/skel/目录
[root@w skel]# ls -al
total 24
drwxr-xr-x. 2 root root 4096 Apr 21 11:22 .
drwxr-xr-x. 59 root root 4096 Apr 21 11:50 ..
-rw-r--r--. 1 root root 18 Jul 18 2013 .bash_logout
-rw-r--r--. 1 root root 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 root root 124 Jul 18 2013 .bashrc
-rw-r--r--. 1 root root 6 Apr 21 11:22 hi.txt
[root@w skel]# cp -a .bash* /home/test1/ 把所有.bash的文件复制到test1的家目录
[root@w skel]# ll /home/test1/ -al 查看文件已存在
total 20
drwx------. 2 test1 test1 4096 Apr 21 11:59 .
drwxr-xr-x. 5 root root 4096 Apr 21 11:23 ..
-rw-r--r--. 1 root root 18 Jul 18 2013 .bash_logout 权限只属于root
-rw-r--r--. 1 root root 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 root root 124 Jul 18 2013 .bashrc
[root@w skel]# chown -R test1 /home/test1/ 赋于test1用户权限,不赋权不能使用
[root@w skel]# ll /home/test1/ -al
total 20
drwx------. 2 test1 test1 4096 Apr 21 11:59 .
drwxr-xr-x. 5 root root 4096 Apr 21 11:23 ..
-rw-r--r--. 1 test1 root 18 Jul 18 2013 .bash_logout 权限赋给test1了
-rw-r--r--. 1 test1 root 176 Jul 18 2013 .bash_profile
-rw-r--r--. 1 test1 root 124 Jul 18 2013 .bashrc
[root@w skel]# su - test1 切换到test1用户,已经可以了
[test1@w ~]$
[test1@w ~]$
/etc/skel目录的更多相关文章
- etc/skel目录介绍
/etc/skel目录的作用: /etc/skel目录是用来存放新用户配置文件的目录,当我们添加新用户时,这个目录下的所有文件会自动被复制到新添加的用户家目录下,默认情况下,/etc/skel 目录下 ...
- /etc/skel 目录作用
/etc/skel包含的文件和目录会被自动复制到一个新用户的家目录(当使用 useradd 程序创建用户时)./etc/skel允许系统管理员给所有的新用户创建一个默认的家目录,这样所有的新用户都有一 ...
- Linux用户管理重要初始化目录skel案例讲解
1. /etc/skel 目录 /etc/skel 的场景作用
- 转://Linux下误删除/home目录的恢复方法
一般情况下,我们在安装Oracle数据库的时候,都会创建一个Oracle用户,用该用户来安装和管理Oracle.Oracle用户的根目录就是/home/oracle. 通常安装Oracle数据库是按照 ...
- Linux 系统的/etc目录
/etc目录下的重要文件 /etc/sysconfig/network 指定服务器上的网络配置信息 /etc/rc.d/init.d/network 网络配置脚本信息 网络配置脚本,开机通过脚本文件来 ...
- 用户(user)和用户组(group)相关的配置文件、命令或目录;
1.与用户(user)和用户组(group)相关的配置文件: 1)与用户(user)相关的配置文件:/etc/passwd 注:用户(user)的配置文件:/etc/shadow 注:用户(user) ...
- skeleton directory: /etc/skel
第一次接触这个词汇 还是在LFS8.2里面,感觉有点吓人.好好一个计算机操作系统,怎么搞出这个恐怖的术语.... 当使用useradd 或者其他命令创建用户的时候,/etc/skel这个目录下的文件. ...
- Linux基础介绍【第七篇】
linux用户分类 超级用户:UID=0,root 普通用户:UID 500起,由超级用户或具有超级用户权限的用户创建的用户. 虚拟用户:UID 1-499,为了满足文件或服务启动的需要而存在,一般都 ...
- Linux系统用户和用户组介绍
1.请问如下登录环境故障的原理及解决办法? [root@server test]# useradd rr ##创建用户rr [root@server test]# id rr uid=510(rr) ...
随机推荐
- 一个标准sql语句模板
select distinct top n * from t1 inner join t2 on ... join t3 on ... where ... group by ... having .. ...
- fastadmin CMS等系列插件安装不成功的问题
由于fastadmin开发者 没有做到权限优化问题,导致用户在linux服务器上lnmp环境下安装的fastadmin后台安装插件一直产生权限不足,安装不成功的问题, 再次给大家一个具体解决办法 对 ...
- Asp.Net构架(Http请求处理流程)
一:引言 我查阅过不少Asp.Net的书籍,发现大多数作者都是站在一个比较高的层次上讲解Asp.Net.他们耐心.细致地告诉你如何一步步拖放控件.设置控件属性.编写CodeBehind代码,以实现某个 ...
- elastalert docker安装
基于对elasticsearch中数据监控需要,我尝试了sentinl和elastalert两款工具.虽然elastalert是纯文本,但易配置管理.elk自带的watch需要付费才可使用. 6.2x ...
- 十六、python面向对象基础篇
面向对象基础: 在了解面向对象之前,先了解下变成范式: 编程范式是一类典型的编程风格,是一种方法学 编程范式决定了程序员对程序执行的看法 oop中,程序是一系列对象的相互作用 python支持多种编程 ...
- UE4 Keynote 1
[UE4 Keynote 1] 1.U3D中的Project,在UE4中叫 ContentBrowser,中文名叫“内容浏览器” 最多可以打开4个ContentBrowser,通过 “窗口” -> ...
- 单文件WebUploader做大文件的分块和断点续传
前言: WebUploader是由Baidu WebFE(FEX)团队开发的一个简单的以HTML5为主,FLASH为辅的现代文件上传组件.在现代的浏览器里面能充分发挥HTML5的优势,同时又不摒弃主流 ...
- LCD编程框架组织
看下面的代码,你会发现韦老师这种组织与内核框架的组织是一脉相承的. led.c #define LCD_NUM 10 static p_lcd_params p_array_lcd[LCD_NUM]; ...
- MySQL 的各种 join
table th:first-of-type { width: 200px; } join 类型 备注 left [outer] join right [outer] join union [all ...
- ubuntu配置定时任务crontab何保存退出
crontab -e配置完成后,如何把保存并退出? 1.Ctrl+o 写入 2.出现“FIile name to Write...”,输入Enter 3.Ctrl+x 保存输出 提示“crontab: ...