1、显示时间、日期 date cal
# date
2016年 03月 17日 星期四 09:01:53 CST
# cal
三月 2016
日 一 二 三 四 五 六
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
2、系统内置的计算器 bc
# bc
bc1.06.95
Copyright1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This isfree software with ABSOLUTELY NO WARRANTY.
Fordetails type `warranty'.
1+1
2
3、查看当前登录了哪些用户 who
# who
root pts/0 2016-03-17 08:49 (10.10.1.6)
4、查看网络连接状态 netstat
Print network connections, routing tables,interface statistics, masquerade connections, and multicast memberships
如:
netstat -a 看所有信息
netstat -t 查看TCP端口
netstat -r 查看路由表
5、查看进程状态 ps pstree
(1)ps :
report a snapshot of the currentprocesses
ps displays information about a selection of theactive processes. If you want a repetitive update of the selection and thedisplayed information, use top(1) instead.
Note that "ps-aux" is distinct from "ps aux". The POSIX and UNIXstandards require that "ps -aux" print allprocesses owned by a user named "x", as well as printing allprocesses that would be selected by the -a option. If the user named"x" does not exist, this ps may interpret the command as "psaux" instead and print a warning. This behavior is intended to aid in transitioningold scripts and habits. It is fragile, subject to change, and thus should notbe relied upon.
Example:
-a
Select all processes except both session leaders(see getsid(2)) and processes not associated with a terminal.
u
userlistSelect by effective user ID (EUID) or name. This selects the processes whoseeffective user name or ID is in userlist. The effective user ID describes theuser whose file access permissions are used by the process (see geteuid(2)).Identical to -u and --user.
# ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2818 0.0 0.0 4064 532 tty2 Ss+ Feb14 0:00 /sbin/mingetty/dev/tty2
root 2820 0.0 0.0 4064 536 tty3 Ss+ Feb14 0:00 /sbin/mingetty/dev/tty3
root 2822 0.0 0.0 4064 532 tty4 Ss+ Feb14 0:00 /sbin/mingetty/dev/tty4
root 2824 0.0 0.0 4064 532 tty5 Ss+ Feb14 0:00 /sbin/mingetty/dev/tty5
root 2826 0.0 0.0 4064 528 tty6 Ss+ Feb14 0:00 /sbin/mingetty/dev/tty6
root 2852 0.0 0.1 160480 29524 tty1 Ss+ Feb14 1:01 /usr/bin/Xorg :0 -nr-verb
root 114048 0.0 0.0 108468 1940 pts/0 Ss 08:49 0:00 -bash
root 114099 0.0 0.0 143896 3460 pts/0 T 08:53 0:00 vim a
root 114280 0.0 0.0 101124 976 pts/0 S+ 09:22 0:00 man ps
root 114283 0.0 0.0 106092 1152 pts/0 S+ 09:22 0:00 sh -c (cd "/usr/share/man"
root 114284 0.0 0.0 106092 564 pts/0 S+ 09:22 0:00 sh -c (cd "/usr/share/man"
root 114288 0.0 0.0 105444 864 pts/0 S+ 09:22 0:00 /usr/bin/less -is
root 114322 0.0 0.0 108468 1876 pts/1 Ss 09:34 0:00 -bash
root 114839 0.0 0.0 110240 1140 pts/1 R+ 10:18 0:00 ps u
(2)pstree
–p
Show PIDs.PIDs are shown as decimal numbers in parentheses after each process name. –p implicitlydisables compaction.
–n
Sortprocesses with the same ancestor by PID instead of by name. (Numeric sort.)
6、数据同步写回磁盘 sync
内存数据写回,有重要数据的修改,在关机前可以调用,不过shutdown/reboot/halt等命令执行时已经默认调用。
7、查看linux系统版本 lsb_release -a
# lsb_release -a
LSBVersion: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
DistributorID: CentOS
Description: CentOSrelease 6.5 (Final)
Release: 6.5
Codename: Final
8、查看当前目录 pwd 忽略链接,展示真实路径 -P
9、单引号 双引号 变量 不同的效果
[root@server3 tmp]# name=123
[root@server3 tmp]# echo $name
123
[root@server3 tmp]# myname="$name isnanm"
[root@server3 tmp]# echo $myname
123 is nanm
[root@server3 tmp]# myname='$name is nanm'
[root@server3 tmp]# echo $myname
$name is nanm
10、查找 grep
[root@server3 tmp]# alias grep='grep--color=auto'
[root@server3 tmp]# source~/.bashrc
[root@server3 tmp]# grep -A2 -B3-n 'class' a.txt
12-importcom.ocappm.model.BoxData;
13-importcom.ocappm.pub.database.ConnectionSource;
14-
15:publicclass IndexDaoImpl implements IndexDao{
16- private Connection connection = null;
17- private PreparedStatement statement = null;