Posts

File count recursively in a directory

Command find DIR_NAME -type f | wc -l

Generate SSH RSA key

Sample ssh-keygen -t rsa

List first/last files in a directory

Sample ls -1t | head -5 ls -1t | tail -5

Fix locale error in Debian OS SSH connection

Solution export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 export LANGUAGE=en_HK.UTF-8 export LANG=en_HK.UTF-8 export LC_ALL=en_HK.UTF-8 locale-gen en_HK.UTF-8 locale-gen en_US.UTF-8 en_HK.ISO-8859-1en_HK.UTF-8 en_US.ISO-8859-1 en_US.ISO-8859-15 en_US.UTF-8 dpkg-reconfigure locales

Silent output in Cron job

Solution xxxxxxx > /dev/null

Error: rm: argument list too long

Solution find . -name "filename*" | xargs mv -t /home/directory find . -name "*.tmp" -delete

LVM partition fdisk a Linux hard-drive

Sample fdisk -l fdisk /dev/sdb root@Mega:~# fdisk /dev/sdb Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2610, default 1): "enter" Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): "enter" Using default value 2610 Command (m for help): t Selected partition 1 Hex code (type L to list codes): 8e Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. root@Mega:~# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created root@Mega:~# vgdisplay --- Volume group --- VG Name Mega VG Size 19.76 GiB root@Mega:~# vgextend Mega /dev/sdb1 Volume group "Mega" successfully extended root@Mega:~# pvscan PV /dev/sda5 VG Mega lvm2 [19.76 GiB / 0 free] PV /dev/sd...