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
Tag: Tutorial
How to get the directory path and file name from a absolute path in C on Linux
Posted onHow 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
How to print out text with line numbers in Linux
Posted onHow to print out a plain text file with line numbers in Linux? Use the nl command: nl text-file Find options in the nl manual.
How to print a plain text file to printers from a terminal in Linux
Posted onHow 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
Ghostscript reports “Unrecoverable error: stackunderflow in .setdistillerparams”
Posted onWith 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 export and import message filters of Thunderbird
Posted onI 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 onI 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 back up a complete IMAP account?
Posted onI 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 make Emacs start up faster?
Posted onI use Emacs in consoles and start Emacs frequently (like check a file, edit it, close it and loop). However, Emacs seems take some time to start up especially some modes/extensions are used. How to make Emacs start up faster? I summarize my solution at this post: Making Emacs Startup Faster. The key is to
Read more
How to make xterm display Chinese characters?
Posted onHow 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
Directly SSH to hosts using internal IPs through the gateway
Posted onWe have many hosts with internal IPs like 10.0.3.* behind a gateway, say gateway.example.org. The hosts with internal IP connect to the Internet through the gateway. How to directly SSH to hosts using internal IPs through the gateway? Here is the solution: Directly SSH to Hosts with LAN IPs Through the Gateway
How to change the default text editor on Linux
Posted onOn Linux, a default editor is used for text editing such as crontab -e or git commit. How to change it to the editor of my own choice? The default editor is indicated by the EDITOR environment variable. You can set this environment variable to set the default editor. For example, set it to emacs
Read more
How to set options for scala in sbt
Posted onIn sbt, I found this message printed out by the scala compiler: [warn] there were 1 deprecation warning(s); re-run with -deprecation for details [warn] one warning found The question is, how to add options (-deprecation here) to the scala compiler in sbt? You can use this inside the sbt console: set scalacOptions += “-deprecation”
How to efficiently take screenshot on Windows 7
Posted onI am tired of the non-efficient “Print Screen” -> Paste in Paint -> Save way. How to efficiently take screenshot on Windows 7? On Windows 7 and later ones, the “Snipping Tool” is handy. Press the “Win” key and input “snipping tool”. The tool will appear in the menu. You can select the whole window,
Read more
How to `cut` a String Using a String as the Delimiter in Bash?
Posted onIs 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
How to install drivers for TL-WN725N v2 USB wireless adapter on Fedora 19
Posted onI had a TP-Link TL-WN725N v2 USB wireless adapter. But it seems the kernels in Fedora 19 have not yet included drivers for it. How to install drivers for TL-WN725N v2 on Fedora 19? The driver is under development. You can find the source here and in the drivers/staging in the Linux kernel. If you
Read more
How to prevent roommates from hogging bandwidth
Posted onI share a ADSL modem via a Wifi router with several roommates. Sometimes, I find the network bandwidth left is too little. Suspiciously, some one is using BT, Thunder, eMule or other P2P tools. These tools can easily use up all the bandwidth and left little for others. How to prevent some roommates from hogging
Read more
How to concatenate multiple video file together on Linux
Posted onI have multiple video files, say video1.avi, video2.avi and video3.avi. How to concatenate these multiple video file to a single file together on Linux? You can use mencoder to concatenate multiple video files to one file. For installing mencoder on Fedora, please check: http://www.systutorials.com/1493/mplayer-on-fedora/ For the question, the command is: mencoder -oac copy -ovc copy
Read more
How to get a Makefile’s directory for including other Makefiles
Posted onI experience this problem: I have a file common.mk that includes release.mk which in the same directory. common.mk is included by the top-level Makefile. common.mk and release.mk are shared by multiple projects and the top-level Makefile may stay in different directories with {common,release}.mk. Now, include in make use the pwd as base directory. So, simply
Read more
Add via to the Tweet button of AddThis share
Posted onI use the AddThis share buttons on my sites. How to add the via @fclosedotcom to the Tweet button of AddThis share so that the tweets automatically @ my twitter handle? Change <a class=”addthis_button_tweet”></a> to <a class=”addthis_button_tweet” tw_via=”fclosedotcom”></a> Try it on this page with the Tweet button.