04-Linux常用命令四&五

1.權限

[root@hadoop000 ~]# ll

total 108

-rw-r--r--. 1 root root? ? 0 May? 2 21:12 20180502.log

-rw-------. 1 root root? 1382 Apr 28 05:21 anaconda-ks.cfg

drwxr-xr-x. 3 root root? 4096 Apr 27 22:37 Desktop

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Documents

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Downloads

-rw-r--r--. 1 root root 49565 Apr 28 05:20 install.log

-rw-r--r--. 1 root root 10033 Apr 28 05:16 install.log.syslog

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Music

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Pictures

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Public

drwxr-xr-x. 3 root root? 4096 May? 2 22:20 ruoze

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Templates

drwxr-xr-x. 2 root root? 4096 Apr 27 21:40 Videos

[root@hadoop000 ~]#

讀:? ? r 4

寫:? ? w 2

執(zhí)行:? x 1? shell腳本

無權限:-

第一列 drwxr-xr-x

第一個: d文件夾 -文件? l連接

rwx r-x r-x: 三組

? ? ? ? ? 第一組: rwx 7? 代表root用戶對這個文件或文件夾的權限

? 第二組: r-x 5? 代表root用戶組的所有用戶對這個文件或文件夾的權限

? ? ? ? ? 第三組: r-x 5? 代表其他組的所有用戶對這個文件或文件夾的權限

第三列: 所屬的用戶root

第四列:所屬的組root

Permission denied? hadoop

修改文件和文件夾的權限

chmod 777 xxx.log?

chmod -R 755 xxxdir

chmod -R 755 xxxdir/*

修改文件和文件夾的所屬的用戶和用戶組

chown jepson:jepson xxx.log

chown -R jepson:jepson xxxdir

chown -R jepson:jepson xxxdir/*

xxx服務 安裝目錄的 xxxuser:xxxuser

可執(zhí)行: 針對于shell腳本

chmod 764 date.sh 只對所屬的用戶

chmod +x? date.sh 所有的用戶

2.yum

yum --help 命令幫助格式

yum -y install httpd

[root@hadoop000 ~]# netstat -nlp|grep 2525

tcp? ? ? ? 0? ? ? 0 :::80? ? ? ? ? ? ? ? :::*? ? ? ? ? ? ? ? ? ? ? ? LISTEN? ? ? 2525/httpd?

:::80?

127.0.0.1:80

0.0.0.0:80

192.168.137.251:80

timeout 去查看服務的端口號對應的ip

ping 192.168.137.251

[root@hadoop000 ~]# yum install telnet

https://jingyan.baidu.com/article/95c9d20d96ba4aec4f756154.html

[root@hadoop000 ~]# which telnet

/usr/bin/telnet

[root@hadoop000 ~]# telnet 192.168.137.251 80

Trying 192.168.137.251...

Connected to 192.168.137.251.

Escape character is '^]'.

^Z^X^C^Z

Connection closed by foreign host.

[root@hadoop000 ~]#

[root@hadoop000 ~]#

[root@hadoop000 ~]#

[root@hadoop000 ~]# telnet 192.168.137.251 808

Trying 192.168.137.251...

telnet: connect to address 192.168.137.251: Connection refused

[root@hadoop000 ~]#

卸載:

[root@hadoop000 ~]# rpm -qa |grep http

httpd-tools-2.2.15-60.el6.centos.6.x86_64

httpd-2.2.15-60.el6.centos.6.x86_64

[root@hadoop000 ~]# rpm --nodeps -e httpd-2.2.15-60.el6.centos.6.x86_64

[root@hadoop000 ~]#

拓展: CentOS6.x使用163和epel yum源的選擇

http://blog.itpub.net/30089851/viewspace-2130239/

3.找命令或者shell腳本

[root@hadoop000 ~]# which java

/usr/bin/java

[root@hadoop000 ~]# locate java

[root@hadoop000 ~]#

4.搜索

find / -name '*abc*'? ? ? 全文

find /tmp -name '*abc*'? 指定目錄

find ./ -name '*hadoop*'? 當前目錄

5.vi

命令模式: i鍵進入編輯 或者 shift+: 進入尾行模式

gg 第一行的第一個字符

G? 最后一行的第一個字符

shift +$ 行尾

dd 刪除當前行

dG 刪除光標以下的所有行

ndd 刪除光標以下的n行

場景: 清空一個文件

? ? ? echo '' > xxx.log

? ? ? cat /dev/null > xxx.log

? ? ? vi:? 1.gg?

? ? ? ? ? 2.dG

編輯模式: esc退出到命令模式

尾行模式:

? ? :q? 退出

? ? :q! 強制退出

? ? :wq 保存退出

? ? :wq! 強制保持退出

? ? :/內(nèi)容? n向下 N向上

? ? 行號

? ? :set nu

? ? :set nonu

? ? 跳轉第N行

? ? :n


6.查看硬盤 內(nèi)存 系統(tǒng)情況

df -h

free -m

top

7.壓縮 tar

Examples:

? tar -cf archive.tar foo bar? # Create archive.tar from files foo and bar.

? tar -tvf archive.tar? ? ? ? # List all files in archive.tar verbosely.

? tar -xf archive.tar? ? ? ? ? # Extract all files from archive.tar.


? [root@hadoop000 ~]#? ? tar -czf ruoze.tar.gz? ruoze/*? 壓縮

? [root@hadoop000 test]# tar -xzvf ruoze.tar.gz? ? ? 解壓

8.壓縮 zip

zip -r ruoze.zip ruoze/*

unzip ruoze.zip

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容