尚硅谷linux

目录

目录树

安装vmTools命令行

搜索和查询类

压缩和解压

gzip和gunzip

zip和unzip 

tar

组管理和权限管理


目录树

 

安装vmTools命令行

cd /opt/    显示文件夹
ll            显示文件
tar -zxvf    解压安装文件包
ll        显示文件
cd 进入文件夹
./        进入安装脚本
完成后需要
reboot    重启系统


可能出现的问题

mounting hgfs share显示失败

解决方法

在linux中Mounting HGFS shares: [失败]解决方案_lsssss_的博客-CSDN博客

用户管理命令行

Xshell 6 (Build 0095)
Copyright (c) 2002 NetSarang Computer, Inc. All rights reserved.

Type `help' to learn how to use Xshell prompt.
[D:\~]$ 

Connecting to 192.168.32.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(xm) at 15:46:27.

Type `help' to learn how to use Xshell prompt.
[D:\~]$ 

Connecting to 192.168.32.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Mon Jul 11 09:40:09 2022 from 192.168.32.1
[root@hadoop1 ~]# ll
总用量 100
-rw-------. 1 root root  1247 7月   9 19:01 anaconda-ks.cfg
-rw-r--r--. 1 root root    57 7月  11 10:43 Hello.java
-rw-r--r--. 1 root root 41954 7月   9 19:01 install.log
-rw-r--r--. 1 root root  9154 7月   9 18:59 install.log.syslog
drwxr-xr-x. 2 root root  4096 7月   9 11:53 公共的
drwxr-xr-x. 2 root root  4096 7月   9 11:53 模板
drwxr-xr-x. 2 root root  4096 7月   9 11:53 视频
drwxr-xr-x. 2 root root  4096 7月   9 11:53 图片
drwxr-xr-x. 2 root root  4096 7月   9 11:53 文档
drwxr-xr-x. 2 root root  4096 7月   9 11:53 下载
drwxr-xr-x. 2 root root  4096 7月   9 11:53 音乐
drwxr-xr-x. 2 root root  4096 7月   9 17:41 桌面
[root@hadoop1 ~]# cd /home
[root@hadoop1 home]# ll
总用量 8
drwx------. 4 xh xh 4096 7月  11 15:42 dog
drwx------. 4 xm xm 4096 7月  11 15:41 xm
[root@hadoop1 home]# passwd xm
更改用户 xm 的密码 。
新的 密码:
无效的密码: 过于简单化/系统化
重新输入新的 密码:
抱歉,密码不匹配。
新的 密码:
无效的密码: WAY 过短
无效的密码: 是回文
重新输入新的 密码:
抱歉,密码不匹配。
新的 密码:
无效的密码: 它没有包含足够的不同字符
无效的密码: 过于简单
重新输入新的 密码:
抱歉,密码不匹配。

passwd: 已经超出服务重试的最多次数
[root@hadoop1 home]# 
[root@hadoop1 home]# userdel -r xm
[root@hadoop1 home]# ll
总用量 4
drwx------. 4 xh xh 4096 7月  11 15:42 dog
[root@hadoop1 home]# userdel -r xh
[root@hadoop1 home]# ll
总用量 0
[root@hadoop1 home]# useradd xm
[root@hadoop1 home]# ll
总用量 4
drwx------. 4 xm xm 4096 7月  11 15:49 xm
[root@hadoop1 home]# passwd xm
更改用户 xm 的密码 。
新的 密码:
无效的密码: 过于简单化/系统化
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[root@hadoop1 home]# pwd xm
/home
[root@hadoop1 home]# useradd -d /home/dog xh
[root@hadoop1 home]# ll
总用量 8
drwx------. 4 xh xh 4096 7月  11 15:50 dog
drwx------. 4 xm xm 4096 7月  11 15:49 xm
[root@hadoop1 home]# pwd xh
/home
[root@hadoop1 home]# passwd xh
更改用户 xh 的密码 。
新的 密码:
无效的密码: 过于简单化/系统化
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[root@hadoop1 home]# userdel xm
[root@hadoop1 home]# ll
总用量 8
drwx------. 4 xh  xh  4096 7月  11 15:50 dog
drwx------. 4 500 500 4096 7月  11 15:52 xm
[root@hadoop1 home]# user -r xh
-bash: user: command not found
[root@hadoop1 home]# user -r xh
-bash: user: command not found
[root@hadoop1 home]# user -r xm
-bash: user: command not found
[root@hadoop1 home]# ll
总用量 8
drwx------. 4 xh  xh  4096 7月  11 15:50 dog
drwx------. 4 500 500 4096 7月  11 15:52 xm
[root@hadoop1 home]# userdel -r xh
[root@hadoop1 home]# ll
总用量 4
drwx------. 4 500 500 4096 7月  11 15:52 xm
[root@hadoop1 home]# userdel -r xm
userdel:用户“xm”不存在
[root@hadoop1 home]# whoami
root
[root@hadoop1 home]# useradd zf
[root@hadoop1 home]# passwd zf
更改用户 zf 的密码 。
新的 密码:
无效的密码: 过于简单化/系统化
重新输入新的 密码:
passwd: 所有的身份验证令牌已经成功更新。
[root@hadoop1 home]# id zf
uid=500(zf) gid=500(zf) 组=500(zf)
[root@hadoop1 home]# id root
uid=0(root) gid=0(root) 组=0(root)
[root@hadoop1 home]# su - zf
[zf@hadoop1 ~]$ exit
logout
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# clean
-bash: clean: command not found
[root@hadoop1 home]# ^C
[root@hadoop1 home]# ^C
[root@hadoop1 home]# clear
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# cd /home
[root@hadoop1 home]# ll
总用量 8
drwx------. 4 zf zf 4096 7月  11 15:52 xm
drwx------. 4 zf zf 4096 7月  11 16:08 zf
[root@hadoop1 home]# su -zf
su:无效选项 -- z
请尝试执行"su --help"来获取更多信息。
[root@hadoop1 home]# su - zf
[zf@hadoop1 ~]$ exit
logout
[root@hadoop1 home]# whoami
root
[root@hadoop1 home]# id zf
uid=500(zf) gid=500(zf) 组=500(zf)
[root@hadoop1 home]# id xm
id: xm:无此用户
[root@hadoop1 home]# groupadd sanguo
[root@hadoop1 home]# useradd -g sanguo liubei
[root@hadoop1 home]# id liubei
uid=501(liubei) gid=501(sanguo) 组=501(sanguo)
[root@hadoop1 home]# ll
总用量 12
drwx------. 4 liubei sanguo 4096 7月  11 20:17 liubei
drwx------. 4 zf     zf     4096 7月  11 15:52 xm
drwx------. 4 zf     zf     4096 7月  11 16:08 zf
[root@hadoop1 home]# usermod -g sanguo zf
[root@hadoop1 home]# id zf
uid=500(zf) gid=501(sanguo) 组=501(sanguo)
[root@hadoop1 home]# usermod -g zf zf
[root@hadoop1 home]# id zf
uid=500(zf) gid=500(zf) 组=500(zf)
[root@hadoop1 home]# groupadd shuihu
[root@hadoop1 home]# useradd -g shuihu songjiang
[root@hadoop1 home]# ll
总用量 16
drwx------. 4 liubei    sanguo 4096 7月  11 20:17 liubei
drwx------. 4 songjiang shuihu 4096 7月  11 20:20 songjiang
drwx------. 4 zf        zf     4096 7月  11 15:52 xm
drwx------. 4 zf        zf     4096 7月  11 16:08 zf
[root@hadoop1 home]# id songjiang
uid=502(songjiang) gid=502(shuihu) 组=502(shuihu)
[root@hadoop1 home]# groupdel shuihu
groupdel:不能移除用户“songjiang”的主组
[root@hadoop1 home]# userdel -r songjiang
[root@hadoop1 home]# ll
总用量 12
drwx------. 4 liubei sanguo 4096 7月  11 20:17 liubei
drwx------. 4 zf     zf     4096 7月  11 15:52 xm
drwx------. 4 zf     zf     4096 7月  11 16:08 zf
[root@hadoop1 home]# groupdel shuihu
[root@hadoop1 home]# pwd zf
/home
[root@hadoop1 home]# ll
总用量 12
drwx------. 4 liubei sanguo 4096 7月  11 20:17 liubei
drwx------. 4 zf     zf     4096 7月  11 15:52 xm
drwx------. 4 zf     zf     4096 7月  11 16:08 zf
[root@hadoop1 home]# pwd liubei
/home
[root@hadoop1 home]# cd /
[root@hadoop1 /]# ll
总用量 98
dr-xr-xr-x.   2 root root  4096 7月   9 12:33 bin
dr-xr-xr-x.   5 root root  1024 7月   9 19:38 boot
drwxr-xr-x.  19 root root  3800 7月  11 09:37 dev
drwxr-xr-x. 105 root root 12288 7月  11 20:21 etc
drwxr-xr-x.   5 root root  4096 7月  11 20:20 home
dr-xr-xr-x.  13 root root  4096 7月   9 12:33 lib
dr-xr-xr-x.   9 root root 12288 7月   9 12:33 lib64
drwx------.   2 root root 16384 7月   9 18:51 lost+found
drwxr-xr-x.   3 root root  4096 7月  11 09:38 media
drwxr-xr-x.   3 root root  4096 7月   9 17:30 mnt
drwxr-xr-x.   4 root root  4096 7月   9 16:50 opt
dr-xr-xr-x. 220 root root     0 7月  11 09:37 proc
dr-xr-x---.  27 root root  4096 7月  11 16:07 root
dr-xr-xr-x.   2 root root 12288 7月   9 17:29 sbin
drwxr-xr-x.   7 root root     0 7月  11 09:37 selinux
drwxr-xr-x.   2 root root  4096 9月  23 2011 srv
drwxr-xr-x   13 root root     0 7月  11 09:37 sys
drwxrwxrwt.  25 root root  4096 7月  11 10:27 tmp
drwxr-xr-x.  13 root root  4096 7月   9 18:56 usr
drwxr-xr-x.  22 root root  4096 7月   9 18:59 var
[root@hadoop1 /]# clea
-bash: clea: command not found
[root@hadoop1 /]# clear
[root@hadoop1 /]# 
[root@hadoop1 /]# 
[root@hadoop1 /]# 
[root@hadoop1 /]# 
[root@hadoop1 /]# 
[root@hadoop1 /]# vim /etc/passwd
[root@hadoop1 /]# useradd -g shuihu songjiang
useradd:“shuihu”组不存在
[root@hadoop1 /]# usermod -g shuihu sonngjiang
usermod:“shuihu”组不存在
[root@hadoop1 /]# groupadd shuihu
[root@hadoop1 /]# usermod -g shuihu sonngjiang
usermod:用户“sonngjiang”不存在
[root@hadoop1 /]# useradd -g shuihu songjiang
[root@hadoop1 /]# ll
总用量 98
dr-xr-xr-x.   2 root root  4096 7月   9 12:33 bin
dr-xr-xr-x.   5 root root  1024 7月   9 19:38 boot
drwxr-xr-x.  19 root root  3800 7月  11 09:37 dev
drwxr-xr-x. 105 root root 12288 7月  11 20:26 etc
drwxr-xr-x.   6 root root  4096 7月  11 20:26 home
dr-xr-xr-x.  13 root root  4096 7月   9 12:33 lib
dr-xr-xr-x.   9 root root 12288 7月   9 12:33 lib64
drwx------.   2 root root 16384 7月   9 18:51 lost+found
drwxr-xr-x.   3 root root  4096 7月  11 09:38 media
drwxr-xr-x.   3 root root  4096 7月   9 17:30 mnt
drwxr-xr-x.   4 root root  4096 7月   9 16:50 opt
dr-xr-xr-x. 220 root root     0 7月  11 09:37 proc
dr-xr-x---.  27 root root  4096 7月  11 20:24 root
dr-xr-xr-x.   2 root root 12288 7月   9 17:29 sbin
drwxr-xr-x.   7 root root     0 7月  11 09:37 selinux
drwxr-xr-x.   2 root root  4096 9月  23 2011 srv
drwxr-xr-x   13 root root     0 7月  11 09:37 sys
drwxrwxrwt.  25 root root  4096 7月  11 10:27 tmp
drwxr-xr-x.  13 root root  4096 7月   9 18:56 usr
drwxr-xr-x.  22 root root  4096 7月   9 18:59 var
[root@hadoop1 /]# cd /home
[root@hadoop1 home]# ll
总用量 16
drwx------. 4 liubei    sanguo 4096 7月  11 20:17 liubei
drwx------. 4 songjiang shuihu 4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf     4096 7月  11 15:52 xm
drwx------. 4 zf        zf     4096 7月  11 16:08 zf
[root@hadoop1 home]# vim /etc/passwd
[root@hadoop1 home]# vim /etc/shadow
[root@hadoop1 home]# id zf
uid=500(zf) gid=500(zf) 组=500(zf)
[root@hadoop1 home]# vim /etc/group
[root@hadoop1 home]# 

文件管理 

删除目录:

mkdir
rmdir
删除非空文件
rm -rf 目录名

搜索和查询类

[root@hadoop1 ~]# whoami
root
[root@hadoop1 ~]# find /home  -name hello,txt
[root@hadoop1 ~]# find /home  -name hello.txt
[root@hadoop1 ~]# cd /home
[root@hadoop1 home]# ll
总用量 24
drwx------. 4 liubei    sanguo 4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root     18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root    366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root    772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu 4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf     4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root    613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root     18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# find /home -name ok3.txt
/home/ok3.txt
[root@hadoop1 home]# find /home -user root
/home
/home/ok3.txt
/home/龙符.txt
/home/zhuge.txt
/home/liubei/ok1.txt
/home/zf/ok1.txt
/home/zf/ok2.txt
/home/ok3.txt~
/home/long
[root@hadoop1 home]# find /size 20M
find: “/size”: 没有那个文件或目录
find: “20M”: 没有那个文件或目录
[root@hadoop1 home]# find / -size 20M
/usr/share/anthy/anthy.dic
/media/CentOS_6.8_Final/Packages/foomatic-db-ppds-4.0-7.20091126.el6.noarch.rpm
/media/CentOS_6.8_Final/Packages/oxygen-icon-theme-4.3.4-2.el6.noarch.rpm
find: “/proc/3352/task/3352/fd/5”: 没有那个文件或目录
find: “/proc/3352/task/3352/fdinfo/5”: 没有那个文件或目录
find: “/proc/3352/fd/5”: 没有那个文件或目录
find: “/proc/3352/fdinfo/5”: 没有那个文件或目录
[root@hadoop1 home]# clear
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 
[root@hadoop1 home]# 使用通配符
-bash: 使用通配符: command not found
[root@hadoop1 home]# find / -name *.txt
find: 路径必须在表达式之前: zhuge.txt
用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@hadoop1 home]# find / -name *.txt
find: 路径必须在表达式之前: zhuge.txt
用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@hadoop1 home]# find /home -name *。txt
[root@hadoop1 home]# find /home -name *.txt
find: 路径必须在表达式之前: zhuge.txt
用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@hadoop1 home]# find /home -name "*.txt
> 
> ^C
[root@hadoop1 home]# find /home -name *.txt

find: 路径必须在表达式之前: zhuge.txt
用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
[root@hadoop1 home]# find /home -name \*.txt
/home/ok3.txt
/home/龙符.txt
/home/zhuge.txt
/home/liubei/ok1.txt
/home/zf/ok1.txt
/home/zf/ok2.txt
[root@hadoop1 home]# update lacatedb
-bash: update: command not found
[root@hadoop1 home]# updatedb
[root@hadoop1 home]# lacate ok3.txt
-bash: lacate: command not found
[root@hadoop1 home]# updatedb
[root@hadoop1 home]# locate ok3.txt
/home/ok3.txt
/home/ok3.txt~
[root@hadoop1 home]# cat ok3.txt
总用量 20
drwx------. 4 liubei    sanguo 4096 7月  12 16:18 liubei
-rw-r--r--. 1 root      root      0 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root    772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu 4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf     4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root    613 7月  12 16:37 zhuge.txt
[root@hadoop1 home]# vim hello.txt
[root@hadoop1 home]# cat hello.txt 
今天是有小雨
今天不宜出们
今天估计要下雨好长时间
yes
come
go
white
black

[root@hadoop1 home]# cat hello.txt | grep -n yes
4:yes
[root@hadoop1 home]# vim hello.txt 
[root@hadoop1 home]# cat hello.txt 
今天是有小雨
今天不宜出们
今天估计要下雨好长时间
yes
come
go
white
black
YES
[root@hadoop1 home]# cat hello.txt | grep -n yes
4:yes
[root@hadoop1 home]# cat hello.txt | grep -ni yes
4:yes
9:YES
[root@hadoop1 home]# 

压缩和解压

gzip和gunzip

[root@hadoop1 home]# pwd
/home
[root@hadoop1 home]# ll
总用量 28
-rw-r--r--. 1 root      root    100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo 4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root     18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root    366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root    772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu 4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf     4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root    613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root     18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# gzip hello.txt 
[root@hadoop1 home]# ll
总用量 28
-rw-r--r--. 1 root      root    125 7月  22 16:22 hello.txt.gz
drwx------. 4 liubei    sanguo 4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root     18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root    366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root    772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu 4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf     4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root    613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root     18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# gunzip hello.txt.gz 
[root@hadoop1 home]# ll
总用量 28
-rw-r--r--. 1 root      root    100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo 4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root     18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root    366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root    772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu 4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf     4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root    613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root     18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# 

zip和unzip 

[root@hadoop1 home]# ll
总用量 8196
-rw-r--r--. 1 root      root       100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo    4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root        18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root   8361032 7月  22 16:32 mypackage.zip
-rw-r--r--. 1 root      root       366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root       772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu    4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf        4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root       613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root        18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# unzip -d /opt/tmp/ mypackage.zip
Archive:  mypackage.zip
   creating: /opt/tmp/home/
  inflating: /opt/tmp/home/ok3.txt   
  inflating: /opt/tmp/home/龙符.txt  
  inflating: /opt/tmp/home/hello.txt  
   creating: /opt/tmp/home/songjiang/
   creating: /opt/tmp/home/songjiang/.mozilla/
   creating: /opt/tmp/home/songjiang/.mozilla/plugins/
   creating: /opt/tmp/home/songjiang/.mozilla/extensions/
  inflating: /opt/tmp/home/songjiang/.bash_profile  
 extracting: /opt/tmp/home/songjiang/.bash_logout  
   creating: /opt/tmp/home/songjiang/.gnome2/
  inflating: /opt/tmp/home/songjiang/.bashrc  
  inflating: /opt/tmp/home/zhuge.txt  
   creating: /opt/tmp/home/liubei/
 extracting: /opt/tmp/home/liubei/ok1.txt  
   creating: /opt/tmp/home/liubei/.mozilla/
   creating: /opt/tmp/home/liubei/.mozilla/plugins/
   creating: /opt/tmp/home/liubei/.mozilla/extensions/
  inflating: /opt/tmp/home/liubei/.bash_profile  
 extracting: /opt/tmp/home/liubei/.bash_logout  
   creating: /opt/tmp/home/liubei/.gnome2/
  inflating: /opt/tmp/home/liubei/.bashrc  
   creating: /opt/tmp/home/zf/
 extracting: /opt/tmp/home/zf/ok1.txt  
   creating: /opt/tmp/home/zf/.mozilla/
   creating: /opt/tmp/home/zf/.mozilla/plugins/
   creating: /opt/tmp/home/zf/.mozilla/extensions/
  inflating: /opt/tmp/home/zf/.bash_profile  
 extracting: /opt/tmp/home/zf/ok2.txt  
 extracting: /opt/tmp/home/zf/.Xauthority  
 extracting: /opt/tmp/home/zf/.bash_logout  
   creating: /opt/tmp/home/zf/.gnome2/
  inflating: /opt/tmp/home/zf/.bash_history  
  inflating: /opt/tmp/home/zf/.bashrc  
  inflating: /opt/tmp/home/ok3.txt~  
  inflating: /opt/tmp/home/long      
[root@hadoop1 home]# ll
总用量 8196
-rw-r--r--. 1 root      root       100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo    4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root        18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root   8361032 7月  22 16:32 mypackage.zip
-rw-r--r--. 1 root      root       366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root       772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu    4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf        4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root       613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root        18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# cd /opt/tmp/
[root@hadoop1 tmp]# ll
总用量 4
drwxr-xr-x. 5 root root 4096 7月  22 16:32 home
[root@hadoop1 tmp]# ls
home
[root@hadoop1 tmp]# cat home
cat: home: 是一个目录
[root@hadoop1 tmp]# cd home
[root@hadoop1 home]# ll
总用量 22004
-rw-r--r--. 1 root root      100 7月  22 16:22 hello.txt
drwx------. 4 root root     4096 7月  12 16:18 liubei
-rw-r--r--. 1 root root 11248892 7月  12 16:27 long
-rw-r--r--. 1 root root      366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root root      772 7月  12 16:46 ok3.txt~
drwx------. 4 root root     4096 7月  11 20:26 songjiang
drwx------. 4 root root     4096 7月  12 15:57 zf
-rw-r--r--. 1 root root      613 7月  12 16:37 zhuge.txt
-rw-r--r--. 1 root root 11248892 7月  12 16:27 龙符.txt
[root@hadoop1 home]# cd ..
[root@hadoop1 tmp]# cd ../../
[root@hadoop1 /]# cd home
[root@hadoop1 home]# 

tar

[root@hadoop1 home]# pwd
/home
[root@hadoop1 home]# vim a1.txt
You have new mail in /var/spool/mail/root
[root@hadoop1 home]# cd^C
[root@hadoop1 home]# cd /var/spool/mail/root
-bash: cd: /var/spool/mail/root: 不是目录
[root@hadoop1 home]# ped
-bash: ped: command not found
[root@hadoop1 home]# pwd
/home
[root@hadoop1 home]# ll
总用量 8200
-rw-r--r--. 1 root      root        36 7月  22 16:41 a1.txt
-rw-r--r--. 1 root      root       100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo    4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root        18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root   8361032 7月  22 16:32 mypackage.zip
-rw-r--r--. 1 root      root       366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root       772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu    4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf        4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root       613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root        18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# vim a2.txt
[root@hadoop1 home]# ll
总用量 8204
-rw-r--r--. 1 root      root        36 7月  22 16:41 a1.txt
-rw-r--r--. 1 root      root        18 7月  22 16:42 a2.txt
-rw-r--r--. 1 root      root       100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo    4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root        18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root   8361032 7月  22 16:32 mypackage.zip
-rw-r--r--. 1 root      root       366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root       772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu    4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf        4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root       613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root        18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# tar -zcvf a.tar.gz a1.txt a2.txt 
a1.txt
a2.txt
[root@hadoop1 home]# ll
总用量 8208
-rw-r--r--. 1 root      root        36 7月  22 16:41 a1.txt
-rw-r--r--. 1 root      root        18 7月  22 16:42 a2.txt
-rw-r--r--. 1 root      root       197 7月  22 16:43 a.tar.gz
-rw-r--r--. 1 root      root       100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo    4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root        18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root   8361032 7月  22 16:32 mypackage.zip
-rw-r--r--. 1 root      root       366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root       772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu    4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf        4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root       613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root        18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# tar -zcvf myhome.tar.gz /home/
tar: 从成员名中删除开头的“/”
/home/
/home/mypackage.zip
/home/ok3.txt
/home/a.tar.gz
/home/龙符.txt
/home/hello.txt
/home/songjiang/
/home/songjiang/.mozilla/
/home/songjiang/.mozilla/plugins/
/home/songjiang/.mozilla/extensions/
/home/songjiang/.bash_profile
/home/songjiang/.bash_logout
/home/songjiang/.gnome2/
/home/songjiang/.bashrc
/home/zhuge.txt
/home/a2.txt
/home/a1.txt
/home/liubei/
/home/liubei/ok1.txt
/home/liubei/.mozilla/
/home/liubei/.mozilla/plugins/
/home/liubei/.mozilla/extensions/
/home/liubei/.bash_profile
/home/liubei/.bash_logout
/home/liubei/.gnome2/
/home/liubei/.bashrc
/home/zf/
/home/zf/ok1.txt
/home/zf/.mozilla/
/home/zf/.mozilla/plugins/
/home/zf/.mozilla/extensions/
/home/zf/.bash_profile
/home/zf/ok2.txt
/home/zf/.Xauthority
/home/zf/.bash_logout
/home/zf/.gnome2/
/home/zf/.bash_history
/home/zf/.bashrc
/home/ok3.txt~
/home/long
tar: /home: 在我们读入文件时文件发生了变化
[root@hadoop1 home]# ll
总用量 16376
-rw-r--r--. 1 root      root        36 7月  22 16:41 a1.txt
-rw-r--r--. 1 root      root        18 7月  22 16:42 a2.txt
-rw-r--r--. 1 root      root       197 7月  22 16:43 a.tar.gz
-rw-r--r--. 1 root      root       100 7月  22 16:22 hello.txt
drwx------. 4 liubei    sanguo    4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root        18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root   8360343 7月  22 16:44 myhome.tar.gz
-rw-r--r--. 1 root      root   8361032 7月  22 16:32 mypackage.zip
-rw-r--r--. 1 root      root       366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root       772 7月  12 16:46 ok3.txt~
drwx------. 4 songjiang shuihu    4096 7月  11 20:26 songjiang
drwx------. 4 zf        zf        4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root       613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root        18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# ls
a1.txt  a2.txt  a.tar.gz  hello.txt  liubei  long  myhome.tar.gz  mypackage.zip  ok3.txt  ok3.txt~  songjiang  zf  zhuge.txt  龙符.txt
[root@hadoop1 home]# tar -zxvf a.tar.gz 
a1.txt
a2.txt
[root@hadoop1 home]# ls
a1.txt  a2.txt  a.tar.gz  hello.txt  liubei  long  myhome.tar.gz  mypackage.zip  ok3.txt  ok3.txt~  songjiang  zf  zhuge.txt  龙符.txt
[root@hadoop1 home]# tar -zxvf myhome.tar.gz -C /opt/
home/
home/mypackage.zip
home/ok3.txt
home/a.tar.gz
home/龙符.txt
home/hello.txt
home/songjiang/
home/songjiang/.mozilla/
home/songjiang/.mozilla/plugins/
home/songjiang/.mozilla/extensions/
home/songjiang/.bash_profile
home/songjiang/.bash_logout
home/songjiang/.gnome2/
home/songjiang/.bashrc
home/zhuge.txt
home/a2.txt
home/a1.txt
home/liubei/
home/liubei/ok1.txt
home/liubei/.mozilla/
home/liubei/.mozilla/plugins/
home/liubei/.mozilla/extensions/
home/liubei/.bash_profile
home/liubei/.bash_logout
home/liubei/.gnome2/
home/liubei/.bashrc
home/zf/
home/zf/ok1.txt
home/zf/.mozilla/
home/zf/.mozilla/plugins/
home/zf/.mozilla/extensions/
home/zf/.bash_profile
home/zf/ok2.txt
home/zf/.Xauthority
home/zf/.bash_logout
home/zf/.gnome2/
home/zf/.bash_history
home/zf/.bashrc
home/ok3.txt~
home/long
[root@hadoop1 home]# ls
a1.txt  a2.txt  a.tar.gz  hello.txt  liubei  long  myhome.tar.gz  mypackage.zip  ok3.txt  ok3.txt~  songjiang  zf  zhuge.txt  龙符.txt
[root@hadoop1 home]# cd opt
-bash: cd: opt: 没有那个文件或目录
[root@hadoop1 home]# cd /opt
[root@hadoop1 opt]# ls
home  rh  tmp  VMwareTools-10.0.5-3228253.tar.gz  vmware-tools-distrib
[root@hadoop1 opt]# cd home
[root@hadoop1 home]# 

组管理和权限管理

组的基本介绍

linux 每个用户属于一个组,不能独立于组外,在Linux中每个文件有所有者,所在组和其他组的概念

查看文件的所有者

  1. ls -ahl(  a 隐藏文件,
    从v的 

  2. 修改文件

组的创建

linux 磁盘分区和管理

创建磁盘并设置自动挂载

Connecting to 192.168.32.129:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Fri Jul 22 21:49:03 2022 from 192.168.32.1
[root@hadoop1 ~]# lsblk -f
NAME   FSTYPE  LABEL            UUID                                 MOUNTPOINT
sr0    iso9660 CentOS_6.8_Final                                      /media/Cen
sdb                                                                  
└─sdb1 ext4                     6b089fe2-33ec-4ade-bac2-6d4295ed085a 
sda                                                                  
├─sda1 ext4                     0af6e570-9832-4054-999e-17f89bd6c89b /boot
├─sda2 swap                     af8f6e0f-b7c0-4d31-a944-cbb5128e89d8 [SWAP]
└─sda3 ext4                     294801d0-9b11-4ac5-8600-1adfe0622c66 /
[root@hadoop1 ~]# mkdir /home/newdisk
[root@hadoop1 ~]# cd home
-bash: cd: home: 没有那个文件或目录
[root@hadoop1 ~]# cd home/
-bash: cd: home/: 没有那个文件或目录
[root@hadoop1 ~]# cd /home
[root@hadoop1 home]# ll
总用量 16428
-rw-r--r--. 1 root      root         36 7月  22 16:41 a1.txt
-rw-r--r--. 1 root      root         18 7月  22 16:42 a2.txt
-rwxr-xr-x. 1 tom       bandit        9 7月  22 19:44 abc.txt
drwxr-xr-x. 2 root      root       4096 7月  22 17:32 animal
-rw-r--r--. 1 root      root        197 7月  22 16:43 a.tar.gz
drwx------. 4 fox       monster    4096 7月  22 17:19 fox
-rw-r--r--. 1 root      root        100 7月  22 16:22 hello.txt
drwxr-x---. 4 jack      police     4096 7月  22 20:33 jack
drwx------. 4 jerry     police     4096 7月  22 20:11 jerry
drwxr-xr-x. 3 tom       bandit     4096 7月  22 19:58 kkk
drwx------. 4 liubei    sanguo     4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root         18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root    8360343 7月  22 16:44 myhome.tar.gz
-rw-r--r--. 1 root      root    8361032 7月  22 16:32 mypackage.zip
-rwxr--r--. 1 root      root         20 7月  22 22:05 mytask1.sh
-rwxr--r--. 1 root      root         38 7月  22 22:14 mytask2.sh
drwxr-xr-x. 2 root      root       4096 7月  23 08:03 newdisk
-rw-r--r--. 1 root      root        366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root        772 7月  12 16:46 ok3.txt~
-rw-r--r--. 1 root      police       16 7月  22 17:23 orange.txt
drwx------. 4 songjiang shuihu     4096 7月  11 20:26 songjiang
drwx------. 4 tom       police     4096 7月  22 22:55 tom
drwx------. 4 xg        bandit     4096 7月  22 20:11 xg
drwx------. 4 xj        bandit     4096 7月  22 20:35 xj
drwx------. 4 zf        zf         4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root        613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root         18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# mount /dev/sdb1 /home/newdisk
[root@hadoop1 home]# ll
总用量 16428
-rw-r--r--. 1 root      root         36 7月  22 16:41 a1.txt
-rw-r--r--. 1 root      root         18 7月  22 16:42 a2.txt
-rwxr-xr-x. 1 tom       bandit        9 7月  22 19:44 abc.txt
drwxr-xr-x. 2 root      root       4096 7月  22 17:32 animal
-rw-r--r--. 1 root      root        197 7月  22 16:43 a.tar.gz
drwx------. 4 fox       monster    4096 7月  22 17:19 fox
-rw-r--r--. 1 root      root        100 7月  22 16:22 hello.txt
drwxr-x---. 4 jack      police     4096 7月  22 20:33 jack
drwx------. 4 jerry     police     4096 7月  22 20:11 jerry
drwxr-xr-x. 3 tom       bandit     4096 7月  22 19:58 kkk
drwx------. 4 liubei    sanguo     4096 7月  12 16:18 liubei
lrwxrwxrwx. 1 root      root         18 7月  12 17:36 long -> ../root/龙符.txt
-rw-r--r--. 1 root      root    8360343 7月  22 16:44 myhome.tar.gz
-rw-r--r--. 1 root      root    8361032 7月  22 16:32 mypackage.zip
-rwxr--r--. 1 root      root         20 7月  22 22:05 mytask1.sh
-rwxr--r--. 1 root      root         38 7月  22 22:14 mytask2.sh
drwxr-xr-x. 3 root      root       4096 7月  22 23:11 newdisk
-rw-r--r--. 1 root      root        366 7月  12 17:13 ok3.txt
-rw-r--r--. 1 root      root        772 7月  12 16:46 ok3.txt~
-rw-r--r--. 1 root      police       16 7月  22 17:23 orange.txt
drwx------. 4 songjiang shuihu     4096 7月  11 20:26 songjiang
drwx------. 4 tom       police     4096 7月  22 22:55 tom
drwx------. 4 xg        bandit     4096 7月  22 20:11 xg
drwx------. 4 xj        bandit     4096 7月  22 20:35 xj
drwx------. 4 zf        zf         4096 7月  12 15:57 zf
-rw-r--r--. 1 root      root        613 7月  12 16:37 zhuge.txt
lrwxrwxrwx. 1 root      root         18 7月  12 17:32 龙符.txt -> ../root/龙符.txt
[root@hadoop1 home]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0     11:0    1  3.7G  0 rom  /media/CentOS_6.8_Final
sdb      8:16   0    2G  0 disk 
└─sdb1   8:17   0    2G  0 part /home/newdisk
sda      8:0    0   20G  0 disk 
├─sda1   8:1    0  200M  0 part /boot
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 17.8G  0 part /
[root@hadoop1 home]# echo 这是临时挂载
这是临时挂载
[root@hadoop1 home]# echo 这是开机自启动 挂载
这是开机自启动 挂载
[root@hadoop1 home]# vim /etc/fstab
[root@hadoop1 home]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Jul  9 18:56:29 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/sdb1                                 /home/disk              ext4    defaults        1 1
UUID=294801d0-9b11-4ac5-8600-1adfe0622c66 /                       ext4    defaults        1 1
UUID=0af6e570-9832-4054-999e-17f89bd6c89b /boot                   ext4    defaults        1 2
UUID=af8f6e0f-b7c0-4d31-a944-cbb5128e89d8 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
[root@hadoop1 home]# vim /etc/fstab
[root@hadoop1 home]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Jul  9 18:56:29 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/sdb1                                 /home/disk              ext4    defaults        0 0
UUID=294801d0-9b11-4ac5-8600-1adfe0622c66 /                       ext4    defaults        1 1
UUID=0af6e570-9832-4054-999e-17f89bd6c89b /boot                   ext4    defaults        1 2
UUID=af8f6e0f-b7c0-4d31-a944-cbb5128e89d8 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
[root@hadoop1 home]# vim /etc/fstab
[root@hadoop1 home]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Jul  9 18:56:29 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/sdb1                                 /home/newdisk           ext4    defaults        0 0
UUID=294801d0-9b11-4ac5-8600-1adfe0622c66 /                       ext4    defaults        1 1
UUID=0af6e570-9832-4054-999e-17f89bd6c89b /boot                   ext4    defaults        1 2
UUID=af8f6e0f-b7c0-4d31-a944-cbb5128e89d8 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
[root@hadoop1 home]# lsblk -f
NAME   FSTYPE  LABEL            UUID                                 MOUNTPOINT
sr0    iso9660 CentOS_6.8_Final                                      /media/CentOS_6.8_Final
sdb                                                                  
└─sdb1 ext4                     6b089fe2-33ec-4ade-bac2-6d4295ed085a /home/newdisk
sda                                                                  
├─sda1 ext4                     0af6e570-9832-4054-999e-17f89bd6c89b /boot
├─sda2 swap                     af8f6e0f-b7c0-4d31-a944-cbb5128e89d8 [SWAP]
└─sda3 ext4                     294801d0-9b11-4ac5-8600-1adfe0622c66 /
[root@hadoop1 home]# cd newdisk
[root@hadoop1 newdisk]# ll
总用量 16
drwx------. 2 root root 16384 7月  22 23:11 lost+found
[root@hadoop1 newdisk]# cd ..

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值