基础常用命令

发布时间:2016-12-11 16:03:37 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"基础常用命令",主要涉及到基础常用命令方面的内容,对于基础常用命令感兴趣的同学可以参考一下。

1. mv (移动多个文件,重命名文件) [[email protected] ~]# ls anaconda-ks.cfg  install.log         name2.txt  test error.log        install.log.syslog  name.txt [[email protected] ~]# mv name2.txt name.txt test/ [[email protected] ~]# ls -l test total 8 -rw-r--r--. 1 root root  0 Aug 10 01:36 name -rw-r--r--. 1 root root 22 Aug 10 01:29 name2.txt -rw-r--r--. 1 root root 22 Aug 10 01:21 name.txt [[email protected] ~]#  cd test [[email protected] test]# ls name  name2.txt  name.txt [[email protected] test]# mv name newname [[email protected] test]# ls name2.txt  name.txt  newname 2. cp( -R 递归拷贝(注意大写) ,拷贝重命名) [[email protected] ~]# ls -lh total 28K -rw-------. 1 root root 1.1K Aug  6 09:26 anaconda-ks.cfg -rw-r--r--. 1 root root   58 Aug 10 01:26 error.log -rw-r--r--. 1 root root 8.6K Aug  6 09:26 install.log -rw-r--r--. 1 root root 3.1K Aug  6 09:24 install.log.syslog drwxr-xr-x. 2 root root 4.0K Aug 10 01:47 test [[email protected] ~]# cp -R test file/ [[email protected] ~]# ls -lh total 32K -rw-------. 1 root root 1.1K Aug  6 09:26 anaconda-ks.cfg -rw-r--r--. 1 root root   58 Aug 10 01:26 error.log drwxr-xr-x. 2 root root 4.0K Aug 10 01:49 file -rw-r--r--. 1 root root 8.6K Aug  6 09:26 install.log -rw-r--r--. 1 root root 3.1K Aug  6 09:24 install.log.syslog drwxr-xr-x. 2 root root 4.0K Aug 10 01:47 test [[email protected] ~]# cd file [[email protected] file]# ls -lh total 8.0K -rw-r--r--. 1 root root 22 Aug 10 01:49 name2.txt -rw-r--r--. 1 root root 22 Aug 10 01:49 name.txt -rw-r--r--. 1 root root  0 Aug 10 01:49 newname [[email protected] file]# cp newname newname2 [[email protected] file]# ls name2.txt  name.txt  newname  newname2 3.rm     -f 直接删除不给提示    -r 递归删除目录 4. file 查看文件类型    [[email protected] file]# file name.txt    name.txt: ASCII text 5. cat 命令显示控制字符,在从其他系统拷贝过来的文档中常遇到控制字符 [[email protected] file]# cat -v name.txt my name is weihongrao 6. 查看文本中最后N行的内容 [[email protected] file]# tail -1  name.txt my name is weihongrao 7. head (和tail 相反,但是都是默认显示10行) [[email protected] file]# head -1 name.txt my name is weihongrao 8. more 和less(都是q退出) [[email protected] file]# more name.txt my name is weihongrao [[email protected] file]# less name.txt [[email protected] file]# 9.查看文件时间戳 [[email protected] file]# stat name.txt   File: `name.txt'   Size: 22              Blocks: 8          IO Block: 4096   regular file Device: fd00h/64768d    Inode: 267303      Links: 1 Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root) Access: 2013-08-10 01:53:26.354993417 -0400 Modify: 2013-08-10 01:49:06.976093595 -0400 Change: 2013-08-10 01:49:06.976093595 -0400 [[email protected] file]# 10 wc 统计命令 [[email protected] file]# wc name.txt  1  4 22 name.txt 11.查看在线用户 [[email protected] file]# w  02:55:36 up  2:00,  2 users,  load average: 0.00, 0.00, 0.00 USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT root     tty1     -                00:55    1:59m  0.07s  0.07s -bash root     pts/0    192.168.1.103    00:56    1.00s  0.60s  0.12s w [[email protected] file]# 12.查看命令所在的目录 [[email protected] file]# whereis iptables iptables: /sbin/iptables /usr/share/man/man8/iptables.8.gz [[email protected] file]# which iptabels /usr/bin/which: no iptabels in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin) 13.echo 输出转义 [[email protected] file]# echo "my name is :\n weihongrao" my name is :\n weihongrao [[email protected] file]# echo -e "my name is :\n weihongrao" my name is :  weihongrao 另一种用法:以标准错误输出(shell脚本中) [[email protected] file]# echo "date format is wrong" 1>&2 date format is wrong 14 tee [[email protected] file]# echo "i love you" | tee test.txt i love you [[email protected] file]# cat test.txt i love you [[email protected] file]#

上一篇:javascript深入了解匿名函数和闭包
下一篇:linux command Line and shell script bible(笔记五)

相关文章

关键词: 基础常用命令

相关评论