Linux简单命令(三)

    科技2022-07-13  136

    chmod命令:用来变更文件或目录权限 将档案file1.txt设为所有人皆可读取: chmod ugo+r file1.txt /chmod a+r file1.txt 将档案file1.txt与file2.txt设为该档案拥有者,与其所属的同一群体可写入,但其他以外的人不可写入: chmod ug+w,o-w file1.txt file2.txt 将ex1.py设定为只有该档案拥有者可以执行: chmod u+x ex1.py 将目前目录下的所有档案与子目录皆设为任何人可读取: chmod -R a+r* 此外chmod命令也可以用数字来表示权限 其中a,b,c各为一个数字,分别表示user,group,other的权限 r=4,w=2,x=1 若要rwx属性则4+2+1=7; 若要rw-属性则4+2=6; 若要r-x属性则4+1=5; 若要-wx属性则2+1=3 chmod a=rwx file 等于 chmod 777 file 效果相同 chmod ug=rwx,o=x file 等于chmod 771 file

    tar压缩命令: 解压tar包 tar -xvf file.tar 解压tar.gz tar -xzvf file.tar.gz 解压tar.bz2 tar -xjvf file.tar.bz2 解压tar.Z tar -xZvf file.tar 解压rar unrar e file.rar 解压zip unzip file.zip 将目录里所有的jpg文件打包成tar,jpg tar -cvf jpg.tar *.jpg 将目录里所有的jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz tar -czf jpg.tar.gz *.jpg 将目录里所有的jpg文件打包成jpg,tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2 tar -cjf jpg.tar.bz2 *.jpg 将目录里所有的jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z tar -cZf jpg.tar.Z *.jpg

    date命令:显示或设置日期 date -d<字符串>:显示字符串所指的日期时间 date -s<字符串>:设定当前日期时间 date +%y-%m-%d date -s 20201004

    grep命令:搜索符合要求的内容

    Processed: 0.011, SQL: 8