How to enable iptables on CentOS 7 / Fedora 20?

Posted on

iptables is plain old good. How to enable it after I disable firewalld? First, install the iptables-services package as root: # yum install iptables-services Then, start iptables service as root: # touch /etc/sysconfig/iptables # touch /etc/sysconfig/ip6tables # systemctl start iptables # systemctl start ip6tables # systemctl enable iptables # systemctl enable ip6tables

Multi-connection multi-part file downloading tools on Linux

Posted on

Is there any good multi-connection multi-part file downloading tools on Linux? wget is great but can only make 1 connection for 1 file. Sometimes, it is too slow on some networks. I use aria2 which supportsmMulti-connection download. aria2 can download a file from multiple sources/protocols and tries to utilize your maximum download bandwidth. Really speeds
Read more

How to get the directory path and file name from a absolute path in C on Linux

Posted on

How to get the directory path and file name from a absolute path in C on Linux? For example, with “/foo/bar/baz.txt”, it will produce: “/foo/bar/” and “baz.txt”. You can use the APIs basename and dirname to parse the file name and directory name. A piece of C code: #include <libgen.h> #include <string.h> char* local_file =
Read more

Ghostscript reports “Unrecoverable error: stackunderflow in .setdistillerparams”

Posted on

With the command -dPDFSETTINGS=/print for ps2pdf, I got: GPL Ghostscript 9.10: Set UseCIEColor for UseDeviceIndependentColor to work properly. Unrecoverable error: stackunderflow in .setdistillerparams make: *** [pdf-print] Error 255 How to fix it? I use this workaround: ps2pdf -dColorConversionStrategy=/LeaveColorUnchanged -dPDFSETTINGS=/printer psfile.ps from this. An alternative is to use -dPDFSETTINGS=/prepress.

How to print a plain text file to printers from a terminal in Linux

Posted on

How to quickly print a plain text file to printers from a terminal in Linux? You can also use enscript: enscript – convert text files to PostScript, HTML, RTF, ANSI, and overstrikes https://www.systutorials.com/docs/linux/man/1-enscript/ enscript text-file The lp command can print a plain text file to a printer. My favorite command: cat text-file | lp -o
Read more

Alternatives to goto in bash

Posted on

As we know: There is no goto statement support in bash. goto is useful for certain situations, especially for debugging. So, is there any alternative mechanisms to goto in bash? Robert Copeland gave an interesting hacking to this problem: http://bobcopeland.com/blog/2012/10/goto-in-bash/ The idea is like the self-modifying code. But the difference is to generate a piece
Read more

How to export and import message filters of Thunderbird

Posted on

I have several installation of Thunderbird under Linux to check/send emails using IMAP email servers. I use filters extensively to manage my emails. How to export and import message filters of Thunderbird so that I can synchronize the rules on several installations? About message filters in Thunderbird (More at http://kb.mozillazine.org/Filters_(Thunderbird)): Filters are account specific, there
Read more

How to add a space between the line numbers and text content in Emacs?

Posted on

I use Emacs in console. The linum-mode displays the line numbers just well. However, in the console, there is no space between the line numbers and the text content, which makes it a little messy some times. How to add a space between the line numbers and text content in Emacs? If you are using
Read more

How to make xterm display Chinese characters?

Posted on

How to make xterm display Chinese characters? It just displays some small rectangles for Chinese characters. First, the settings for some old X programs like xterm is in ~/.Xresources. And it takes effect after the X server restarts, or you can manually load the settings by xrdb -merge ~/.Xresources Second, the Chinese or similar fonts
Read more

How to back up a complete IMAP account?

Posted on

I have a large IMAP email account which contains many emails in a rich structure of directories. How to back up the whole IMAP account to my local computer? The requirements: Automatically downloading these files. There are many directories, and copying-pasting emails will take too much time. Keep the directory structures which are used to
Read more

How to `cut` a String Using a String as the Delimiter in Bash?

Posted on

Is is possible to cut in Linux using a string as the delimiter? cut –delimiter=”delim” -f 1,3 cut reports: cut: the delimiter must be a single character The most closest solution that I find is using awk/gawk: awk -F ‘delim’ ‘{print $1; print $3}’ From the manual: -F fs –field-separator fs Use fs for the
Read more