linux基础命令(二)
一.基础命令
1.目录管理
1.1 ls 列出目录内容
-
[root@SYL2 ~]# ls 1 2 4 7 a test.tar.gz 1.1.txt 20220323 5 8 anaconda-ks.cfg 10 3 6 9 bin [root@SYL2 ~]# ls 1.1.txt 1.1.txt
-
-l (ls -l )ll
-
-(文件类型) rw-r–r–.(权限) 1(内存中存在的次数) root (文件属主,文件属于谁) root(属组,文件能够执行的权限) 88(大小) Mar 24 10:35(时间) 1.1.txt(文件名)
-
[root@SYL2 ~]# ls -l 1.1.txt -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt [root@SYL2 ~]# ll 1.1.txt -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt [root@SYL2 ~]#
-
ls -l 文件类型 - 普通文件(f) d 目录文件 b 块设备文件(block) c 字符设备文件(character) l 符号链接文件(symbolic link file) p 命令管道(pipe) s 套接字文件(socket) -
[root@SYL2 ~]# ls -l total 12 -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt drwxr-xr-x. 2 root root 27 Mar 24 11:30 20220323 drwxr-xr-x. 5 root root 33 Mar 23 15:23 a -rw-------. 1 root root 1092 Mar 24 10:02 anaconda-ks.cfg drwxr-xr-x. 2 root root 17 Mar 24 11:24 bin -rw-r--r--. 1 root root 210 Mar 24 11:15 test.tar.gz [root@SYL2 ~]#
-
-h 显示单位
-
[root@SYL2 ~]# ll -h 1.1.txt -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt [root@SYL2 ~]# ll -h anaconda-ks.cfg -rw-------. 1 root root 1.1K Mar 24 10:02 anaconda-ks.cfg [root@SYL2 ~]#
-
-
-a 显示以.开头的隐藏文件
-
[root@SYL2 ~]# ls -a . .bashrc a .. .config anaconda-ks.cfg ... .cshrc bin .bash_history .tcshrc test.tar.gz .bash_logout 1.1.txt .bash_profile 20220323 [root@SYL2 ~]#
-
-
. 表示当前目录 …表示父目录
-
[root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# cd . [root@SYL2 network-scripts]# cd .. [root@SYL2 sysconfig]# cd .. [root@SYL2 etc]# [root@SYL2 ~]# ls .. 1.1.txt dev lib mnt root srv usr bin etc lib64 opt run sys var boot home media proc sbin tmp [root@SYL2 ~]# ls / 1.1.txt dev lib mnt root srv usr bin etc lib64 opt run sys var boot home media proc sbin tmp [root@SYL2 ~]#
-
-
-d 显示目录自身属性
-
[root@SYL2 ~]# ll bin/ total 140 -rwxr-xr-x. 1 root root 143224 Mar 23 14:48 lls [root@SYL2 ~]# ll -d bin drwxr-xr-x. 2 root root 17 Mar 24 11:24 bin [root@SYL2 ~]#
-
-
-i 显示文件的inode(index node)
-
[root@SYL2 ~]# cd bin/ [root@SYL2 bin]# ls lls [root@SYL2 bin]# ln lls 111 [root@SYL2 bin]# ls 111 lls [root@SYL2 bin]# ll -i total 280 34224236 -rwxr-xr-x. 2 root root 143224 Mar 23 14:48 111 34224236 -rwxr-xr-x. 2 root root 143224 Mar 23 14:48 lls [root@SYL2 bin]# [root@SYL2 ~]# ll -i anaconda-ks.cfg 33575044 -rw-------. 1 root root 1092 Mar 24 10:02 anaconda-ks.cfg [root@SYL2 ~]#
-
-
-r 逆序显示 -t 根据修改时间排序
-
[root@SYL2 ~]# ll -t total 12 drwxr-xr-x. 2 root root 28 Mar 24 15:13 bin drwxr-xr-x. 2 root root 27 Mar 24 11:30 20220323 -rw-r--r--. 1 root root 210 Mar 24 11:15 test.tar.gz -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt -rw-------. 1 root root 1092 Mar 24 10:02 anaconda-ks.cfg drwxr-xr-x. 5 root root 33 Mar 23 15:23 a [root@SYL2 ~]# ll -rt total 12 drwxr-xr-x. 5 root root 33 Mar 23 15:23 a -rw-------. 1 root root 1092 Mar 24 10:02 anaconda-ks.cfg -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt -rw-r--r--. 1 root root 210 Mar 24 11:15 test.tar.gz drwxr-xr-x. 2 root root 27 Mar 24 11:30 20220323 drwxr-xr-x. 2 root root 28 Mar 24 15:13 bin [root@SYL2 ~]#
-
-
-R 递归(recursive)显示
-
[root@SYL2 ~]# ls -R a a: b c d a/b: 147 235 a/b/147: a/b/235: a/c: 123 a/c/123: a/d: aaa bbb a/d/aaa: 199 a/d/aaa/199: a/d/bbb: [root@SYL2 ~]#
-
1.2 cd 改变当前工作目录
-
回家 cd cd ~ cd /root
cd - 回看 -
[root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# cd . [root@SYL2 network-scripts]# cd .. [root@SYL2 sysconfig]# cd .. [root@SYL2 etc]# cd [root@SYL2 ~]# [root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# cd ~ [root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# cd /root [root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# cd - /root [root@SYL2 ~]# cd - /etc/sysconfig/network-scripts [root@SYL2 network-scripts]# cd - /root [root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# cd [root@SYL2 ~]#
1.3 pwd 打印当前工作目录路径
-
[root@SYL2 ~]# pwd /root [root@SYL2 ~]# cd /etc/sysconfig/network-scripts/ [root@SYL2 network-scripts]# pwd /etc/sysconfig/network-scripts [root@SYL2 network-scripts]#
1.4 mkdir 创建目录 rmdir 删除目录,只能删除空目录
-
-p 创建目录时若父目录不存在则自动创建
-
[root@SYL2 ~]# mkdir 1999 [root@SYL2 ~]# cd 1999 [root@SYL2 1999]# touch 2022 [root@SYL2 1999]# ls 2022 [root@SYL2 1999]# cd .. [root@SYL2 ~]# ls 1.1.txt 20220323 2060 anaconda-ks.cfg test.tar.gz 1999 2050 a bin [root@SYL2 ~]# rmdir 1999 rmdir: failed to remove '1999': Directory not empty [root@SYL2 ~]# rmdir 2050 [root@SYL2 ~]#
1.5 tree 查看目录树
-
[root@SYL2 ~]# tree a a |-- b | |-- 147 | `-- 235 |-- c | `-- 123 `-- d |-- aaa | `-- 199 `-- bbb 9 directories, 0 files [root@SYL2 ~]#
2.文件管理
2.1 touch 创建文件
-
[root@SYL2 ~]# cd 2060 [root@SYL2 2060]# touch 2121 [root@SYL2 2060]# touch AAA [root@SYL2 2060]# ls 2121 AAA [root@SYL2 2060]#
2.2 stat 显示文件或文件系统的状态
-
[root@SYL2 ~]# stat 2060/ File: 2060/ Size: 29 Blocks: 0 IO Block: 4096 directory Device: fd00h/64768d Inode: 33576897 Links: 2 Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2022-03-24 15:58:45.419395637 +0800 Modify: 2022-03-24 15:58:43.340395721 +0800 Change: 2022-03-24 15:58:43.340395721 +0800 Birth: 2022-03-24 15:32:50.314458605 +0800 [root@SYL2 ~]#
2.3 rm 删除文件,删除命令默认会提示是否需要删除
-
rm -f 删除文件 强制删除,忽略不存在的文件,不提示确认
-
rm -rf 删除目录 参数表示递归强制删除非空文件夹
-
[root@SYL2 2060]# ls 2121 AAA [root@SYL2 2060]# rm -f AAA [root@SYL2 2060]# rm 2121 rm: remove regular empty file '2121'? y [root@SYL2 2060]# ls [root@SYL2 2060]# touch 258 [root@SYL2 2060]# cd [root@SYL2 ~]# rm -rf 2060 [root@SYL2 ~]# ls 1.1.txt 1999 20220323 a anaconda-ks.cfg bin
2.4 cp 复制文件,一个文件到一个文件,多个文件到一个目录并且设置属性
-
cp 复制目录要加 -r
-
[root@SYL2 ~]# cp -r a 2060 [root@SYL2 ~]# ls 2060 a [root@SYL2 ~]#
-
单个文件复制到另一个文件
-
[root@SYL2 ~]# ls 1.1.txt 20220323 2060 aaa bin 1999 2050 a anaconda-ks.cfg [root@SYL2 ~]# cp aaa 123 [root@SYL2 ~]# ls 1.1.txt 1999 2050 a anaconda-ks.cfg 123 20220323 2060 aaa bin [root@SYL2 ~]#
-
多对一 多个文件复制一个目录
-
1.1.txt 1999 2050 a anaconda-ks.cfg 123 20220323 2060 aaa bin [root@SYL2 ~]# cp 123 2050 aaa bin/ [root@SYL2 ~]# ls bin/ 111 123 2050 aaa lls [root@SYL2 ~]#
-
一个目录复制到另一个目录
-
[root@SYL2 ~]# ls bin/ 111 123 2050 aaa lls [root@SYL2 ~]# ls 1999/ 2022 [root@SYL2 ~]# cp -r 1999/ bin/ [root@SYL2 ~]# ls bin/ 111 123 1999 2050 aaa lls [root@SYL2 ~]#
2.5 mv 移动文件,实现剪贴和重命名
-
重命名 一对一 mv abc abc.php #将abc重命名为abc.php
-
剪贴 一对一 多对一 最后一个必须是目录
-
重命名 目录更换名字,内容不变
-
[root@SYL2 ~]# ls 1.1.txt 20220323 2060 aaa bin 1999 2050 a anaconda-ks.cfg [root@SYL2 ~]# mv 1999 qqq [root@SYL2 ~]# ls 1.1.txt 2050 a anaconda-ks.cfg qqq 20220323 2060 aaa bin [root@SYL2 ~]#
-
剪贴 文件到目录
-
[root@SYL2 ~]# ls 1.1.txt 2050 a anaconda-ks.cfg qqq 20220323 2060 aaa bin [root@SYL2 ~]# mv 2050 qqq [root@SYL2 ~]# ls qqq 2022 2050 [root@SYL2 ~]#
-
支持多个文件,目录移到到目录中
-
[root@SYL2 ~]# ls 1.1.txt 2060 anaconda-ks.cfg kkk qqq zxc 20220323 a bin qaz qwe [root@SYL2 ~]# mv qaz qwe zxc 2060/ [root@SYL2 ~]# ls 1.1.txt 2060 anaconda-ks.cfg kkk 20220323 a bin qqq [root@SYL2 ~]# ls 2060/ a qaz qwe zxc [root@SYL2 ~]# mv 2060/ kkk/ [root@SYL2 ~]# ls kkk/ 2060 [root@SYL2 ~]# ls 1.1.txt 20220323 a anaconda-ks.cfg bin kkk qqq
2.6 install 复制文件并且设置属性
-
[root@SYL2 ~]# install hhh 999 [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]# ll total 8 -rw-r--r--. 1 root root 88 Mar 24 10:35 1.1.txt drwxr-xr-x. 2 root root 38 Mar 24 16:22 20220323 -rwxr-xr-x. 1 root root 0 Mar 24 16:29 999 drwxr-xr-x. 5 root root 33 Mar 23 15:23 a -rw-------. 1 root root 1092 Mar 24 10:02 anaconda-ks.cfg drwxr-xr-x. 3 root root 74 Mar 24 16:11 bin -rw-r--r--. 1 root root 0 Mar 24 16:27 hhh drwxr-xr-x. 3 root root 18 Mar 24 16:24 kkk drwxr-xr-x. 2 root root 30 Mar 24 16:17 qqq [root@SYL2 ~]#
3.压缩、解压缩命令
- file 看压缩包类型
3.1压缩格式,不能压缩目录
- gz bz2 xz zip Z
3.2 gzip 压缩后的文件以.gz结尾 解压 gzip -d/gunzip
-
压缩原文件没有了,解压压缩文件没了
-
[root@SYL2 ~]# gzip 999 [root@SYL2 ~]# ls 1.1.txt 999.gz anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]# file 999.gz 999.gz: gzip compressed data, was "999", last modified: Thu Mar 24 08:29:02 2022, from Unix, original size 0 [root@SYL2 ~]# gzip -d 999.gz [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]#
3.3 bzip2压缩后的文件以.bz2结尾 bunzip2 解压/bzip2 -d
-
[root@SYL2 ~]# bzip2 qqq bzip2: Input file qqq is a directory. [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]# bzip2 anaconda-ks.cfg [root@SYL2 ~]# file anaconda-ks.cfg.bz2 anaconda-ks.cfg.bz2: bzip2 compressed data, block size = 900k [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg.bz2 hhh qqq 20220323 a bin kkk [root@SYL2 ~]# bzip2 -d anaconda-ks.cfg.bz2 [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]#
3.4 xz 压缩后的文件以.xz结尾 unxz 解压/xz -d
-
[root@SYL2 ~]# which xz /usr/bin/xz [root@SYL2 ~]# xz hhh [root@SYL2 ~]# file hhh.xz hhh.xz: XZ compressed data [root@SYL2 ~]# unxz hhh.xz [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]# xz hhh [root@SYL2 ~]# xz -d hhh.xz [root@SYL2 ~]# ls 1.1.txt 999 anaconda-ks.cfg hhh qqq 20220323 a bin kkk [root@SYL2 ~]#
3.5 zip 既归档又压缩的工具。zip可以压缩目录 unzip
-
压缩多个文件
-
[root@SYL2 ~]# zip dv.zip 123 2060 hhh adding: 123 (stored 0%) adding: 2060 (stored 0%) adding: hhh (stored 0%) [root@SYL2 ~]# file dv.zip dv.zip: Zip archive data, at least v1.0 to extract [root@SYL2 ~]# ls 1.1.txt 20220323 999 abc bin hhh 123 2060 a anaconda-ks.cfg dv.zip [root@SYL2 ~]# rm -f 123 2060 hhh [root@SYL2 ~]# ls 1.1.txt 999 abc bin 20220323 a anaconda-ks.cfg dv.zip [root@SYL2 ~]# file dv.zip dv.zip: Zip archive data, at least v1.0 to extract [root@SYL2 ~]# zip abc.zip abc adding: abc/ (stored 0%)
-
压缩目录
-
[root@SYL2 ~]# zip abc.zip abc adding: abc/ (stored 0%) [root@SYL2 ~]# ls 1.1.txt 999 abc anaconda-ks.cfg dv.zip 20220323 a abc.zip bin [root@SYL2 ~]# rm -f abc rm: cannot remove 'abc': Is a directory [root@SYL2 ~]# rm -rf abc [root@SYL2 ~]# ls 1.1.txt 999 abc.zip bin 20220323 a anaconda-ks.cfg dv.zip [root@SYL2 ~]# unzip abc.zip Archive: abc.zip creating: abc/ [root@SYL2 ~]# ls 1.1.txt 999 abc anaconda-ks.cfg dv.zip 20220323 a abc.zip bin [root@SYL2 ~]#
-
解压
-
[root@SYL2 ~]# unzip abc.zip Archive: abc.zip [root@SYL2 ~]# ls 1.1.txt 999 abc anaconda-ks.cfg dv.zip 20220323 a abc.zip bin [root@SYL2 ~]# unzip dv.zip Archive: dv.zip extracting: 123 extracting: 2060 extracting: hhh [root@SYL2 ~]# ls 1.1.txt 2060 abc bin 123 999 abc.zip dv.zip 20220323 a anaconda-ks.cfg hhh [root@SYL2 ~]#
3.6 tar 归档工具,只归档不压缩
-
-c 创建归档文件 -f file.tar 操作的归档文件 -x 还原归档 -v 显示归档过程 -p 归档时保留权限信息。只有管理员才有权限用此选项 -C 将展开的归档文件保存至指定目录下 -
tar -xf +包 解压不分格式
-
[root@SYL2 ~]# tar -xf abc1.tar.bz2 [root@SYL2 ~]# ls 1.1.txt a abc2.tar.xz hhh 123 abc.tar.gz anaconda-ks.cfg 20220323 abc.zip bin 2060 abc1.tar.bz2 dv.zip [root@SYL2 ~]# [root@SYL2 ~]# tar -jcf abc1.tar.gz 123 2060 hhh [root@SYL2 ~]# ls 1.1.txt abc.tar.gz abc1.tar.gz bin 20220323 abc.zip abc2.tar.xz dv.zip a abc1.tar.bz2 anaconda-ks.cfg [root@SYL2 ~]# tar -xf abc1.tar.gz [root@SYL2 ~]# ls 1.1.txt a abc1.tar.gz dv.zip 123 abc.tar.gz abc2.tar.xz hhh 20220323 abc.zip anaconda-ks.cfg 2060 abc1.tar.bz2 bin [root@SYL2 ~]#
-
tar -tf +包 不解压查看压缩包
-
[root@SYL2 ~]# tar -tf abc1.tar.bz2 2060 123 hhh [root@SYL2 ~]#
-
-zcf //归档并调用gzip压缩
-
-zxf //调用gzip解压缩并展开归档
-
[root@SYL2 ~]# unzip abc.zip Archive: abc.zip [root@SYL2 ~]# ls 1.1.txt 999 abc anaconda-ks.cfg dv.zip 20220323 a abc.zip bin [root@SYL2 ~]# unzip dv.zip Archive: dv.zip extracting: 123 extracting: 2060 extracting: hhh [root@SYL2 ~]# ls 1.1.txt 2060 abc bin 123 999 abc.zip dv.zip 20220323 a anaconda-ks.cfg hhh [root@SYL2 ~]#
-
[root@SYL2 ~]# tar -zxf abc.tar.gz [root@SYL2 ~]# ls 1.1.txt 2060 abc anaconda-ks.cfg hhh 123 999 abc.tar.gz bin 20220323 a abc.zip dv.zip
-
-Jcf //归档并调用xz压缩
-
-Jxf //调用xz解压缩并展开归档
-
[root@SYL2 ~]# tar -Jcf abc2.tar.xz abc 123 hhh [root@SYL2 ~]# ls 1.1.txt 2060 abc abc1.tar.bz2 bin 123 999 abc.tar.gz abc2.tar.xz dv.zip 20220323 a abc.zip anaconda-ks.cfg hhh [root@SYL2 ~]# rm -f abc 123 hhh rm: cannot remove 'abc': Is a directory [root@SYL2 ~]# rm -rf abc 123 hhh [root@SYL2 ~]# ls 1.1.txt 999 abc.zip anaconda-ks.cfg 20220323 a abc1.tar.bz2 bin 2060 abc.tar.gz abc2.tar.xz dv.zip
-
[root@SYL2 ~]# tar -Jxf abc2.tar.xz abc 123 hhh [root@SYL2 ~]# ls 1.1.txt 2060 abc abc1.tar.bz2 bin 123 999 abc.tar.gz abc2.tar.xz dv.zip 20220323 a abc.zip anaconda-ks.cfg hhh
-
-jcf //归档并调用bzip2压缩
-
-jxf //调用bzip2解压缩并展开归档
-
[root@SYL2 ~]# tar -jcf abc1.tar.bz2 2060 123 hhh [root@SYL2 ~]# ls 1.1.txt 2060 abc abc1.tar.bz2 dv.zip 123 999 abc.tar.gz anaconda-ks.cfg hhh 20220323 a abc.zip bin [root@SYL2 ~]# rm -f 2060 123 hhh [root@SYL2 ~]# ls 1.1.txt a abc.zip bin 20220323 abc abc1.tar.bz2 dv.zip 999 abc.tar.gz anaconda-ks.cfg [root@SYL2 ~]#
-
[root@SYL2 ~]# tar -jxf abc1.tar.bz2 2060 123 hhh [root@SYL2 ~]# ls 1.1.txt 2060 abc abc1.tar.bz2 dv.zip 123 999 abc.tar.gz anaconda-ks.cfg hhh 20220323 a abc.zip bin [root@SYL2 ~]#
3.7 删除压缩包
-
[root@SYL2 ~]# ls 1.1.txt a abc1.tar.bz2 ana.tar.gz hhh 123 abc.tar.gz abc1.tar.gz bin 2060 abc.zip abc2.tar.xz dv.zip [root@SYL2 ~]# rm -rf *.gz *.bz2 *.zip [root@SYL2 ~]# ls 1.1.txt 123 2060 a abc2.tar.xz bin hhh [root@SYL2 ~]# rm -rf *.xz [root@SYL2 ~]# ls 1.1.txt 123 2060 a bin hhh [root@SYL2 ~]#
4.文本统计
4.1 wc
-
-c 显示字节数
-
-l 显示行数
-
-w 显示单词数
-
[root@SYL2 ~]# wc 1.1.txt 204 299 4913 1.1.txt [root@SYL2 ~]# wc -c 1.1.txt 4913 1.1.txt [root@SYL2 ~]# wc -l 1.1.txt 204 1.1.txt [root@SYL2 ~]# wc -w 1.1.txt 299 1.1.txt [root@SYL2 ~]#
5.大小统计
5.1 du 查看文件或目录占用的磁盘空间大小
-
-h 显示大小
-
-s 显示总的占用空间大小
-
[root@SYL2 ~]# ls 1.1.txt abc.tar.gz abc1.tar.bz2 abc2.tar.xz bin a abc.zip abc1.tar.gz ana.tar.gz dv.zip [root@SYL2 ~]# du ana.tar.gz 4 ana.tar.gz [root@SYL2 ~]# du -sh ana.tar.gz 4.0K ana.tar.gz [root@SYL2 ~]# du -s ana.tar.gz 4 ana.tar.gz [root@SYL2 ~]# du -h ana.tar.gz 4.0K ana.tar.gz [root@SYL2 ~]#
5.2 df 报告文件系统磁盘空间使用情况
-
-h 显示大小
-
[root@SYL2 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 874M 0 874M 0% /dev tmpfs 893M 0 893M 0% /dev/shm tmpfs 893M 8.7M 885M 1% /run tmpfs 893M 0 893M 0% /sys/fs/cgroup /dev/mapper/cs-root 17G 1.8G 16G 11% / /dev/sda1 1014M 210M 805M 21% /boot tmpfs 179M 0 179M 0% /run/user/0 [root@SYL2 ~]#
-
-i 显示inode信息
-
[root@SYL2 ~]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on devtmpfs 223510 388 223122 1% /dev tmpfs 228531 1 228530 1% /dev/shm tmpfs 228531 588 227943 1% /run tmpfs 228531 17 228514 1% /sys/fs/cgroup /dev/mapper/cs-root 8910848 33529 8877319 1% / /dev/sda1 524288 310 523978 1% /boot tmpfs 228531 5 228526 1% /run/user/0
6.其他命令
6.1 [^]–匹配指定范围之外的任意单个字符
-
[root@SYL2 ~]# ls [^0-9] e g i k m o q s u w y f h j l n p r t v x z a: b c d [root@SYL2 ~]# ls [^e..z] 1 3 5 7 9 g i k m o q s u w y 2 4 6 8 f h j l n p r t v x a: b c d [root@SYL2 ~]#
6.2 环境变量
-
PATH 命令搜索路径
-
[root@SYL2 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin [root@SYL2 ~]#
-
-
HISTSIZE 命令历史缓冲区大小
-
[root@SYL2 ~]# echo $HISTSIZE 1000
-
-
SHELL 当前shell
-
[root@SYL2 ~]# echo $SHELL /bin/bash
-
6.3 内置变量
-
RANDOM 保存着0-32768之间的随机数
-
[root@SYL2 ~]# echo $RANDOM 20427 [root@SYL2 ~]# echo $RANDOM 10645 [root@SYL2 ~]# echo $RANDOM 4891 [root@SYL2 ~]# echo $RANDOM 25514
-
6.4 ln 在文件之间建立连接
-
[root@SYL2 ~]# cd bin/ [root@SYL2 bin]# ls lls [root@SYL2 bin]# ln lls 111 [root@SYL2 bin]# ls 111 lls [root@SYL2 bin]# ll -i total 280 34224236 -rwxr-xr-x. 2 root root 143224 Mar 23 14:48 111 34224236 -rwxr-xr-x. 2 root root 143224 Mar 23 14:48 lls [root@SYL2 bin]#
6.5 which 显示指定命令的绝对路径
-
[root@SYL2 ~]# which ls alias ls='ls --color=auto' /usr/bin/ls [root@SYL2 ~]# which rm alias rm='rm -i' /usr/bin/rm [root@SYL2 ~]# which cd /usr/bin/cd [root@SYL2 ~]#
-
- SHELL 当前shell
- ```
[root@SYL2 ~]# echo $SHELL
/bin/bash
```
-
##### 6.3 内置变量
- RANDOM 保存着0-32768之间的随机数
- ```
[root@SYL2 ~]# echo $RANDOM
20427
[root@SYL2 ~]# echo $RANDOM
10645
[root@SYL2 ~]# echo $RANDOM
4891
[root@SYL2 ~]# echo $RANDOM
25514
```
##### 6.4 ln 在文件之间建立连接
- ```
[root@SYL2 ~]# cd bin/
[root@SYL2 bin]# ls
lls
[root@SYL2 bin]# ln lls 111
[root@SYL2 bin]# ls
111 lls
[root@SYL2 bin]# ll -i
total 280
34224236 -rwxr-xr-x. 2 root root 143224 Mar 23 14:48 111
34224236 -rwxr-xr-x. 2 root root 143224 Mar 23 14:48 lls
[root@SYL2 bin]#
6.5 which 显示指定命令的绝对路径
-
[root@SYL2 ~]# which ls alias ls='ls --color=auto' /usr/bin/ls [root@SYL2 ~]# which rm alias rm='rm -i' /usr/bin/rm [root@SYL2 ~]# which cd /usr/bin/cd [root@SYL2 ~]#