天天看點

linux指令

1,ps aux | grep "tomcat"			查找運作的程序

2,find / -name java*				全部查找(java*)檔案

3,cat -n name-file | grep "java"		查找檔案(java)所在行

4,cat -n name-file | tail -n +92 | head -n 20		檢視檔案92行前後20行

5 :set nu 顯示行号

6,:行号  跳轉到指定行号

7,tail -n 20 filename	顯示後20行資料

8,sudo -u bsafe bash	切換basfe帳戶

9,cat textJson_20190216.log | awk -F '\t' '{print $NF}' > result.log	去除檔案中字元"\t"
	方法二:#awk -F "\t" '{print $2}' ./textJson_20190215.log >result.log

10,cat file1 file2 | sort | uniq > fileAll	取出檔案的并集(去重)

11,遠端複制拷貝
$scp local_file remote_username@remote_ip:remote_folder
$scp local_file remote_username@remote_ip:remote_file
$scp local_file remote_ip:remote_folder
$scp local_file remote_ip:remote_file
scp [email protected]:/opt/soft/nginx-0.5.38.tar.gz /opt/soft/

12,字元串切割
awk '{FS=":"}{print $1"\t" $3}' /etc/passwd,使用FS=””,指定分割符,第一行已經讀完,用冒号分割已經來不及了,預設的用空格分割,後面的用冒号分割,在FS之前強制加個BEGIN
***********awk -F '\t' '{print $3}'**********

13,删除指定行	sed -i '1d' <file>

14,删除包含特定字元的行	sed -e '/xxx/d' a1.txt > a2.txt

15,檔案授權(遞歸授權所有檔案)	chown -R testname <filename>

16,壓縮	壓縮方式: 
     tar -zcvf archive_name.tar.gz filename
     解壓縮方式: 
     tar -zxvf archive_name.tar.gz 
	壓縮解壓(zip)
	 zip -r 123.zip 123.txt
	 unzip 123.zip -d ./
	 
17,nohup
	nohup /usr/local/node/bin/node /www/im/chat.js >> /usr/local/node/output.log 2>&1 &
	
18,hadoop執行指令
	hadoop jar /usr/bin/hadoop/software/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.4.jar wordcount /home/testWord /home/output/2

19,替換檔案制定字元
	sed -i "s/tf_ab/tf_qw/g" result.txt
	
20,git指令
    git status
	git add .
	git commit -m "一些資訊"
	git push 倉庫位址
	###分支
	git checkout -b 分支名 #建立分支
	git branch -a 
	git checkout 分支名
	
21,rsync -av  ../log/textJson_$min".log" --port=9215 [email protected]::web_news_database
           
上一篇: linux 指令
下一篇: Linux指令

繼續閱讀