/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) ...
随机推荐
- ECharts将折线变平滑和去掉点的属性(转载)曲线变圆滑
本文链接:https://blog.csdn.net/sinat_36422236/article/details/62430114 series : [ { name:'your name', sy ...
- 在知识爆炸的年代如何学习,避免成为PPT架构师
计算机的发展大体遵循摩尔定律,IT要学的东西越来越多,感觉无从下手 然后发现许多人,专门喜欢说这些名词概念装高大上,脱离一线开发,技术跟风盲目崇拜新的骚东西,比如docker,k8s,微服务,open ...
- python的multitask模块安装
今天参考网络上的例子,编写基于python的网络程序,遇到下面的错误. No module named 'multitask' 但是multitask的模块却始终下载不了,在网上找到的CSDN下载链接 ...
- 汉诺塔问题深度剖析(python实现)
当我们学习一门编程语言的时候,都会遇到递归函数这个问题.而学习递归的一个经典案例就是汉诺塔问题.通过这篇文章,观察移动三个盘子和四个盘子的详细过程,您不仅可以深刻的了解递归,也更加熟悉了汉诺塔的游戏的 ...
- qt 断点无效
点击 工具 -->选项-->构建套件-->手动设置项,选择正确的编译器和调试器.
- 怎么认Destsoon标签条件
看准一个标签认条件 如: <!--{php $tags=tag("moduleid=18&table=club_group_18&condition=status=3 ...
- 记录一次群答问:requests获取cookie
问题: 为了测试,写的sever,下面仅为set cookie的部分代码 response = make_response('{"code":9420, "msg&quo ...
- 常用dos命令(2)
文件管理 type 显示文本文件的内容. copy 将一份或多份文件复制到另一个位置. del 删除一个或数个文件. move 移动文件并重命名文件和目录.(Windows XP Home Editi ...
- mysql where/having
select * from t1 where id<5;select * from t1 where id<5; where 从t1中筛选内容 而having从*中筛选内容
- dijkstra算法的堆优化
普通的dijkstra算法模板: //数据结构 int g[LEN][LEN]; //邻接矩阵 int vis[LEN]; //标记是否访问 int dist[LEN] //源点到各点的距离 fill ...