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

linux常用命令

时间:2016-12-23 18:40:53      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:磁盘   服务   集锦   vim   ext   rem   时间   mat   shel   

有一部分linux命令已经很熟了,就不多列出来,就记录一些可能用的比较多的,自己不熟的,仅服务于自己!

1、finger: 显示系统用户信息。

The finger displays information about the system users.
root@kali:~# finger root
Login: root                       Name: root
Directory: /root                        Shell: /bin/bash
On since Thu Dec 15 19:57 (EST) on tty2 from :0
   18 minutes 43 seconds idle
No mail.
No Plan.

2、whereis: 查找指定的二进制文件,源文件和手动文件命令名称。

whereis locates the binary, source and manual files for  the  specified command  names.
root@kali:~# whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
lz@ubuntu:~/test$ which ls
/bin/ls

3、查看环境变量

root@kali:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

4、链接ln

技术分享

 5、计算文件中的行数、字数、字节数: wc

-c, --bytes            print the byte counts
-m, --chars            print the character counts
-l, --lines            print the newline counts
      --files0-from=F    read input from the files specified by
                           NUL-terminated names in file F;
                           If F is - then read names from standard input
-L, --max-line-length  print the maximum display width
-w, --words            print the word counts

6、正则搜索: grep

Globally search a Regular Expression and Print
ls -l | grep ‘^d‘  只把目录列出来

7、开机自启动: chkconfig

chkconfig --list       这个命令会列出所有的服务项
chkconfig mysql on      设置开机启动
chkconfig iptables on   防火墙

8、查看文件: vi、vim、cat、nl、less、more、

cat -n 1.txt    查看文件内容,显示行号,顺序读
tac -n 1.txt    查看文件内容,显示行号,逆序读
head -n 3 1.txt  查看前三行的内容
tail -n 3 1.txt  查看后三行的内容

9、设置、查看文件隐藏属性: chattr、lsattr

lz@ubuntu:~/test$ ls
lz@ubuntu:~/test$ > 1
lz@ubuntu:~/test$ sudo chattr +i 1    #为文件1增加隐藏属性
lz@ubuntu:~/test$ lsattr 1          #查看文件的隐藏属性
----i--------e- 1
lz@ubuntu:~/test$ sudo rm 1         #即使是root用户也不能删除
rm: cannot remove `1‘: Operation not permitted
lz@ubuntu:~/test$ sudo chattr -i 1     #需要先删除隐藏属性
lz@ubuntu:~/test$ lsattr 1
-------------e- 1
lz@ubuntu:~/test$ rm 1
lz@ubuntu:~/test$ ls
lz@ubuntu:~/test$ 

10、查看文件类型: file

lz@ubuntu:~/test$ file 1
1: ASCII text

 

 

小命令集锦:

date     显示时间
cal      显示日历
bc       简易计算器
sync     系统同步写入磁盘

 

linux常用命令

标签:磁盘   服务   集锦   vim   ext   rem   时间   mat   shel   

原文地址:http://www.cnblogs.com/Hi-blog/p/6185649.html

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