1、ls -l |grep "^-"|wc -l 查看文件夹下文件个数
2、使用scp远程拷贝(前提是可以ssh无秘钥登录),将本地文件远程拷贝到ip中的/usr/test目录下,root为远程主机账号
scp 本地文件路径 root@ip:/usr/test
将远程文件拷贝到本地的/home/test目录下
scp root@ip:文件路径 /home/test
远程拷贝命令
scp -P13722 sftproot@10.0.0.1:/data/sftp/data/stb_pm_20180408_14.txt.gz ./
该命令在本地网上执行,10.0.0.1为远程ip,/data/sftp/data/stb_pm_20180408_14.txt.gz 远程拷贝的源文件路径
3、将目录上传到远程服务器上的home下的test目录
scp -r dir root@ip:/home/test
4、统计文件中第一列不同的值
9_20.csv文件内容格式
jia,1,2
test,1,3
cat 9_20.csv | awk -F "," '{print $1}'|sort| uniq
5、查看系统所有进程
ps aux 或者 ps -eFH
[wds@zdnl-app ~]$ ps -eFH
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
root 2 0 0 0 0 1 Apr11 ? 00:00:01 [kthreadd]
root 3 2 0 0 0 0 Apr11 ? 00:00:09 [migration/0]
root 4 2 0 0 0 0 Apr11 ? 00:13:39 [ksoftirqd/0]
root 5 2 0 0 0 0 Apr11 ? 00:00:00 [stopper/0]
root 6 2 0 0 0 0 Apr11 ? 00:00:27 [watchdog/0]
root 7 2 0 0 0 1 Apr11 ? 00:00:26 [migration/1]
root 8 2 0 0 0 1 Apr11 ? 00:00:00 [stopper/1]
root 9 2 0 0 0 1 Apr11 ? 00:48:45 [ksoftirqd/1]
root 10 2 0 0 0 1 Apr11 ? 00:00:22 [watchdog/1]
root 11 2 0 0 0 2 Apr11 ? 00:00:17 [migration/2]
root 12 2 0 0 0 2 Apr11 ? 00:00:00 [stopper/2]
root 13 2 0 0 0 2 Apr11 ? 00:09:58 [ksoftirqd/2]
root 14 2 0 0 0 2 Apr11 ? 00:00:26 [watchdog/2]
root 15 2 0 0 0 3 Apr11 ? 00:00:34 [migration/3]
root 16 2 0 0 0 3 Apr11 ? 00:00:00 [stopper/3]
root 17 2 0 0 0 3 Apr11 ? 00:08:24 [ksoftirqd/3]
root 18 2 0 0 0 3 Apr11 ? 00:00:20 [watchdog/3]
root 19 2 0 0 0 0 Apr11 ? 00:16:37 [events/0]
root 20 2 0 0 0 1 Apr11 ? 04:03:38 [events/1]
root 21 2 0 0 0 2 Apr11 ? 00:12:21 [events/2]
root 22 2 0 0 0 3 Apr11 ? 10:41:04 [events/3]
root 23 2 0 0 0 0 Apr11 ? 00:00:00 [events/0]
root 24 2 0 0 0 1 Apr11 ? 00:00:00 [events/1]
root 25 2 0 0 0 2 Apr11 ? 00:00:00 [events/2]
root 26 2 0 0 0 3 Apr11 ? 00:00:00 [events/3]
root 27 2 0 0 0 0 Apr11 ? 00:00:00 [events_long/0]
root 28 2 0 0 0 1 Apr11 ? 00:00:00 [events_long/1]
root 29 2 0 0 0 2 Apr11 ? 00:00:00 [events_long/2]
root 30 2 0 0 0 3 Apr11 ? 00:00:00 [events_long/3]
root 31 2 0 0 0 0 Apr11 ? 00:00:00 [events_power_ef]
root 32 2 0 0 0 1 Apr11 ? 00:00:00 [events_power_ef]
root 33 2 0 0 0 2 Apr11 ? 00:00:00 [events_power_ef]
root 34 2 0 0 0 3 Apr11 ? 00:00:00 [events_power_ef]
root 35 2 0 0 0 2 Apr11 ? 00:00:00 [cgroup]
root 36 2 0 0 0 0 Apr11 ? 00:00:00 [khelper]
root 37 2 0 0 0 2 Apr11 ? 00:00:00 [netns]
root 38 2 0 0 0 3 Apr11 ? 00:00:00 [async/mgr]
root 39 2 0 0 0 2 Apr11 ? 00:00:00 [pm]
root 40 2 0 0 0 1 Apr11 ? 00:00:55 [sync_supers]
root 41 2 0 0 0 1 Apr11 ? 00:01:14 [bdi-default]
root 42 2 0 0 0 0 Apr11 ? 00:00:00 [kintegrityd/0]
root 43 2 0 0 0 1 Apr11 ? 00:00:00 [kintegrityd/1]
root 44 2 0 0 0 2 Apr11 ? 00:00:00 [kintegrityd/2]
root 45 2 0 0 0 3 Apr11 ? 00:00:00 [kintegrityd/3]
root 46 2 0 0 0 0 Apr11 ? 00:00:42 [kblockd/0]
root 47 2 0 0 0 1 Apr11 ? 00:00:53 [kblockd/1]
root 48 2 0 0 0 2 Apr11 ? 00:01:03 [kblockd/2]
root 49 2 0 0 0 3 Apr11 ? 00:00:39 [kblockd/3]
root 50 2 0 0 0 0 Apr11 ? 00:00:00 [kacpid]
root 51 2 0 0 0 0 Apr11 ? 00:00:00 [kacpi_notify]
root 52 2 0 0 0 0 Apr11 ? 00:00:00 [kacpi_hotplug]
root 53 2 0 0 0 2 Apr11 ? 00:00:00 [ata_aux]
root 54 2 0 0 0 0 Apr11 ? 01:26:28 [ata_sff/0]
root 55 2 0 0 0 1 Apr11 ? 00:52:43 [ata_sff/1]
root 56 2 0 0 0 2 Apr11 ? 00:08:07 [ata_sff/2]
root 57 2 0 0 0 3 Apr11 ? 00:04:57 [ata_sff/3]
root 58 2 0 0 0 2 Apr11 ? 00:00:00 [ksuspend_usbd]
root 59 2 0 0 0 2 Apr11 ? 00:00:00 [khubd]
root 60 2 0 0 0 1 Apr11 ? 00:00:00 [kseriod]
root 61 2 0 0 0 0 Apr11 ? 00:00:00 [md/0]
root 62 2 0 0 0 1 Apr11 ? 00:00:00 [md/1]
root 63 2 0 0 0 2 Apr11 ? 00:00:00 [md/2]
root 64 2 0 0 0 3 Apr11 ? 00:00:00 [md/3]
root 65 2 0 0 0 0 Apr11 ? 00:00:00 [md_misc/0]
root 66 2 0 0 0 1 Apr11 ? 00:00:00 [md_misc/1]
root 67 2 0 0 0 2 Apr11 ? 00:00:00 [md_misc/2]
root 68 2 0 0 0 3 Apr11 ? 00:00:00 [md_misc/3]
root 69 2 0 0 0 2 Apr11 ? 00:00:00 [linkwatch]
root 71 2 0 0 0 0 Apr11 ? 00:01:12 [khungtaskd]
root 72 2 0 0 0 3 Apr11 ? 00:16:11 [kswapd0]
root 73 2 0 0 0 2 Apr11 ? 00:00:00 [ksmd]
root 74 2 0 0 0 3 Apr11 ? 00:08:10 [khugepaged]
root 75 2 0 0 0 0 Apr11 ? 00:00:00 [aio/0]
root 76 2 0 0 0 1 Apr11 ? 00:00:00 [aio/1]
root 77 2 0 0 0 2 Apr11 ? 00:00:00 [aio/2]
root 78 2 0 0 0 3 Apr11 ? 00:00:00 [aio/3]
root 79 2 0 0 0 0 Apr11 ? 00:00:00 [crypto/0]
root 80 2 0 0 0 1 Apr11 ? 00:00:00 [crypto/1]
root 81 2 0 0 0 2 Apr11 ? 00:00:00 [crypto/2]
root 82 2 0 0 0 3 Apr11 ? 00:00:00 [crypto/3]
root 89 2 0 0 0 0 Apr11 ? 00:00:00 [kthrotld/0]
root 90 2 0 0 0 1 Apr11 ? 00:00:00 [kthrotld/1]
root 91 2 0 0 0 2 Apr11 ? 00:00:00 [kthrotld/2]
root 92 2 0 0 0 3 Apr11 ? 00:00:00 [kthrotld/3]
root 93 2 0 0 0 2 Apr11 ? 00:00:00 [pciehpd]
root 95 2 0 0 0 3 Apr11 ? 00:00:00 [kpsmoused]
root 96 2 0 0 0 2 Apr11 ? 00:00:00 [usbhid_resumer]
root 97 2 0 0 0 3 Apr11 ? 00:00:00 [deferwq]
root 130 2 0 0 0 2 Apr11 ? 00:00:00 [kdmremove]
root 131 2 0 0 0 2 Apr11 ? 00:00:00 [kstriped]
root 258 2 0 0 0 1 Apr11 ? 00:00:00 [scsi_eh_0]
root 260 2 0 0 0 3 Apr11 ? 01:25:06 [scsi_eh_1]
root 444 2 0 0 0 1 Apr11 ? 00:00:00 [scsi_eh_2]
root 445 2 0 0 0 1 Apr11 ? 00:00:00 [vmw_pvscsi_wq_2]
root 619 2 0 0 0 2 Apr11 ? 00:00:00 [kdmflush]
root 621 2 0 0 0 0 Apr11 ? 00:00:00 [kdmflush]
root 687 2 0 0 0 0 Apr11 ? 00:00:03 [jbd2/dm-0-8]
root 688 2 0 0 0 2 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1111 2 0 0 0 3 Apr11 ? 00:05:12 [vmmemctl]
root 1574 2 0 0 0 0 Apr11 ? 00:00:00 [kdmflush]
root 1584 2 0 0 0 1 Apr11 ? 00:00:00 [kdmflush]
root 1586 2 0 0 0 3 Apr11 ? 00:00:00 [kdmflush]
root 1588 2 0 0 0 0 Apr11 ? 00:00:00 [kdmflush]
root 1593 2 0 0 0 2 Apr11 ? 00:00:00 [kdmflush]
root 1596 2 0 0 0 0 Apr11 ? 00:00:00 [kdmflush]
root 1716 2 0 0 0 3 Apr11 ? 00:00:00 [jbd2/sda1-8]
root 1717 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1718 2 0 0 0 2 Apr11 ? 00:00:09 [jbd2/dm-5-8]
root 1719 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1720 2 0 0 0 3 Apr11 ? 00:00:00 [jbd2/dm-3-8]
root 1721 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1722 2 0 0 0 2 Apr11 ? 00:02:06 [jbd2/dm-6-8]
root 1723 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1724 2 0 0 0 2 Apr11 ? 00:00:00 [jbd2/dm-7-8]
root 1725 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1726 2 0 0 0 2 Apr11 ? 00:01:39 [jbd2/dm-4-8]
root 1727 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1728 2 0 0 0 2 Apr11 ? 00:01:20 [jbd2/dm-2-8]
root 1729 2 0 0 0 3 Apr11 ? 00:00:00 [ext4-dio-unwrit]
root 1794 2 0 0 0 3 Apr11 ? 00:00:07 [kauditd]
root 2436 2 0 0 0 0 Apr11 ? 00:00:00 [loop0]
root 2437 2 0 0 0 2 Apr11 ? 00:00:00 [loop1]
root 2440 2 0 0 0 2 Apr11 ? 00:00:00 [kdmflush]
root 2446 2 0 0 0 1 Apr11 ? 00:00:09 [dm_bufio_cache]
root 2449 2 0 0 0 1 Apr11 ? 00:00:00 [kcopyd]
root 2450 2 0 0 0 2 Apr11 ? 00:05:21 [dm-thin]
root 11142 2 0 0 0 1 Jun05 ? 00:02:20 [flush-253:6]
root 28054 2 0 0 0 0 Jun29 ? 00:01:01 [flush-253:4]
root 30611 2 0 0 0 3 Sep29 ? 00:00:03 [flush-253:0]
root 19122 2 0 0 0 2 Oct08 ? 00:00:01 [flush-253:2]
root 17150 2 0 0 0 1 09:45 ? 00:00:00 [flush-253:5]
root 17410 2 0 0 0 0 09:49 ? 00:00:00 [flush-253:7]
root 1 0 0 4841 648 0 Apr11 ? 00:25:29 /sbin/init
root 791 1 0 2849 240 2 Apr11 ? 00:00:00 /sbin/udevd -d
root 1598 791 0 2852 220 1 Apr11 ? 00:00:00 /sbin/udevd -d
root 2438 791 0 2848 216 2 Apr11 ? 00:00:00 /sbin/udevd -d
root 2138 1 0 47436 1512 1 Apr11 ? 03:35:50 /usr/sbin/vmtoolsd
root 2231 1 0 23289 592 0 Apr11 ? 00:00:37 auditd
root 2233 2231 0 20509 520 2 Apr11 ? 00:00:42 /sbin/audispd
root 2235 2233 0 5314 400 0 Apr11 ? 00:00:10 /usr/sbin/sedispatch
root 2255 1 0 62993 5144 3 Apr11 ? 00:03:59 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5
root 2270 1 0 4594 448 1 Apr11 ? 00:54:17 irqbalance --pid=/var/run/irqbalance.pid
dbus 2281 1 0 5458 832 3 Apr11 ? 00:02:14 dbus-daemon --system
68 2301 1 0 9791 1460 0 Apr11 ? 00:01:45 hald
root 2302 2301 0 5100 424 2 Apr11 ? 00:00:00 hald-runner
root 2347 2302 0 5630 360 3 Apr11 ? 00:00:00 hald-addon-input: Listening on /dev/input/event2 /dev/input/event0
root 2348 2302 0 5629 448 3 Apr11 ? 01:51:10 hald-addon-storage: polling /dev/sr0 (every 2 sec)
68 2352 2302 0 4501 384 1 Apr11 ? 00:05:06 /usr/libexec/hald-addon-acpi
ntp 2397 1 0 6629 784 0 Apr11 ? 00:00:31 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g
root 2429 1 0 90861 5380 3 Apr11 ? 02:17:47 /usr/bin/docker -d --exec-driver=lxc --selinux-enabled
root 2500 1 0 1016 204 2 Apr11 tty2 00:00:00 /sbin/mingetty /dev/tty2
root 2502 1 0 1016 204 3 Apr11 tty3 00:00:00 /sbin/mingetty /dev/tty3
root 2510 1 0 1016 204 3 Apr11 tty4 00:00:00 /sbin/mingetty /dev/tty4
root 2513 1 0 1016 204 1 Apr11 tty5 00:00:00 /sbin/mingetty /dev/tty5
root 2519 1 0 1016 204 1 Apr11 tty6 00:00:00 /sbin/mingetty /dev/tty6
root 2620 1 0 521259 1112 2 Apr11 ? 00:00:16 /usr/sbin/console-kit-daemon --no-daemon
root 2695 1 0 12501 1076 2 Apr11 ? 00:00:16 /usr/libexec/devkit-power-daemon
root 2736 1 0 13195 1316 1 Apr11 ? 00:00:36 /usr/libexec/polkit-1/polkitd
rtkit 2747 1 0 42114 384 3 Apr11 ? 00:05:27 /usr/libexec/rtkit-daemon
root 31904 1 0 1016 204 0 May15 tty1 00:00:00 /sbin/mingetty /dev/tty1
root 4496 1 0 6371 476 0 Jun06 ? 00:00:46 /usr/local/openssh/sbin/sshd
root 4919 1 0 6371 476 1 Jun06 ? 00:02:56 /usr/local/openssh/sbin/sshd -p 80
root 22725 4919 0 7004 2508 1 Oct08 ? 00:00:00 sshd: sctele [priv]
sctele 22727 22725 0 7004 1340 2 Oct08 ? 00:00:00 sshd: sctele
root 13494 4919 0 7017 2424 0 08:54 ? 00:00:00 sshd: sctele [priv]
sctele 13496 13494 0 7017 1488 2 08:54 ? 00:00:00 sshd: sctele@pts/3
sctele 13497 13496 0 27116 1876 1 08:54 pts/3 00:00:00 -bash
root 13680 4919 0 7017 2424 0 08:57 ? 00:00:00 sshd: wds [priv]
wds 13682 13680 0 7108 1908 1 08:57 ? 00:00:00 sshd: wds@pts/6
wds 13683 13682 0 27084 1784 0 08:57 pts/6 00:00:00 -bash
wds 17412 13683 0 27586 1168 2 09:49 pts/6 00:00:00 ps -eFH
root 17369 4919 0 7017 2420 2 09:49 ? 00:00:00 sshd: wds [priv]
wds 17371 17369 0 7017 1424 1 09:49 ? 00:00:00 sshd: wds@pts/0
wds 17372 17371 0 27083 1788 0 09:49 pts/0 00:00:00 -bash
wds 17411 17372 0 3758 1280 2 09:49 pts/0 00:00:00 top
root 7291 1 0 5429 520 1 Jun06 ? 00:00:00 xinetd -stayalive -pidfile /var/run/xinetd.pid
root 31987 1 0 49983 4364 2 Jun10 ? 05:15:37 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf
sctele 15938 31987 75 10581896 23169920 1 Oct08 ? 1-10:26:18 java -XX:+UseG1GC -Xms29696M -Xmx29696M -XX:MaxDirectMemorySize=8388607T -Dlog4j.configuration=file:/data/app/flink-1.4.2
root 29181 1 0 2847 4 2 Jun29 ? 00:00:00 /usr/share/metricbeat/bin/metricbeat-god -r / -n -p /var/run/metricbeat.pid -- /usr/share/metricbeat/bin/metricbeat -c /etc/m
root 29182 29181 1 270132 65856 0 Jun29 ? 1-22:21:16 /usr/share/metricbeat/bin/metricbeat -c /etc/metricbeat/metricbeat.yml -path.home /usr/share/metricbeat -path.config /etc
wds 3028 1 0 3758 424 0 Jul11 ? 00:00:00 top
wds 26153 1 0 3758 544 0 Aug30 ? 00:00:21 top
root 30854 1 0 29216 648 2 Sep29 ? 00:00:06 crond
root 4325 1 0 320038 20568 2 Sep29 ? 02:16:33 ./titanagent -d
root 4333 4325 1 22246 1484 1 Sep29 ? 04:23:20 titan_monitor -p 4325 -l 50 -c 150 -g 0
6、查看程序运行的进程号
ps -ef | grep '文件名'
root 8342 6952 24 09:23 pts/9 00:05:17 python3 kafkawritefile.py
第二列是进程号
关闭该进程运行
kill 8342 或者 kill -9 8342
-
ps命令
ps [选项]
下面对命令选项进行说明:
-e 显示所有进程。
-f 全格式。
-h 不显示标题。
-l 长格式。
-w 宽输出。
a 显示终端上的所有进程,包括其他用户的进程。
r 只显示正在运行的进程。
u 以用户为主的格式来显示程序状况。
x 显示所有程序,不以终端机来区分。 -
grep命令
grep [options][options]主要参数:
-c:只输出匹配行的计数。
-I:不区分大 小写(只适用于单字符)。
-h:查询多文件时不显示文件名。
-l:查询多文件时只输出包含匹配字符的文件名。
-n:显示匹配行及 行号。
-s:不显示不存在或无匹配文本的错误信息。
-v:显示不包含匹配文本的所有行。