How to find out a domain’s MX record for Email on Linux? For example, to find which domain/IP the email to gmail.com is delivered to. You may make use of the host command. The -t option is used to select the query type. type can be any recognized query type: CNAME, NS, SOA, SIG, KEY,
Read more
Tag: Programming
How to redirect anything written on a file to another file in linux?
Posted onSuppose we have two files, a.txt and b.txt . If we write anything in a.txt & b.txt, it should be redirected to c.txt. tee may help for this purpose. tee: duplicate standard input You may try a command like this: echo “hello” | tee -a a.txt >>b.txt Both a.txt and b.txt will contain the “hello”.
Read more
How to wrap long lines in a text file on Linux?
Posted onI have some text files which contain some long lines. Now I would like to break lines to at most 80 characters. How to wrap long lines in a text file on Linux? The fold command can wrap lines. fold – wrap each input line to fit in specified width For your purpose, fold -w
Read more
Skype crashes because it cannot read data from “C:Documents and SettingsAdministratorLocal SettingsTemp”
Posted onOn my laptop, I install windows xp because it is user-friendly for me. However, Skype cannot be open because “The system is not unavailable”. At last, I find the “Skype” directory under “C:Documents and SettingsAdministratorLocal SettingsTemp” cannot be accessed. “C:Documents and SettingsAdministratorLocal SettingsTemp” is like temporary directory for specific user under Linux OS. Actually, for
Read more
How to enable SSH service on Fedora Linux?
Posted onHow to enable SSH service on Fedora Linux? By default, it seems ssh is not enabled. Fedora may not have sshd service installed/enabled by default. You will need to install and configure it by yourself. The following instructions is for Fedora 22 as an example. First, install the sshd server by # dnf install openssh-server
Read more
How to merge 2 .a libraries to one .a library on Linux?
Posted onWe have 2 static .a libraries and we would like to merge them into a single one for easier usage. How to merge 2 .a libraries to one .a library on Linux? With GNU ar, you can specify the single command-line option -M and control it with a script supplied via standard input, like the
Read more
How to make Fedora Linux not clean some files in /tmp/?
Posted onOn my Fedora 20, I find that the system automatically clean up file under /tmp/. This is convenient. However, it cause some problems for some programs. For example, HDFS puts its DataNode pid file under /tmp/ by default like hadoop-hadoop-datanode.pid. After it is cleaned up, the hadoop-daemon.sh script will consider there is no DataNode running.
Read more
Xterm color codes for Vim on Linux
Posted onVim uses Xterm color codes like 9, 1 and 114 on Linux. What’s the overall mapping from color to codes or codes to color? Xterm color table: You can also find the Xterm color codes here.
What’s wrong with the messages like “UnrecovData 10B8B BadCRC” and “failed command: READ FPDMA QUEUED” on Linux?
Posted onI keep seeing messages in dmesg as follows with “exception Emask 0x10” -> “SError: { UnrecovData 10B8B BadCRC }” -> “failed command: READ FPDMA QUEUED” -> “hard resetting link”: [ 7395.936692] ata4.00: exception Emask 0x10 SAct 0xe000 SErr 0x280100 action 0x6 frozen [ 7395.936701] ata4.00: irq_stat 0x08000000, interface fatal error [ 7395.936703] ata4: SError: {
Read more
How to encode spaces in curl GET request URL on Linux?
Posted onThe problem is like this: I would like to send a GET request using curl and the content has spaces, such as curl “http://example.com/send?msg=hello world” The space and the “world” will be left away if this command is executed directory on Linux. How to encode spaces in curl request URL? You can use the –date-urlencode
Read more
How to make curl request pass the Squid proxy?
Posted onI use curl to send requests to remote servers like following command. curl http://example.com/send –date-urlencode “data=hello” However, it is blocked by the network proxy squid in some networks with message like (some info anonymized with “…”): ERROR The requested URL could not be retrieved POST /… HTTP/1.1 Proxy-Authorization: Basic … User-Agent: Mozilla/4.0 (compatible;) Host: …
Read more
Printing “powernow-k8 transition frequency failed” after install XEN
Posted onAfter I installed XEN hypervisor, the tty0 (CTRL+ALT+F1) prints “powernow-k8 transition frequency failed” to STDOUT continously, how to solve it? sudo rmmod powernow_k8 From https://lists.debian.org/debian-user/2013/01/msg00754.html How to make the settings persistent (take effect after reboot)? 1, Create script file ‘/etc/init.d/stop_pwoerk8.sh’ as follows. harry2vera@node1:/etc/init.d$ cat stop_pwoerk8.sh #! /bin/sh rmmod powernow_k8 2, Add the full PATH of
Read more
Implementation of strstr in glibc
Posted onWhat is the implementation of strstr in glibc? Implementation of STRSTR in glibc (string/strstr.c): /* Return the first occurrence of NEEDLE in HAYSTACK. Return HAYSTACK if NEEDLE is empty, otherwise NULL if NEEDLE is not found in HAYSTACK. */ char * STRSTR (const char *haystack_start, const char *needle_start) { const char *haystack = haystack_start; const
Read more
How to sort all files recursively by modification time in a directory on Linux?
Posted onHow to sort all the files in a directory and subdirectories recursively by modification time on Linux? You can make use of find (GNU find, or plus stat), sort and sed together to achieve recursively sort files by modification time: find . -type f -printf ‘%T@ %pn’ | sort -k 1 -n | sed ‘s/^[^
Read more
Required packages for building YouCompleteMe for Vim on Fedora 21
Posted onYouCompleteMe for Vim on Fedora 21 reports this error: [zma@laptop:~/.vim/bundle/YouCompleteMe]$ ./install.sh — The C compiler identification is GNU 4.9.2 — The CXX compiler identification is GNU 4.9.2 — Check for working C compiler: /usr/bin/cc — Check for working C compiler: /usr/bin/cc — works — Detecting C compiler ABI info — Detecting C compiler ABI info
Read more
How to find which program or process is listening on a certain port in Linux?
Posted onMy program reports that the port is already used. How to find which program or process is listening on a certain port in Linux? You can use netstat to do this. netstat can print network connections. For example, to find which program is listing on port 9999 netstat -pln | grep 9999 You will need
Read more
How to move all the files under Users for a user to another drive on Windows?
Posted onUnfortunately, my C: drive is almost full. Most of the space are used by the user home under C:Users. How can I move the home directory to another drive while not affecting the user’s usage of Windows. On Linux/Unix, moving the directory to another drive/partition and then keeping a softlink is enough. But how to
Read more
How to quite VirtualBox scale mode?
Posted onHow to quite VirtualBox scale mode? Use this hot key shortcut to quit VirtualBox scale mode Right_Ctrl + c
Un-exporting an Exported Variable in Bash in Linux
Posted onHow to un-export an imported variable in Bash on Linux? For example, first, I export a variable MODE like export MODE=debug but I want to unexport the MODE (not turn to be `””`, should be truly non-defined). You can export -n MODE or unset MODE For your reference (from the [`bash` manual](https://www.systutorials.com/docs/linux/man/1-bash/)): export [-fn] [name[=word]]
Read more
How to get the directory path and file name from a absolute path in Bash on Linux?
Posted onHow to get the directory path and file name from a absolute path in Bash on Linux? For example, with “/foo/bar/baz.txt”, it will produce: “/foo/bar/” and “baz.txt”. You also have the basename and dirname commands besides of the basename and dirname C API in Linux: [zma@laptop:~]$ p=”/foo/bar/baz.txt” [zma@laptop:~]$ dirname $p /foo/bar [zma@laptop:~]$ basename $p baz.txt