搜尋此網誌

顯示具有 Debian Linux 標籤的文章。 顯示所有文章
顯示具有 Debian Linux 標籤的文章。 顯示所有文章

2017年11月13日 星期一

透過 DU 指令,找出目錄底下體積最大的前 5 個檔案

透過 DU 指令,找出當下目錄底下體積最大的前 5 個檔案

du -h -s * | sort -rn | head -5

如果要查其他目錄,只要修改上述 * 號,例如:

du -h -s /* | sort -rn | head -5



還有更方便的工具,但是需要額外安裝 ncdu

ncdu -q -x

-q Quiet mode, doesn't update the screen 10 times a second
   while scanning, reduces network bandwidth used

-x Don't cross filesystem borders (don't descend into a
   directory which is a mounted disk)




2017年7月13日 星期四

2017年4月27日 星期四

讓 Ubuntu 支援讀寫 exFAT 格式

讓 Ubuntu 支援讀寫 exFAT  格式

sudo apt-get -y install exfat-utils exfat-fuse


例如要存取 USB 外接磁碟

先以 fdisk -l 查出該裝置被分配的編號 /dev/sdf1
然後
mkdir /mnt/usb
mount -v -t auto /dev/sdf1 /mnt/usb


- The End -

2017年3月4日 星期六

mount cifs


mount -t cifs -o username="Username",password="Password" //IP/share /mnt/smb


umount /mnt/smb


- The End -

2017年2月25日 星期六

Linux mount NFS Using TCP

The default transport protocol for NFS is UDP; however, the Red Hat Enterprise Linux 3 kernel includes support for NFS over TCP. To use NFS over TCP, include the -o tcp option to mount when mounting the NFS-exported file system on the client system. For example:

mount -o tcp shadowman.example.com:/misc/export /misc/local

If the NFS mount is specified in /etc/fstab:

server:/usr/local/pub    /pub   nfs    rsize=8192,wsize=8192,timeo=14,intr,tcp


If it is specified in an autofs configuration file:

myproject  -rw,soft,intr,rsize=8192,wsize=8192,tcp penguin.example.net:/proj52


Since the default is UDP, if the -o tcp option is not specified, the NFS-exported file system is accessed via UDP.

The advantages of using TCP include the following:


  • Improved connection durability, thus less NFS stale file handles messages.
  • Performance gain on heavily loaded networks because TCP acknowledges every packet, unlike UDP which only acknowledges completion.
  • TCP has better congestion control than UDP (which has none). On a very congested network, UDP packets are the first types of packet that are dropped. Which means if NFS is writing data (in 8K chunks) all of that 8K has to retransmitted. With TCP because of its reliability, one parts of that 8K data is transmitted at a time.
  • Error detection. When a tcp connection breaks (due to the server going down) the client stops sending data and starts the reconnection process. With UDP, since its connection-less, the client continue to pound the network with data until server comes up.


The main disadvantage is that there is a very small performance hit due to the overhead associated with the TCP protocol.


Source:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/System_Administration_Guide/s1-nfs-mount.html



2017年2月15日 星期三

Ubuntu 文字轉圖形登入


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fxlrg
sudo apt-get install xserver-xorg-core
sudo apt-get install xserver-xorg
sudo apt-get install xorg
sudo apt-get install xorg openbox
sudo apt-get install xauth
sudo apt-get install ubuntu-desktop
sudo apt-get install mate-core mate-desktop-environment mate-notification-daemon

echo mate-session> ~/.xsession
sudo systemctl restart xrdp



2017年2月9日 星期四

vSphere 環境下 UBuntu 網卡

在 vSphere 環境下 ,當 UBuntu 找不到網卡時後,可以輸入
ifconfig -a

系統會顯示 網卡名稱,例如: ens192
編輯  vi /etc/network/interface

固定IP 方式 如以下:
# The primary network interface
auto ens192
#iface ens192 inet dhcp

iface ens192 inet static
address 192.168.103.105
netmask 255.255.0.0
gateway 192.168.1.254

dns-nameservers 192.168.1.100 139.175.1.1 168.95.1.1 8.8.8.8 8.8.4.4

儲存離開
輸入
/etc/init.d/networking restart

查看網路是否恢復啟用

- The End -
 




2017年2月8日 星期三

Ubuntu 捨棄 /etc/resolv.conf

Ubuntu 於 12.04 之後捨棄 /etc/resolv.conf 的設計,每次開機皆會重置此檔案內容。

現在必須編輯 sudo vi /etc/network/interfaces
加入
dns-nameservers 8.8.8.8 8.8.4.4

- The End -



2017年1月20日 星期五

修復centos 7 開機grub失敗

用 Clonezilla 再生龍 製作 centos7 映像檔出來後,還原回去之後卻
出現 symbol grub_xputs not found 這字樣  就停在 grub>

解決方式:

1.先用 centos 開機救援光碟開機進入 linux rescue 救援模式
2.進行以下指令步驟
#chroot /mnt/sysimage (將/mnt/sysimage 設為 root (/))
#sudo su
[root#]grub2-mkconfig -o /boot/grub2/grub.cfg
[root#]grub2-install /dev/sda
exit
exit
reboot


開機之後,可能發現網卡編號已經被 GRUB 修改了,
安裝 NetworkManager-tui 解決網卡設置問題

yum install -y NetworkManager-tui

執行
nmtui


另外有網友還分享了這個也很棒 Super Grub2 Disk

參考原文1
參考原文2
GRUB 設置參考




2017年1月18日 星期三

在Linux 查出Process ID 並作處置

作業系統重新開機後,所安排自動執行的 process id 每次都不同
所以透過以下指令,可以查出來並安排後續處理,
例如,找出 hgtask 這個 process 的 id:

ps ax | grep hgtask | awk '{print $1}' | head -1 > /tmp/hgtask_id
ID=`cut -c 1-6 /tmp/hgtask_id`
echo "HGTASK Process ID:"$ID

就會得到一個數字,後續處理上
例如,對該數字查出總共產生了多少個執行緒數量:

cat /proc/$ID/status | grep Threads > /tmp/hgtask_threads
Num=`cut -c 9-18 /tmp/hgtask_threads`
echo "HGTASK TotaL Threads:"$Num

就會得到一個數字,後續就看怎麼安排處理。

參考

- The End -




2016年12月19日 星期一

改變 MATE UBUNTU 開機自動登入的帳號

編輯
sudo nano /etc/lightdm/lightdm.conf

會看到以下,改變 autologin-user
[SeatDefaults] greeter-session=lightdm-gtk-greeter user-session=mate autologin-user=username


2016年12月9日 星期五

BananaPI UBUNTU 16.04 安裝 MongoDB

先註記一下, MongoDB 最好是跑在 32bits 上
但是我還沒購買 64bits 的Banana PI,所以就先強制安裝 32bits 吧。
因此命令模式執行 mongo client 就會看到溫馨提示32bits有記憶體的限制等等。

開始:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6

注意
Ubuntu 16.04 版本的方式
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

Ubuntu 14.04 版本的方式
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list

然後務必
apt-get update

接下來,安裝
apt-get install -y mongodb mongodb-clients mongodb-server

完成之後,確認服務狀態
service mongodb status

設定開機服務自動啟動
systemctl enable mongodb
systemctl status mongodb

- The End -

2016年12月8日 星期四

解決 SSH 登入時,認證很慢的問題

修改 SSH 設定檔 /etc/ssh/sshd_config

將  #UseDNS yes 修改為  UseDNS no

或自行添加 UseDNS no 這一行

2016年11月15日 星期二

以 cpulimit 限制某些程序爆衝

1. 先安裝
yum -y install cpulimit


2. 限制某個 pid 只能消耗 cpu 60%的資源,
-i 是連同子執行緒一起限制,
-v 是顯示執行狀態

cpulimit -p 20385 -l 60 -i -v


- End -

2016年11月14日 星期一

Linux Command Line 寄信 透過 ssmtp


1. 安裝 ssmtp 套件
yum -y install ssmtp

2. 修改設定
vim /etc/ssmtp/ssmtp.conf

填入
mailhub=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=indy.hgd@gmail.com
AuthPass=XXXXXXXXXXXXXXX
#TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt


3: 指定系統預設發信軟體為 SSMTP
alternatives --config mta


4. 檢查是否正確變更
sendmail -V


5. 寄信方法,在命令列底下,輸入
ssmtp indy.chou@hgdata.com.tw
Subject: This is Subject Line
Email content line 1
Email content line 2
Email content line 3
^d


- END -

搜尋此網誌