How to process a file line by line in Go?

Posted on

In the Go programming language, How to process a file line by line? An equivalent piece of Bash code could be while read line ; do echo $line done < ./input.txt You can make use of the bufio package’s Scan(). // open the file filepath f := os.Open(filepath) // create a scanner fs := bufio.NewScanner(f)
Read more

How to convert the dmesg timestamps to easier to read format on Linux?

Posted on

The dmesg results from newer Linux kernels show the timestamps. It seems the time in seconds since the kernel start time. How to convert the dmesg timestamps to the real time on Linux? The dmesg timestamp is the time in seconds since the kernel starting time. Later dmesg has an -T option: -T, –ctime Print
Read more

How to get the full path and directory of a Makefile itself?

Posted on

How to get the full path and directory of a Makefile itself like finding Bash script’s own path? This 2 lines in Makefile get the full path and dir of the Makefile itself: mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) mkfile_dir := $(dir $(mkfile_path)) The piece of code gets you Makefile, finds its absolute path and the
Read more

How to choose the key used by SSH for a specific host?

Posted on

How to choose a key used rather than the default ~/.ssh/id_rsa when ssh to a remote server for a specific host? You have at least 2 choices for choosing the key used by ssh. Taking ~/.ssh/key1 and user@example.com as the example here. Method one, specify the key in command line with the -i option of
Read more

how to use pc internet of window8 on iphone 4s via usb

Posted on

how to use pc internet on iPhone 4s wia usb cable, pc is of window 8 and in network setting its not showing of connection of I phones network I ever wrote a tutorial at http://www.systutorials.com/136003/iphone-connecting-internet-using-windows-pc-network-through-usb-cable/ . But please be aware that it worked only on specific OS combinations. So, I am not sure whether
Read more

How to get the metadata of an AWS S3 object?

Posted on

I upload files using the aws cli http://www.systutorials.com/239665/uploading-large-files-amazon-s3-aws-cli/ . But how to get the metadata of an object in AWS S3? You can use the s3api‘s head-object command to get the metadata of an object. Taking one example: $ aws s3api head-object –bucket test-hkust –key dir2/fileupload/fb0c6353-a90c-4522-9355-7cd16cf756ff.file.txt It will print results like { “AcceptRanges”: “bytes”, “ContentType”:
Read more

how change my policy of scheduling in hadoop?

Posted on

I want to change policy of scheduling in Hadoop, how to I can change job order in map reduce automatically. Assume you are using Hadoop 2 / YARN. The configuration parameter named yarn.resourcemanager.scheduler.class controls the class to be used as the resource scheduler for YARN/Hadoop. The default value for the scheduler class (check more at
Read more

How to get the CPU temperatur in command linux on Linux?

Posted on

Most modern servers or computers have sensors to detect the temperature of various components. On Linux, how to get the CPU core temperatur in command linux? First, make sure the package “lm-sensors” is installed on your Linux and the command sensors works for you. Then, you can use this piece of script to get the
Read more

How to make lftp to use key for authentication for sftp on Linux?

Posted on

I have successfully enabled password-less ssh login to a remote server, say example.com with username user. But when I use lftp to log on the sftp by lftp sftp://user@example.com it still asks my password. How it make lftp use my private key to logon the remote lftp server? There is a little trick to make
Read more

How to make the rpcbind.service auto start in systemd on Linux?

Posted on

The command systemctl enable rpcbind.service seems not work. The rpcbind.service does not start after rebooting. How to make/force the rpcbind.service auto start in systemd on Linux? You an force the rpcbind.service to start by making it be “wanted” by the target such as multi-user: # systemctl add-wants multi-user rpcbind.service This will force rpcbind.service to start.