Useful tricks
Useful tricks in Linux using and server managing
(specifically, a Ubuntu desktop version and a server version)
- Use
ls -lh
to identify the size of your files - To mount your portable disk on a Ubuntu PC, you need to
sudo mkdir /mnt/my_disk1
and thensudo mount /dev/sdf1 /mnt/my_disk1/
. After these steps, you will be able to read and operate your disk via/mnt/my_disk1
- To unmount your disk, just try
sudo umount /dev/sdf1
and then pull off your disk. - Record the file structure of 4 level in current directory.
sudo tree -L 4 | sudo tee log.txt
- The advance media player is
mplayer
- Use
rename
to rename all the files under a folderrename 's/(..)(.*)/$2/p' *.txt
- Use
dos2unix
to erease the windows style^M
at the end of each line. - Delete the
\n
of all the lines in a file / Merge all the lines into one single lineawk '{printf $0}' 1.txt
- Mount a NTFS disk of hypenating windows in Ubuntu
sudo mkdir /media/windows /media/D
sudo mount -t ntfs-3g -o ro /dev/sda4 /media/windows
sudo mount -t ntfs-3g -o ro /dev/sda6 /media/D
OR
sudo ntfsfix /dev/sdXY
where XY
is the partition, e.g. a2
(/dev/sda2
)
Check the dependency of a software, take octave as an example
sudo apt-get build-dep octave
Shutdown the Bluetooth function from the beginning. Add this sentence to
rc.local
rfkill block bluetooth
Solve the problem of Permission denied: "/home/XXX/.gvfs"
umount /home/$USER/.gvfs
rm -rf .gvfs/
- Check memory info in Ubuntu
sudo dmidecode -t memory
14 Change the character coding for file name
First things first, install convmv
sudo apt-get install convmv
- circumstance 1
Change all document into utf8
convmv -f gbk -t utf8 --notest *
- circumstance 2
If above method fails, it may be cause by some idots claiming the code to be GBK but actually windows-1252
convmv -f utf8 -t windows-1252 --notest *
convmv -f gbk -t utf8 --notest *
使用技巧
中文版?不存在的,脑子一热就写了英文的