Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Wednesday, June 16, 2021

Linux查詢目錄大小

 du -chd 1 | sort -h 

這個指令才是把當前路徑中所有目錄所佔用大小做統計並且排序。


Reference:

https://www.mxp.tw/8171/


Monday, September 25, 2017

PDF 處理工具 pdftk in CentOS 7

下載篇:
https://www.linuxglobal.com/pdftk-works-on-centos-7/

指令篇:
http://seisman.info/introduction-to-pdftk.html

Friday, September 22, 2017

install Samba 4.4.4 in CentOS

yum --nogpgcheck localinstall samba-common-libs-4.4.4-14.el7_3.x86_64.rpm samba-libs-4.4.4-14.el7_3.x86_64.rpm samba-common-tools-4.4.4-14.el7_3.x86_64.rpm libsmbclient-4.4.4-14.el7_3.x86_64.rpm samba-client-4.4.4-14.el7_3.x86_64.rpm samba-4.4.4-14.el7_3.x86_64.rpm libwbclient-4.4.4-14.el7_3.x86_64.rpm samba-client-libs-4.4.4-14.el7_3.x86_64.rpm samba-common-4.4.4-14.el7_3.noarch.rpm


CentOS 7更新後的暫純檔位置

/var/cache/yum/x86_64/7/updates/packages

Tuesday, August 29, 2017

crontab usage rule in Linux

1. create new crontab task:
crontab -e
https://code.kpman.cc/2015/02/11/%E5%88%A9%E7%94%A8-crontab-%E4%BE%86%E5%81%9A-Linux-%E5%9B%BA%E5%AE%9A%E6%8E%92%E7%A8%8B/

2. delete crontab task text in "crontab -e":
crontab -r
3. lookup current crontab task in "crontab -e":
crontab -l
4. delete on-going crontab task:
ps -o pid,sess,cmd afx
For example:
(4-1) find the task executed by cron:
 88588  88588 /usr/sbin/crond -n
160149  88588  \_ /usr/sbin/crond -n
134979  88588  \_ /usr/sbin/CROND -n
134982 134982      \_ /bin/sh -c python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1 > ~/run_11ax_txop.log
134984 134982      |   \_ python /dataVol/homes/yarco.yang/omnetpp/inet_11ax/examples/wireless/ieee80211ax/feature_test_script/auto_peak_txop_ps_per0.py 1
170760 134982      |       \_ sh utility_script/vector_filter_fast.sh results/dntp-4STAs-11ax-AMSDU-UDP-AlgoA-4A0B-TXOP-4NSS-4.vec resul ...

(4-2) crontab start executing a python script, you can kill this python script task by
kill -9 134984 

ref: https://superuser.com/questions/232144/how-to-stop-a-currently-running-cron-job/834110

Monday, September 7, 2015

ftp upload script in linux

#!/bin/sh
#!/usr/bin/expect
HOST='xxxxx'
USER='xxxxx'
PASSWD='xxxxx'

if [ $# -ne 1 ]; then
    #echo "$#"
    echo "Usage: ./upload_hwrd.sh [git repository name]"
    exit
fi

# copy INET git repository to HWRD
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /proj/d_01036/repo/
bin
put $1
quit
END_SCRIPT
echo "Copy $1 to /proj/d_01036/repo/ successfully"

exit

Tuesday, August 18, 2015

dynamic watch the log results

When your log continue to generate new results, you can use the following command in Linux console/terminal to see the last results every 1 second


  • watch -n 1 tail [file name]

Tuesday, July 21, 2015

configure the auto-scheduler

crontab -e

// this command in crontab will be executed at 10 PM everyday
* 22 * * * python test.py

// this command in crontab will be executed at every 5 minutes
*/5 * * * * python test.py

crontab -l

//the alert message can check as below
vim /var/spool/mail/ping-chen.lin

Thursday, February 26, 2015

修改root密碼

請使用指令
sudo passwd root

輸入目前帳號的密碼後,在輸入兩次root帳號的密碼即可

Thursday, January 22, 2015

Linux mount網路硬碟

在終端機下以下兩行指令:
sudo mount -t cifs -o username=(帳號),password=(密碼) //網路位址   ~/mnt
sudo tar czf ~/mnt/(網路位址下的檔案路徑) /home/(電腦路徑)

Friday, April 18, 2014

用軟連結(ln -s)來分享Linux資料到Windows的samba上

相信有很多用了samba的人都會有這個小問題,想要不移動檔案但是讓Windows可以參照到Linux下的檔案,經過研究後,其實步驟很簡單,方法如下:

請參考連結
http://blog.ixxoo.me/samba.html

Thursday, April 17, 2014

簡單避免Linux被入侵的方法

設定不許登入的電腦(/etc/hosts.deny):
======================================
正常的情況下
Linux 會先判斷 hosts.allow
檔案中的電腦如果設定為可連線的話
則 hosts.deny 就不會被使用
因此,設定好了 hosts.allow 之後
將 /etc/hosts.deny 設定為『所有電腦都不許登入』

$ sudo nano /etc/hosts.deny
in.telnetd: ALL : Deny
sshd: All: Deny
sendmail: All: Deny

存檔
 禁止 root 帳號透過 ssh 登入
======================================
將 sshd_config 內的 PermitRootLogin 設成 no
$ sudo nano /etc/ssh/sshd_config
PermitRootLogin no

存檔
重開機

Important information for Linux

The system file /etc/passwd contains a database dealing with user accounts. It consists of lines, one per user, that contain the username, encrypted password, user identifier (UID), group identifier (GID), full name, home directory, and default shell. Here’s an example line:

neil:zBqxfqedfpk:500:100:Neil Matthew:/home/neil:/bin/bash

If you write a program that determines the UID of the user who started it, you could extend it to look in the password file to find out the user’s login name and full name. We don’t recommend this because modern UNIX-like systems have moved away from using simple password files to improve system security. Many systems, including Linux, have the option to use shadow password files that don’t contain any useful encrypted password information at all (this is often held in /etc/shadow, a file that ordinary users cannot read).

Additionally, I also suggest that reader can refer to [2] to comprehend the details of shadow file.

Reference:

  1. Neil Matthew and Richard Stones, Beginning Linux Programming, 4/e, Wiley Publishing, Inc, 2007, page 191.
  2. /etc/shadow檔案結構. [Online]. Available: http://linux.vbird.org/linux_basic/0410accountmanager.php#shadow_file