How to set the replication factor for one file when it is uploaded by `hdfs dfs -put` command line in HDFS?

Posted on

When uploading a file by the hdfs dfs -put command line in HDFS, how to set a replication factor instead of the global one for that file? For example, HDFS’s global replication factor is 3. For some temporary files, I would like to save just one copy for faster uploading and saving disk space. The
Read more

How to exit the program in Node.js?

Posted on

When fatal error happened, we’d like to kill the program. How to exit the program in Node.js? You can use: process.exit() Here, “process” is a global process object. exit method ends the process. process.exit([code]) Ends the process with the specified code. If omitted, exit uses the ‘success’ code 0. To exit with a ‘failure’ code:
Read more

How to parse POST data in node.js?

Posted on

Some JavaScript libraries send data by POST instead of JSON. In node.js, how to parse the POST data? You can use the “querystring” module: var qs = require(‘querystring’) The following piece of code works well for me. The comments should help you read the code well. var post_handle = function(request, response) { if (request.method ==
Read more

How to force a USB 3.0 port to work in USB 2.0 mode in Linux?

Posted on

We know that we can disable USB 3.0 in the BIOS. But is there a way to force a USB 3.0 port to work in USB 2.0 mode inside of a running Linux? On Linux on some platforms booted in BIOS modes, you can use the following command to force USB 2.0 modes for your
Read more

How to detect whether Linux runs in UEFI or BIOS mode inside the Linux?

Posted on

How to detect whether Linux runs in UEFI or BIOS mode inside the Linux itself without needed to boot the the management console of the mother board? You can detect whether Linux runs in EFI mode by checking whether /sys/firmware/efi exist. In bash, you can test by [ -d /sys/firmware/efi/ ] This technique is used
Read more

How to force ssh client to authenticate using password on Linux?

Posted on

ssh client can use many authentication methods like password, keys. On a server, I set password-less log in with private/public key. Now, I want to try whether the new password is set correctly by log on using ssh. By default, the key-based authentication method is used again. How to force ssh client to authenticate using
Read more

How to advertise different gateway ip via DHCP in OpenWRT?

Posted on

How to advertise a different router/gateway ip via DHCP in OpenWRT? In general, you need to configure the DHCP option with code 3 (router). (A list of all options can be found in http://www.networksorcery.com/enp/protocol/bootp/options.htm ) For example, to advise the gateway IP 192.168.1.2, you will send this option: “3,192.168.1.2” Now, for OpenWRT, you have 2
Read more

How to find out the MX record for a domain on Linux?

Posted on

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

How to force umount a NFS directory on Linux?

Posted on

The NFS server is down. It is reported “Stale NFS file handle”. I tried ‘umount’ and ‘umount -f’. But neither succeeded. # umount /mnt/store umount.nfs: /mnt/store: Stale NFS file handle # umount -f /mnt/store umount.nfs: /mnt/store: Stale NFS file handle How to force umounting the NFS without rebooting the Linux server? I usually have to
Read more

How to allow websites’ .htaccess files in Apache2?

Posted on

How to allow websites to use .htaccess files in Apache2 web servers? The AllowOverride directive controls this: http://httpd.apache.org/docs/current/mod/core.html#allowoverride To allow AllowOverride in a directory, add the following rules to the /etc/httpd/conf/httpd.conf or similar configuration file for your apache installation: <Directory “/var/www/www.example.com”> Options FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files.
Read more

How to host multiple websites on a Apache Linux web server?

Posted on

I have a Linux web server with Apache (httpd). How to host multiple websites on Apache? To host websites www.example1.com and www.example2.com on a single node with Apache2 on a single IP, you can use VirtualHost as follows. Edit /etc/httpd/conf/httpd.conf and add the following lines: NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /var/www/example1.com ServerName www.example1.com # Other
Read more