linux常用命令
来源:互联网 发布:linux系统安全 编辑:程序博客网 时间:2024/05/16 16:02
lsb_release -a
/proc/version
uname -a
/etc/issue
查看版本
grep -F MASQUERADE -R /path
find /your/path -type f -print | xargs grep MASQUERADE
查找文件
ls|while read line ; do mv $line $line.txt; done
dmidecode |more
查看硬件配置
echo 222222|passwd –stdin root
linux下非交互情况修改密码
cp ./*/*attch* /testout_attch/
使用通配符对文件操作
paste -d "\n" *.txt > z
合并所有txt文档到z文件(采用\n分割)
pkill -kill -t pts/3
踢掉用户
xargs
对输入执行命令操作
find /tmp -name core -type f -print | xargs /bin/rm -f
Find files named core in or below the directory /tmp and delete them. Note that this will work incorrectly if there are any filenames containing newlines or spaces.
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
Find files named core in or below the directory /tmp and delete them, processing filenames in such a way that file or directory names containing spaces or newlines are correctly handled.
find -type f -mtime 0|xargs -i cp {} /check/
ls|xargs -i rm -rf {}
删除文件
ls|xargs -i mv {} {}.old
文件改名
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin
/usr/kerberos/bin:/usr/local/sbin
以:分割,去第二个第四个
head/tail
列举文件头尾信息
tail -100 messages|head 10
messages文件中后100行中前10行
head -n100 messages|tail -10
messages文件中前100行中后10行
tail -f
刷新显示
diff
文件(夹)比较
diff -ruN /tmp/file1.txt /tmp/file2.txt > /tmp/file.diff
生成了一个 file2 相对 file1 的差异文件(补丁)
打补丁:cd /tmp; patch -p1 < file.diff
diff -ruN /tmp/path1 /tmp/path2 > /tmp/path.diff
目录比较
diff -rq -x .svn dirA/ dirB/
diff中递归比较带子目录的源码使用-r选项,只打印文件名使用-q选项。要排除一些目录或者文件,不参与比较,可以使用-x选项。比如通常我们不比较版本代码中的.svn中的文件。
rpm
rpm -qa | grep
查看是否安装
rpm -ivh (–nodeps) x.rpm
安装x软件包
rpm -e(--erase) --test -vv --force
卸载软件包
rpm -Uvh x.rpm
rpm -Fvh x.rpm
升级安装 Uvh 未安装则安装,安装过则升级;Fvh 未安装则不安装,安装过则升级
–nodeps 取消关联性 --test测试 -vv显示过程 --force强制
history
(export HISTTIMEFORMAT='%F %T '增加环境变量显示时间)
history -c
du
检测文件空间
du --max-depth=N -h(--human-readable)
du -a(all)b(bytes) = ll
find
查找
find -anewer
寻找比xx新的文件(touch -d xx)
find -exec command "{}"
配合find运行command (find .-name '*.zip' -exec unzip "{}"\;)
grep -rn "string" <dir>
查找特定字符串的文件
tar命令
-c:压缩
-x:解压
-t:查看内容
-r:向压缩归档文件末尾追加文件
-u:更新原压缩包中的文件
-z:有gzip属性的
-j:有bz2属性的
-Z:有compress属性的
-v:显示所有过程
-O:将文件解开到标准输出
tar -zxvf
压缩
tar -zcvf xx.tar.gz xx/
解压
tar -zcvPf /webback/$stmp/web.tar.gz /var/www/html/web/
备份
tar -zcvf test.tar.gz --exclude=c --exclude=d./path
or
tar -zcvf test.tar.gz --exclude=path/c --exclude=pach/d ./path
打包path目录中出去文件c和d
tar cvzpf - somedir | split -d -b 500m
tar分卷压缩:-d不是split的选项,是shell的选项,表示将tar命令的输出作为split的输入
cat x* > mytarfile.tar.gz
tar多卷合并
ls --full-time
显示文件被修改的详细时间,包括年月日时分秒,还有时区
mysqldump
mysqldump --opt phsfront -u root -psig1000|gzip>/webback/$stmp/phsfront.gz
mysqldump --opt phsurl -u root -psig1000|gzip>/webback/$stmp/phsurl.gz
mysql备份
yast2
SUSE
常用命令
> open addr > user > pass > ls > dir > pwd > lcd > mput > mget > bye.
restart 12384
上传续传
put file
下传续传
$reget remote-file [local-file]
如果local-file存在,则从上次传输中断处续传
HOST='xx.xx.xx.xx'
USER='user'
PASSWD='passwd'
FILE='yourfile'
ftp -n $HOST << END_SCRIPT
quote USER $USER
quote PASS $PASSWD
bin
prompt
get(/put) $FILE
quit
END_SCRIPT
exit 0
在shell中使用ftp,避免交互
while [ 1 ]; do ifconfig eth0|grep -o 'TX bytes:[0-9]\{9\}'; sleep 10;done
- 【linux 常用命令】常用命令整理
- linux常用命令
- Linux常用命令
- LINUX 常用命令
- linux常用命令
- Linux 常用命令
- Linux 常用命令
- Linux常用命令
- LINUX常用命令
- Linux 常用命令
- linux常用命令
- Linux常用命令
- Linux常用命令
- Linux 常用命令
- Linux常用命令
- Linux 常用命令
- Linux 常用命令!
- Linux 常用命令
- linux 下获取当前网络连接状态的两种方法
- C++字符串:string and wstring的区别
- Android系统的改进(八)-- 当把手机当作存储介质连到电脑后,如果指定的铃声在存储卡上,指定的歌曲铃声消失,恢复默认
- log4j logback slf4j项目配置中的简单总结
- vs2012 error c4996: 'fopen': This function or variable may be unsafe
- linux常用命令
- iptables 指令
- 小牛的 JavaScript项目
- amqp协议与php下的rabbitMQ
- 亲测 OK6410 dnw下载驱动 win7 x64位
- google chrome 离线安装插件包
- nfs:server 172.168.1.22 not responding,still trying问题解决方法 平台为RealARM 210平台
- c# linq如何进行降序以及按优先级排序
- SSH原理探析与Linux下SSH命令使用方法详解