1. ls:显示文件
[wyb@localhost tmp]$ ls
a a.txt
[wyb@localhost tmp]$ ls -l
total 4
drwxr-xr-x. 2 wyb root 4096 Apr 17 18:23 a
-rw-r--r--. 1 wyb root 0 Apr 17 18:23 a.txt
[wyb@localhost tmp]$ ls -a
. .. a a.txt .esd-500 .ICE-unix
[wyb@localhost tmp]$ ls -al
total 20
drwxrwxrwt. 5 root root 4096 Apr 17 18:23 .
dr-xr-xr-x. 22 root root 4096 Apr 17 16:31 ..
drwxr-xr-x. 2 wyb root 4096 Apr 17 18:23 a
-rw-r--r--. 1 wyb root 0 Apr 17 18:23 a.txt
drwx------. 2 wyb wyb 4096 Apr 10 19:15 .esd-500
drwxrwxrwt. 2 root root 4096 Apr 17 16:31 .ICE-unix
2. pwd:查看当前工作路径
[wyb@localhost ~]$ pwd
/home/wyb
3. cd:切换目录
[wyb@localhost ~]$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
[wyb@localhost ~]$ cd Desktop/ //相对路径
[wyb@localhost Desktop]$ cd /tmp/a //绝对路径
[wyb@localhost a]$ pwd
/tmp/a
4. mkdir:新建文件夹
[wyb@localhost tmp]$ ls
a a.txt
[wyb@localhost tmp]$ mkdir bbb
[wyb@localhost tmp]$ ls
a a.txt bbb
5. touch/vim:新建文件
[wyb@localhost tmp]$ ls
a a.txt bbb
[wyb@localhost tmp]$ touch bbb.txt
[wyb@localhost tmp]$ ls
a a.txt bbb bbb.txt
5. rm:删除文件
[wyb@localhost tmp]$ ls
a a.txt bbb bbb.txt c.txt
[wyb@localhost tmp]$ rm c.txt //删除文件c.txt
[wyb@localhost tmp]$ ls
a a.txt bbb bbb.txt
[wyb@localhost tmp]$ rm a //删除文件夹a,结果不能删除
rm: cannot remove `a': Is a directory
[wyb@localhost tmp]$ rm -r a //加上-r才能删除文件夹
[wyb@localhost tmp]$ ls
a.txt bbb bbb.txt
6. ifconfig:查看网卡的信息
[wyb@localhost tmp]$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:56:B4:10
inet addr:192.168.63.131 Bcast:192.168.63.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe56:b410/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:67099 errors:0 dropped:0 overruns:0 frame:0
TX packets:34939 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:94042525 (89.6 MiB) TX bytes:1995748 (1.9 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
7. netstat:查找网络连接信息
netstat -l //listen状态的
netstat -an //显示所有的连接信息,且以ip地址代替名称
netstat -t //显示tcp连接信息
netstat -u //显示udp连接信息
LISTENING //监听端口状态
ESTABLSHED //建立连接
CLOSE_WAIT //对方主动断开连接,此时我方就会变为这个状态,我方要调用close()
TIME_WAIT //我方主动调用close(),对方收到后变为CLOSE_WAIT
[root@localhost ~]# netstat -l -n
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address远程 State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 所有ip均可连接22
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 只有127.0.0.1连接25端口
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:631 :::* LISTEN
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 14229 public/cleanup
unix 2 [ ACC ] STREAM LISTENING 14236 private/tlsmgr
unix 2 [ ACC ] STREAM LISTENING 14240 private/rewrite
unix 2 [ ACC ] STREAM LISTENING 14244 private/bounce
unix 2 [ ACC ] STREAM LISTENING 14248 private/defer
8.nslookup:查看DNS信息
nslookup 查看ip和域名的相互映射
nslookup www.baidu.com //返回一些信息
9. ping
ping -c 3 www.baidu.com //指定ping百度3次
10. last:查看近期的登陆信息
[root@localhost ~]# last
10. find:查找文件
which vim //查看可执行文件的位置
*which是通过 PATH环境变量到该路径内查找可执行文件,所以基本的功能是寻找可执行文件*
whereis、locate也可查找文件,它们是使用数据库来搜索数据
find . -name 1.txt //查找当前文件夹及子目录下的1.txt、
find . -name *.txt //使用通配符
find /bin -perm 755 //返回的都是755权限的文件
find /bin -perm 4755 //返回有gid(即s权限)的文件 2是gid
[wyb@localhost tmp]$ sudo find / -name *.log //根目录下查找名字以log结尾的文件
/var/spool/plymouth/boot.log
/var/log/wpa_supplicant.log
/var/log/dracut.log
/var/log/vmware-tools-upgrader.log
[wyb@localhost ~]$ find /bin -perm 755 | xargs ls -al //前一个命令的输出作为后一个命令的输入
-rwxr-xr-x. 1 root root 123 Feb 21 2013 /bin/alsaunmute
-rwxr-xr-x. 1 root root 27776 Jun 22 2012 /bin/arch
-rwxr-xr-x. 1 root root 26264 Jun 22 2012 /bin/basename
-rwxr-xr-x. 1 root root 938768 Feb 21 2013 /bin/bash
-rwxr-xr-x. 1 root root 48568 Jun 22 2012 /bin/cat
-rwxr-xr-x. 1 root root 55472 Jun 22 2012 /bin/chgrp
-rwxr-xr-x. 1 root root 52472 Jun 22 2012 /bin/chmod
11. cat/nl
前者显示
后者显示的同时有行号
[wyb@localhost tmp]$ cat > a.txt //创建文件同时写入数据
this is a.txt
^C
[wyb@localhost tmp]$ cat > b.txt
this is b.txt
^C
[wyb@localhost tmp]$ cat a.txt b.txt > c.txt //合并文件
[wyb@localhost tmp]$ cat c.txt
this is a.txt
this is b.txt
[wyb@localhost tmp]$ cat -n c.txt //获取文件内容切添加行号
1 this is a.txt
2 this is b.txt
12. head
[wyb@localhost tmp]$ head /etc/passwd //默认显示前10行
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
[wyb@localhost tmp]$ head -n 4 /etc/passwd //设置显示前4行
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
[wyb@localhost tmp]$ head -c 100 d.txt //显示前100个字节
1 this is a.txt
2 this is b.txt
this is add content
1 this is a.txt
2 this is b.[wyb@localhost tmp]$
13. tail
[wyb@localhost tmp]$ tail -f a.txt //实时显示文件后10行
this is a.txt
111111
aaaaaa
^C
[wyb@localhost tmp]$ tail -n 3 d.txt //显示文件后3行
1 this is a.txt
2 this is b.txt
this is add content
[wyb@localhost tmp]$ tail -c 100 d.txt //显示后100个字节
2 this is b.txt
this is add content
1 this is a.txt
2 this is b.txt
this is add content
[wyb@localhost tmp]$
14.磁盘
fdisk /dev/sdb
sudo mkfs.ext3 /dev/sdb1
mount -t ext3 -o rw /dev/sdb1 /home/aaa //-o指定权限
15.finger
finger可以查看用户登录情况
16.时间同步
ntpdate time.nist.gov //需要root权限
网友评论