普通用戶下ls查看文件時(shí)顯示顏色
修改當(dāng)前用戶的
.bashrc
文件榜贴,在末尾添加如下語(yǔ)句:
alias ls='ls --color=auto'
去除重復(fù)行慢哈,只保留一行
使用vim或vi命令打開(kāi)要處理的文件
對(duì)文檔數(shù)據(jù)進(jìn)行排序
:sort
執(zhí)行去重命令
g/^(.)\n\1$/d*
文件系統(tǒng)的磁盤(pán)空間占用情況
df -h
查看目錄下文件大小
du -sh *
* 可以替換為指定的文件
du -sh alexai
alexai 為文件名
根據(jù)關(guān)鍵字,提取文件信息
cat log.log |grep 'keyword' > temp.log
將log.log文件中的包含 keyword的行帮匾,寫(xiě)入文件temp.log
根據(jù)正則查描,提取相關(guān)位置前后內(nèi)容
grep -A 5 'parttern' filename > temp.log //匹配行的后5行,并將內(nèi)容輸出到temp.log
grep -B 5 'parttern' filename > temp.log //匹配行的前5行组力,并將內(nèi)容輸出到temp.log
grep -C 5 'parttern' filename > temp.log //匹配行的前后5行省容,并將內(nèi)容輸出到temp.log
grep -5 'parttern' filename > temp.log//匹配行的前后5行 ,并將內(nèi)容輸出到temp.log
查看機(jī)器是否有GPU
lspci |grep -i nvidia
查看GPU占用情況
watch -n 0.1 nvidia-smi
或
nvidia-smi
查看 CUDA 版本
cat /usr/local/cuda/version.txt
查詢程序端口占用情況
1燎字、 查詢某個(gè)程序占用了哪個(gè)端口腥椒,使用命令:
ps -aux | grep 程序名稱(chēng)
例如:查詢java進(jìn)程占用了哪個(gè)端口
ps -aux | grep java
查詢結(jié)果:
[root@localhost Desktop]# ps -aux | grep java
root 3717 0.0 0.0 112672 980 pts/1 S+ 10:11 0:00 grep --color=auto java
2、 查詢某個(gè)端口被哪個(gè)程序占用候衍,我們可以使用命令:
netstat -apn | grep 端口號(hào)
例如:查詢端口5029的占用情況
netstat -anp | grep 5029
查詢結(jié)果:
[root@localhost Desktop]# netstat -anp | grep 5029
tcp 0 0 0.0.0.0:5029 0.0.0.0:* LISTEN 3074/mysqld
開(kāi)放端口和關(guān)閉端口
1笼蛛、 查詢本機(jī)當(dāng)前已經(jīng)啟動(dòng)的網(wǎng)絡(luò)服務(wù)以及端口號(hào)、PID蛉鹿、狀態(tài)等信息滨砍,使用命令
netstat -tunpl
執(zhí)行結(jié)果:
[root@localhost Desktop]# netstat -tunpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1614/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1375/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1372/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1579/master
tcp 0 0 0.0.0.0:5029 0.0.0.0:* LISTEN 3074/mysqld
tcp6 0 0 :::22 :::* LISTEN 1375/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1372/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1579/master
udp 0 0 0.0.0.0:24002 0.0.0.0:* 1099/dhclient
udp 0 0 0.0.0.0:45031 0.0.0.0:* 545/avahi-daemon: r
udp 0 0 192.168.122.1:53 0.0.0.0:* 1614/dnsmasq
udp 0 0 0.0.0.0:34876 0.0.0.0:* 1087/dhclient
udp 0 0 0.0.0.0:67 0.0.0.0:* 1614/dnsmasq
udp 0 0 0.0.0.0:68 0.0.0.0:* 1099/dhclient
udp 0 0 0.0.0.0:68 0.0.0.0:* 1087/dhclient
udp 0 0 0.0.0.0:5353 0.0.0.0:* 545/avahi-daemon: r
udp 0 0 127.0.0.1:323 0.0.0.0:* 528/chronyd
udp6 0 0 :::24002 :::* 1087/dhclient
udp6 0 0 :::15066 :::* 1099/dhclient
udp6 0 0 ::1:323 :::* 528/chronyd
...
2、 查看已經(jīng)開(kāi)放的端口妖异,我們可以執(zhí)行命令
/sbin/iptables -L -n
查詢結(jié)果:
[root@localhost Desktop]# /sbin/iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:67
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
INPUT_direct all -- 0.0.0.0/0 0.0.0.0/0
INPUT_ZONES_SOURCE all -- 0.0.0.0/0 0.0.0.0/0
INPUT_ZONES all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
3惋戏、新增開(kāi)放端口
以開(kāi)放infobright端口5029為例。
方法一:命令行方式
1. 開(kāi)放端口命令:
/sbin/iptables -A INPUT -p tcp --dport 5029 -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp --sport 5029 -j ACCEPT
2.保存:
/e
方法二:配置文件方式
編輯/etc/sysconfig/iptables:
vi /etc/sysconfig/iptables
添加:
iptables -A INPUT -p tcp --dport 5029 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 5029 -j ACCEPT
重啟服務(wù):
/etc/init.d/iptables restart
注意:在RHEL7中他膳,沒(méi)有這個(gè)服務(wù)
查詢某個(gè)路徑下的文件個(gè)數(shù)**
for i in /*; do echo $i; find $i |wc -l|sort -nr; done
未完待續(xù)