此篇创作还没做完整,我将加把劲,早日完成
目录
一、Linux系统目录结构
1、查看目录结构命令
tree 目标目录
查看指定目录内容
[root@huang yum.repos.d]# tree /home/ /home/ └── huang
1 directory, 0 files
2、目录结构操作使用方法
在对目录结构进行操作管理时,可有三种方法对目录进行操作管理:
1.采用绝对路径方式进行操作管理
2.采用相对路径方式进行操作管理
3.采用设备挂载方式进行管理
2.1、绝对路径
表示从根路径开始,进入指定的路径或子目录中,获取指定的数据资源信息
采用绝对路径方式进入到network-scripts目录中
[root@huang ~]# cd /etc/sysconfig/network-scripts/ [root@huang network-scripts]# ls ifcfg-ens33 ifdown-ppp ifup-ib ifup-Team ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort ifdown ifdown-sit ifup-ipv6 ifup-tunnel ifdown-bnep ifdown-Team ifup-isdn ifup-wireless ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global ifdown-ib ifdown-tunnel ifup-plusb network-functions ifdown-ippp ifup ifup-post network-functions-ipv6 ifdown-ipv6 ifup-aliases ifup-ppp ifdown-isdn ifup-bnep ifup-routes ifdown-post ifup-eth ifup-sit
说明:采用绝对路径的方式切换目录可以更有效地保证操作的准确性
2.2、相对路径
表示从当前路径开始,进入指定的路径中或子目录中,获取指定的数据资源信息
采用相对路径方式进入到network-scripts目录中
[root@huang network-scripts]# cd /etc/sysconfig/ [root@huang sysconfig]# cd network-scripts/ [root@huang network-scripts]# ls ifcfg-ens33 ifdown-ppp ifup-ib ifup-Team ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort ifdown ifdown-sit ifup-ipv6 ifup-tunnel ifdown-bnep ifdown-Team ifup-isdn ifup-wireless ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global ifdown-ib ifdown-tunnel ifup-plusb network-functions ifdown-ippp ifup ifup-post network-functions-ipv6 ifdown-ipv6 ifup-aliases ifup-ppp ifdown-isdn ifup-bnep ifup-routes ifdown-post ifup-eth ifup-sit
说明:采用相对路径的方式切换目录可以提升操作效率
3、目录结构中重要文件数据
3.1、网卡地址信息配置文件
/ect/sysconfig/network-scripts/ifcfg-ens33
说明:网卡文件名称结尾的数字编号n,即为第n+1块网卡信息,ens33表示第一块网卡,ens34则表示第二块网卡,以此类推;
3.2、网络域名服务配置文件
/etc/resolve.conf
说明:此文件中配置信息,也会影响主机和外网域名地址信息进行通讯。
3.3、网络本地解析配置文件
/etc/hosts
说明:此文件中配置信息,主要用于测试访问指定网站服务器,以及可以利用域名地址和其他服务器建立通讯。
3.4、开机自动运行脚本或命令文件
/etc/rc.local
说明:此文件中产生信息,为系统或某些服务运行状态信息,会有正常运行状态输出信息,也会有错误输出信息,主要用于排错使用。
二、文件与目录操作命令
1、打印工作目录命令
pwd命令来查看“当前工作目录”的完整路径。简单得说,每当你在终端进行操作时,你都会有一个当前工作目录。在不太确定当前位置时,就会使用pwd来判定当前目录在文件系统内的确切位置。
语法:pwd [选项]
[root@huang etc]# pwd /etc
2、目录切换命令
cd命令可以说是Linux中最基本的命令语句,其他的命令语句要进行操作,都是建立在使用cd命令上的。
语法:
cd [目录]
选项:
cd:返回当前登录用户的家目录
cd..:返回上级目录
cd~:返回当前登陆用户的家目录
cd-:返回上次跳转到当前目录的目录
cd /指定目录:切换到指定目录 [root@huang ~]# cd [root@huang ~]# cd .. [root@huang /]# cd ~ [root@huang ~]# cd - /
[root@huang /]# cd /etc [root@huang etc]#
3、目录内容查看命令
ls命令是linux下最常用的命令。ls命令就是list的缩写,缺省下ls用来打印当前目录的清单,如果ls指定其他目录,那么就会显示指定目录里的文件及文件夹清单。通过ls命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录、文件夹、文件权限)查看目录信息等等。
语法:ls []
选项:
-a,--all:显示所有文件(包括以.开头的隐藏文件)
-l:使用详细列表格式显示文件或目录的详细信息
-h,--human-readable:使用人类可读的格式显示文件大小(例如1K、2M)
-r,--reverse:以相反的顺序列出文件
-t:按照修改时间(最新的文件在前)排序
-S:按照文件大小排序
-d,--directory:显示目录本身,而非目录下的文件列表
-i,--inode:显示每个文件的inode号
--color=auto:自动根据文件类型显示不同的颜色
-R,--recursive:递归列出目录及其子目录中的文件
[root@huang ~]# ls -a . .bash_history .bashrc .cshrc .ICEauthority .tcshrc 模板 文档 桌面 .. .bash_logout .cache .dbus initial-setup-ks.cfg .viminfo 视频 下载 anaconda-ks.cfg .bash_profile .config .esd_auth .local 公共 图片 音乐
[root@huang ~]# ls -l 总用量 8 -rw-------. 1 root root 1700 5月 7 23:15 anaconda-ks.cfg -rw-r--r--. 1 root root 1748 5月 7 23:21 initial-setup-ks.cfg drwxr-xr-x. 2 root root 6 5月 7 23:24 公共 drwxr-xr-x. 2 root root 6 5月 7 23:24 模板 drwxr-xr-x. 2 root root 6 5月 7 23:24 视频 drwxr-xr-x. 2 root root 6 5月 7 23:24 图片 drwxr-xr-x. 2 root root 6 5月 7 23:24 文档 drwxr-xr-x. 2 root root 6 5月 7 23:24 下载 drwxr-xr-x. 2 root root 6 5月 7 23:24 音乐 drwxr-xr-x. 2 root root 6 5月 7 23:24 桌面 [root@huang ~]# ls -lh 总用量 8.0K -rw-------. 1 root root 1.7K 5月 7 23:15 anaconda-ks.cfg -rw-r--r--. 1 root root 1.8K 5月 7 23:21 initial-setup-ks.cfg drwxr-xr-x. 2 root root 6 5月 7 23:24 公共 drwxr-xr-x. 2 root root 6 5月 7 23:24 模板 drwxr-xr-x. 2 root root 6 5月 7 23:24 视频 drwxr-xr-x. 2 root root 6 5月 7 23:24 图片 drwxr-xr-x. 2 root root 6 5月 7 23:24 文档 drwxr-xr-x. 2 root root 6 5月 7 23:24 下载 drwxr-xr-x. 2 root root 6 5月 7 23:24 音乐 drwxr-xr-x. 2 root root 6 5月 7 23:24 桌面
[root@huang ~]# ls -r 桌面 音乐 下载 文档 图片 视频 模板 公共 initial-setup-ks.cfg anaconda-ks.cfg [root@huang ~]# ls -t 公共 模板 视频 图片 文档 下载 音乐 桌面 initial-setup-ks.cfg anaconda-ks.cfg [root@huang ~]# ls -tl 总用量 8 drwxr-xr-x. 2 root root 6 5月 7 23:24 公共 drwxr-xr-x. 2 root root 6 5月 7 23:24 模板 drwxr-xr-x. 2 root root 6 5月 7 23:24 视频 drwxr-xr-x. 2 root root 6 5月 7 23:24 图片 drwxr-xr-x. 2 root root 6 5月 7 23:24 文档 drwxr-xr-x. 2 root root 6 5月 7 23:24 下载 drwxr-xr-x. 2 root root 6 5月 7 23:24 音乐 drwxr-xr-x. 2 root root 6 5月 7 23:24 桌面 -rw-r--r--. 1 root root 1748 5月 7 23:21 initial-setup-ks.cfg -rw-------. 1 root root 1700 5月 7 23:15 anaconda-ks.cfg [root@huang ~]# ls -S initial-setup-ks.cfg 公共 视频 文档 音乐 anaconda-ks.cfg 模板 图片 下载 桌面
[root@huang ~]# ls -Sl 总用量 8 -rw-r--r--. 1 root root 1748 5月 7 23:21 initial-setup-ks.cfg -rw-------. 1 root root 1700 5月 7 23:15 anaconda-ks.cfg drwxr-xr-x. 2 root root 6 5月 7 23:24 公共 drwxr-xr-x. 2 root root 6 5月 7 23:24 模板 drwxr-xr-x. 2 root root 6 5月 7 23:24 视频 drwxr-xr-x. 2 root root 6 5月 7 23:24 图片 drwxr-xr-x. 2 root root 6 5月 7 23:24 文档 drwxr-xr-x. 2 root root 6 5月 7 23:24 下载 drwxr-xr-x. 2 root root 6 5月 7 23:24 音乐 drwxr-xr-x. 2 root root 6 5月 7 23:24 桌面
[root@huang ~]# ls -d . [root@huang ~]# ls -dl dr-xr-x---. 14 root root 4096 5月 9 14:36 . [root@huang ~]# ls -il 总用量 8 100663362 -rw-------. 1 root root 1700 5月 7 23:15 anaconda-ks.cfg 100663363 -rw-r--r--. 1 root root 1748 5月 7 23:21 initial-setup-ks.cfg 68134271 drwxr-xr-x. 2 root root 6 5月 7 23:24 公共 33713981 drwxr-xr-x. 2 root root 6 5月 7 23:24 模板 68134272 drwxr-xr-x. 2 root root 6 5月 7 23:24 视频 33713982 drwxr-xr-x. 2 root root 6 5月 7 23:24 图片 100663421 drwxr-xr-x. 2 root root 6 5月 7 23:24 文档 10908 drwxr-xr-x. 2 root root 6 5月 7 23:24 下载 10909 drwxr-xr-x. 2 root root 6 5月 7 23:24 音乐 100663420 drwxr-xr-x. 2 root root 6 5月 7 23:24 桌面
[root@huang ~]# ls -R .: anaconda-ks.cfg initial-setup-ks.cfg 公共 模板 视频 图片 文档 下载 音乐 桌面
./公共:
./模板:
./视频:
./图片:
./文档:
./下载:
./音乐:
./桌面:
4、文件查看命令
4.1、cat命令
cat命令的用途是连接文件或标准输入并打印。这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读出内容并显示,它常用与重定向符号配合使用。
cat [选项] [文件]...
功能:
1、一次显示整个文件:cat filename
2、从键盘创建一个文件:cat>filename只能创建新文件,不能编辑已有文件
3、将几个文件合并为一个文件:cat file1 file2 > file3
4、追加内容到指定文件
[root@huang ~]# cat <<e>> 3.txt
123456 e [root@huang ~]# cat 3.txt 123456
重定向符号:
1、覆盖重定向:>
2、追加重定向:>>
[root@huang ~]# cat > 1.txt 123 456 789[root@huang ~]# cat 1.txt 123 456 789[root@huang ~]# cat > 2.txt qwe asd zxc [root@huang ~]# cat 2.txt qwe asd zxc
[root@huang ~]# cat 1.txt > 3.txt [root@huang ~]# cat 3.txt 123 456
789[root@huang ~]# cat 2.txt >> 3.txt [root@huang ~]# cat 3.txt 123 456 789qwe asd zxc
选项:
-n:显示行号
-e:在输出的行尾添加制表符和换行号
[root@huang ~]# cat -n 3.txt 1 123 2 456
3 789[root@huang ~]# cat -e 3.txt 123$ 456$