码迷,mamicode.com
首页 > 系统相关 > 详细

一些Linux shell

时间:2016-03-16 01:49:55      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:shell

以下shell在centos下使用. 

获取一个压缩软件包的version(版本)

huwei@huwei:/work/lnmp$ ll -a php.tar.gz
-rw-rw-r-- 1 huwei huwei 18355694  3月 15 14:32 php.tar.gz
huwei@huwei:/work/lnmp$ tar -ztf php.tar.gz|tail -1|awk -F‘/‘ ‘{print $1}‘
php-5.6.19


随机密码,对于mysql,不方便使用下划线以及特殊符号,使用mysqldump备份会失败.

passVar=`cat /dev/urandom | tr -dc "a-zA-Z0-9"| fold -w 20 |head -n 1`


检查是否存在mysql用户,如果不存在侧创建

id mysql
        if [ $? -ne 0 ]
        then
                useradd mysql -s /sbin/nologin
                /usr/sbin/useradd mysql -s /sbin/nologin
        fi

通过find命令查找大文件

huwei@huwei:~$ sudo find /home/huwei/ -type f -size +6G -ls
20319458 6479992 -rw-------   1 huwei    huwei    6637486080  3月  2 14:15 /home/huwei/VirtualBox\ VMs/test50/Snapshots/{644badc2-a908-4e74-a2ec-a03f52b21578}.vdi

通过find

本文出自 “海底两万里” 博客,请务必保留此出处http://huwei555.blog.51cto.com/1347480/1751310

一些Linux shell

标签:shell

原文地址:http://huwei555.blog.51cto.com/1347480/1751310

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!