Andrew's Personal Linux Note (keep updating)

Words
255
Reading
2 min
9y
Listen to this post
~2 min

1. Andrew's Linux Note

1.1. Disk operation

1.1.1. copy folder content to another directory

cp -avr /source /target

-a : Preserve the specified attributes such as directory an file mode, ownership, timestamps, if possible additional attributes: context, links, xattr, all.
-v : Explain what is being done.
-r : Copy directories recursively.

1.1.2. How to check disk temperature.

sudo hddtemp /dev/sd{a,b,c,d,e,f,g,h,i}

1.2. Operation

1.2.1. enable ssh

sudo apt-get install openssh-server openssh-client

1.2.2. Check openning port

1.2.3. Mount and Unmount a usb drive

Remember that a file system cannot be in use when it is unmounted, otherwise umount will give an error. If you know it is safe to unmount a file system you can use:

mount

sudo mount /dev/sda1 /mnt

umount

sudo umount -l /mountpoint

power off

udisksctl power-off -b /dev/sda

eject

sudo eject /dev/hdc

1.2.4. Test disk speed

sudo hdparm -Tt /dev/sda

1.2.5. Check disk io status

#install
sudo apt install sysstat
#run, 10 means seconds
iostat -d 10 /dev/sda1

1.2.6. Check cpu temperature

#install 
sudo apt install lm-sensors
#detect
sudo sensors-detect
#run service
sudo service kmod start
#get temperature
sensors

1.2.7. check running services/process

>pstree 

1.2.8. list all listenning port

netstat -plntu

1.2.9. remove apt installed software

sudo apt remove package* --purge
#remove all auto installed dependencies
sudo apt autoremove

#remove some directories 
rm -r -f /var/lib/mongodb/
rm -r -f /var/log/mongodb/

1.2.10. show cpu temperature and control fan

sudo apt-get install lm-sensors 
sudo sensors-detect
sudo service kmod start
sensors
sudo apt-get install fancontrol

1.3. Useful Apps

1.3.1. File share

Use Samba, the sharing file can be accessed from both windows and mac.

#install
sudo apt-get install samba
#configure a user name
sudo smbpasswd -a andrewzhu

now configure the share folder

sudo vim /etc/samba/smb.conf

update the config file with the following content

[<folder_name>]
path = /home/<user_name>/<folder_name>
available = yes
valid users = <user_name>
read only = no
browsable = yes
public = yes
writable = yes

restart the samba service

sudo service smbd restart

now, in windows or mac, you can input the ip address of the computer to view the share folder

1.3.2. bit torrent download

Use rtorrent
https://www.linuxtechi.com/rtorrent-command-line-bittorrent-client-ubuntu-linux/
Use magnet
http://snarvaez.poweredbygnulinux.com/libertad/index.php/2013/05/10/download-magnet-links-with-rtorrent-from-command-line/
Use deluge

Use amule
https://wiki.debian.org/aMule

1.4. Trouble Shooting

1.4.1. ubuntu download armhf files.

here is the solution:
It is likely that you have installed (for example) armhf cross tools (compiler, linker, etc.) that add armhf as foreign architecture. You can verify this by running:

>dpkg --print-foreign-architectures

You can remove the foreign architecture by running:

sudo dpkg --force-architecture --remove-architecture armhf

https://askubuntu.com/questions/543722/apt-get-searching-for-binary-armhf-with-intel-i7-cpu

Andrew's Personal Linux Note (keep updating) | Ecency