我的學習筆記(二)
1.複製某資料夾內所有檔案到另一個資料夾
cp -Rf /import/* /home/node4
將import內所有檔案複製到node4
2./bin與/usr/bin的區別
/bin 二進位制可執行命令
/sbin 系統管理命令,這裡存放的是系統管理員使用的管理程式
/usr/bin 眾多的應用程式
/usr/sbin 超級使用者的一些管理程式
3.如果系統不認識某個命令,可以通過yum whatprovides 搜尋安裝包並安裝
4. fdisk可以配置MBR格式; gdisk配置gpt格式, parted可以自己選擇
5.ssh是你連結別人用的 配置檔案是ssh_conf
ssh server是別人連結你用的,配置檔案是sshd_conf
6.crontab 新增定時任務使用指令碼需要用絕對路徑
7.ll顯示的是位元組,可以使用-h引數來提高檔案大小的可讀性,另外ll不是命令,是ls -l的別名
8.掛載windows共享資料夾
mount -t cifs -o username=administrator,password=dddddd //192.168.12.1/note
/note
mount -t cifs -o user=jimmy,password='abc!222' //192.168.1.4/迅雷下載
/mnt/test
如果密碼裡含有特殊符號時,記得前後加上單引號,如'pass!word'
否則,會報如下錯誤
-bash: !222: event not found
9.很多Linux distribution使用udev動態管理裝置檔案,並根據裝置的資訊對其進行持久化命名
一般來說 , 對應關係應該記錄在 /etc/udev/rules.d/70-persistent-net.rules
10.檢視某埠被什麼程式佔用
netstat -alp |grep 5900
或者程式使用了哪些埠
netstat -alp |grep vnc
11.關閉防火牆
centos 7: systemctl stop firewalld.service #停止 systemctl disable firewalld.service #禁用 之前的版本: service iptables stop #停止 chkconfig iptables off #禁用
12.關閉selinux
vi /etc/sysconfig/selinux
SELINUX=disabled
centos7的檔案路徑有些許變化,如下:
vi /etc/selinux/config
13.結束某個程序或任務
a.
ps aux 檢視PID
kill -9 1348
b.
jobs 檢視後臺任務
[[email protected] ~]# jobs
[1]+ Stopped find a.txt /
[[email protected] ~]# kill %1
[1]+ Stopped find a.txt /
14.centos7設定主機名
hostnamectl set-hostname centos7.test.com
記得再編輯一下hosts檔案
15.快速對應物理網絡卡與系統網絡卡編號
比如當你無法確認eth0對應的是哪塊網絡卡時,一般都是通過插拔網線來確認的吧,反正我是這麼幹過
其實可以通過以下命令快速識別
ethtool --identify eth0 20
這個命令的意思就是讓eth0的網絡卡燈亮20秒
還有一個選項
ethtool -p eth0 20
意思是讓eth0的網絡卡燈閃20秒,哪塊網絡卡的燈在閃,哪塊就對應eth0
16.檢視檔案行數
wc -l /etc/abc.conf //顯示該檔案有多少行
-c以位元組數顯示,-w以字數顯示
17.使用cat合併檔案
cat a.txt >> b.txt //把a.txt的內容追加到b.txt後面
cat a.txt > b.txt //用a.txt的內容覆蓋b.txt的內容
18. ~/的含義
~代表你的主目錄,例如你的使用者名稱為tom,那麼~/代表/home/tom/
19.FTP架設
20.檢視伺服器報錯情況
grep error /var/log/messages
21.SecureFX顯示隱藏檔案
勾選view---Dot files
22.簡易http伺服器搭建
yum install httpd -y
service httpd start
chkconfig httpd on
網頁檔案預設存放目錄/var/www/html
建立檔案進行測試
vi /var/www/html/index.html
一些相關設定引數:
Apache主配置檔案:/etc/httpd/conf/httpd.conf
ServerRoot "/etc/httpd" #用於指定Apache的執行目錄
Listen 80 # 監聽埠
User apache #執行apache程式的使用者和組
Group apache
ServerAdmin [email protected] #管理員郵箱
DocumentRoot "/var/www/html" #網頁檔案的存放目錄
<Directory "/var/www/html"> #<Directory>語句塊自定義目錄許可權
Require all granted
</Directory>
ErrorLog "logs/error_log" #錯誤日誌存放位置
AddDefaultCharset UTF-8 #預設支援的語言
IncludeOptional conf.d/*.conf #載入其它配置檔案
DirectoryIndex index.html #預設主頁名稱
進階設定:
23.MySQL相關文章
24.NFS伺服器簡易搭建
yum install nfs-utils -y
service rpcbind start //centos6之前的版本此服務名為portmap
service nfs start //centos7中服務名為nfs-server
chkconfig rpcbind on
chkconfig nfs on
編輯配置檔案
vi /etc/sysconfig/nfs
在文末新增如下內容:
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
RQUOTAD_PORT=875
MOUNTD_PORT=892
STATD_PORT=662
STATD_OUTGOING_PORT=2020
RPCNFSDARGS="-N 4"
建立輸出資料夾
mkdir /data
chown 65534.65534 data //65534為預設的匿名使用者和匿名組的ID
編輯輸出目錄配置檔案
vi /etc/exports
/data *(rw,sync,no_subtree_check,all_squash) //anonuid和anongid未指定的話,預設為65534
service nfs restart
客戶端掛載測試
臨時掛載
[[email protected] mnt]# mount -t nfs 192.168.1.20:/data /mnt/nfs
mount: 檔案系統型別錯誤、選項錯誤、192.168.1.20:/data 上有壞超級塊、
缺少內碼表或助手程式,或其他錯誤
(對某些檔案系統(如 nfs、cifs) 您可能需要
一款 /sbin/mount.<型別> 助手程式)
有些情況下在 syslog 中可以找到一些有用資訊- 請嘗試
dmesg | tail 這樣的命令看看。
[[email protected] mnt]# yum install nfs-utils -y //出現上面這種報錯的話,需要安裝一下nfs
如果掛載成功後,沒有寫入許可權的話,那就是伺服器端許可權配置有問題,需重新檢查
建議的永久掛載方式:
vi /etc/fstab
192.168.1.20:/data /mnt/nfs nfs soft,intr,rsize=8192,wsize=8192
0 0
mount -a
25.samba伺服器簡易配置
yum install samba -y
[[email protected] ~]# service smb start
啟動 SMB 服務: [確定]
[[email protected] ~]# service nmb start
啟動 NMB 服務: [確定]
[[email protected] ~]# chkconfig smb on
[[email protected] ~]# chkconfig nmb on
vi /etc/samba/smb.conf
security = share
load printers = no
註釋掉預設的home和printers
增加
[test]
comment = test
path = /test
writable = yes
browseable = yes
guest ok = yes
printable = no
[[email protected] samba]# testparm //使用此命令檢查配置檔案是否有誤
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[test]"
WARNING: The security=share option is deprecated
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
security = SHARE
log file = /var/log/samba/log.%m
max log size = 50
client signing = required
idmap config * : backend = tdb
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
cups options = raw
browseable = No
[test]
comment = test
path = /test
read only = No
guest ok = Yes
browseable = Yes
loaded service file OK.說明配置檔案沒有問題
service smb restart;service nmb restart
chown -R nobody:nobody /test //否則匿名使用者沒有寫入許可權
然後就可以用客戶端訪問測試一下。
win客戶端比較簡單
linux客戶端如下:
yum install samba-client
[[email protected] ~]# smbclient -L 192.168.1.20 -N //檢視samba共享,-N意為不需要密碼
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-44.el6_9]
Sharename Type Comment
--------- ---- -------
test Disk test
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-44.el6_9]
Server Comment
--------- -------
BAINUO Samba Server Version 3.6.23-44.el6_9
Workgroup Master
--------- -------
MYGROUP BAINUO
[[email protected] ~]# smbclient //192.168.1.20/test -N //連線到samba
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-44.el6_9]
Server not using user level security and no password supplied.
smb: \> ?
臨時掛載方法
[[email protected] mnt]# mount -t cifs //192.168.1.20/test /mnt/smb
mount: 檔案系統型別錯誤、選項錯誤、//192.168.1.20/test 上有壞超級塊、
缺少內碼表或助手程式,或其他錯誤
(對某些檔案系統(如 nfs、cifs) 您可能需要
一款 /sbin/mount.<型別> 助手程式)
有些情況下在 syslog 中可以找到一些有用資訊- 請嘗試
dmesg | tail 這樣的命令看看。
如果出現以上錯誤yum install cifs-utils
[[email protected] mnt]# mount -t cifs //192.168.1.20/test /mnt/smb
Password for [email protected]//192.168.1.20/test:
如果不想跳出輸密碼的步驟,如下
[[email protected] ~]# mount -t cifs //192.168.1.20/test /mnt/smb -o guest
其中-t cifs意義為使用SMB檔案系統,-o guest意義為匿名訪問,即使用guest來賓賬戶,之後不會再要求輸入密碼。命令執行完畢後即將遠端主機上的Public目錄掛載到本地的/mnt/samba目錄。開機自動掛載方法:
vi /etc/fstab
//192.168.1.20/test /mnt/smb cifs guest 0 0
如果是有使用者名稱密碼的呢,方法如下
//192.168.1.20/test /mnt/smb cifs username=abc,password=123456 0 0
相關文章:
26.關於dig 命令檢視域名的解析過程:
dig www.xxx.com +trace
27.有時候ssh連線很慢,是因為開啟了dns反向查詢,關閉即可
[[email protected] ~]# vi /etc/ssh/sshd_config
找到#UseDNS yes 去掉註釋,將yes改為no
重啟sshd服務即可
28.DNS簡易搭建