Good Linux Tool, find out the biggest file / directory in the system
No matter how big your hard disk is, it can still run out of space someday. So, do some regular cleaning up work is necessary. Free some space by deleting the files which are out of date or not needed anymore.
To get the space consumed by each directory with du and find out the biggest one with sort.
$du --max-depth=1 -h | sort -h -r
Meaning of du options:
--max-depth : print the total size of direcotries on the firest level.
-h : print the size in human readable format (e.g. 1K, 2M, 3G, etc. ).
Meaning of sort options:
-h : sort human readable format numbers.
-r : reverse the result, the biggest number is on the top.
What I need to do is use this command recursively from the root directory ( / ) . It will finally lead me to the file or directory which consumes most of my storage.
Good Linux tool, netcat
Netcat, as know as nc, is a simple command line tool to send and receive data with TCP or UDP protocal.
There are many tutorials for the netact on the internet, since it has been wildly used as a back-end tool to :
- Simulate server
- Scanning ports
- File transfers
- Proxy gateway
- Many other things to transfer data with TCP/UDP from one place to another.
Hence here I'd like to show you something different, an example of how to create a echo server with netcat.
The server side just as simple as one line command:
$ nc -l -p 12345 -c 'while true; do read i && echo [echo] $i; done'
Then the telnet can be used as a client to connect to the nc server
$ telnet localhost 12345 hello [echo] hello
Once you input any string, the server returns your input with [echo] prefix.
Good Linux tool, Module Assistant
Module Assistant is a powerful tool to build Debian kernel modules without re-compile the whole linux kernel. Module Assitant extramly facilitate the process of building kenerl modules by automatically download the module source code from Debian package repository and compile the source code to generate kernel module binary file.
Moduel Assistant requires to run as root. With Module Assistant, the process of building kernel module is simplyfied to 5 steps.
- Install Module Assistant,
$ sudo apt-get install module-assistant
- Prepare the artifact for building kernel modules,
$ sudo m-a prepare
The command will automatically download and install the kernel headers corresponding to current kernel and needed building tools like gcc, make and so on.
- Update the module assitant suppored module list,
$ sudo m-a update
- Check supported module list,
$ sudo m-a list
- Build the needed module, such as, the module for Logitech Quickcam,
$ sudo m-a a-i qc-usb-source
Option a-i stands for automatic installation.
Good Linux tool, Network Manager.
Network Manager is a GUI application powered by dbus for network configuration. Network Manager provides a user-friendly interface to set up the wired and wireless network interface.
Network Manager consists of a background daemon process running as root and a front-end applet application.
Install Network Manager with command,
$ sudo apt-get install network-manager network-manager-gnome
To utilize the Network Manager, for Debian users, the user has to be a member of netdev group. For other distribution users, the similar user privileges are required.
$ sudo usermod -a -G netdev paul
Verify the user group setting with
$ id paul uid=1000(paul) gid=1000(paul) groups=1000(paul),4(adm),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),109(netdev),110(bluetooth),116(scanner)
By default, Network Manager only handles the interface not declared in /etc/network/interfaces.
Not declared interface means the interface is not described in the interface or the interface is disableed with a #NetworkMangaer# prefix.
For instance,
# The primary network interface allow-hotplug eth0 #NetworkManager#iface eth0 inet dhcp
To enable Network Manager to handle the interfaces in /etc/network/interfaces, the Network Manager's configuration file /etc/NetworkManager/NetworkManager.conf should be updated as:
[main] plugins=ifupdown,keyfile [ifupdown] managed=true
Then restart network-manager service:
$ sudo /etc/init.d/network-manager restart
Replace scim with ibus on Debian
The default input method framework of Debian is scim.
You may know from my last post that I just change to use sunpinyin for my default Chinese input method. But the scim sunpinyin engine seems like a little buggy. I can not switch between English and Chinese input by the shift. The window may hangs when I am typing pinyin.
Okay. I change to use ibus as well.
Firstly, the scim should be remove completely from system. Use the Synaptic or apt-get to remove all the scim related package ( scim, scim input engines, scim libs and so on ).
$ sudo apt-get purge scim
Secondary, install the ibus and ibus sunpinyin engine.
$ sudo apt-get install ibus $ sudo apt-get -t experimental ibus-sunpinyin
Finally, set ibus the default input method then restart the X session to active the ibus input method.
$ im-switch -s ibus