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
Tag: FS
How to play video in full screen and keep it looping with MPlayer?
Posted onI would like to play a video file in full screen and automatically make it keep playing during an exhibition. On Linux, how to do it with MPlayer? You can use this command mplayer -fs -loop 0 video.mp4 Here, -fs make it fullscreen and -loop 0 makes it loop infinitely. For more usage of mplayer,
Read more
Cannot connect QEMU guest os with vncviewer
Posted onThe question is as follows. harry@debian:~/workshop1/qemu_test/version1/test$ qemu-system-x86_64 -hda qcow2.img -cdrom domU-x86_64-FS.img -boot d -m 1024 VNC server running on `::1:5900′ harry@debian:~/workshop1/qemu_test/version1/test$ vncviewer 127.0.0.1:1 vncviewer: ConnectToTcpAddr: connect: Connection refused Unable to connect to VNC server Solution (add -vnc parameter for qemu-system-x86_64): harry@debian:~/workshop1/qemu_test/version1/test$ qemu-system-x86_64 -hda qcow2.img -cdrom domU-x86_64-FS.img -boot d -m 1024 -vnc 127.0.0.1:2 harry@debian:~/workshop1/qemu_test/version1/test$ vncviewer 127.0.0.1:2
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
SEEK_HOLE and SEEK_DATA: efficiently archive/copy large sparse files
Posted onHow to efficiently archive a very large sparse file, say 1TB? The sparse file may contains a small amount of data, say 32MB. SEEK_HOLE and SEEK_DATA The SEEK_HOLE/SEEK_DATA functionalities play the trick and makes `tar` and `cp` handle the large sparse file very efficiently. `lseek` with `SEEK_HOLE` returns the offset of the start of the
Read more
How to Export an NFSv4 Server to External Networks
Posted onWe ever discussed fixing ports used by NFSv3 so that it can be easily exported to external networks. For NFSv4.1 or higher, things are much easier. The ports for mountd, statd, and lockd are not required in a pure NFSv4 environment. We have less ports to control or allow for connections. Only port 111 and
Read more
The length of timeslices for processes under CFS process scheduling algorithm in Linux Kernel
Posted onAbstract As is known, CFS (Completely Fair Scheduling) is a famous process scheduling algorithm in Linux Kernel but there is no convenient way for developers to get the timeslices of processes if CFS is chosen. In this article, I will introduce one way to hack the timeslices of process easily for CFS in Linux Kernel.
Read more
How migration thread works inside of Linux Kernel
Posted onAbstract In computer systems, resources have to be balanced so that the performance will be better based on the same hardware. In Linux Kernel system, we will see some migration kernel threads running as daemons to do this kind of jobs as follows. In this article, we will discuss how Linux Kernel balances its hardware/software
Read more
How to Get Available Filesystem Space on Linux: a C Function with a C++ Example
Posted onIt is common for programs to write to files in filesystems on disks. However, what if the disk was almost full when your program writes to the filesystem on a disk? For systems software and mission critical programs, it is a better or must-to-do practice to check the available filesystem space before actually writing to
Read more
Hadoop Installation Tutorial (Hadoop 2.x)
Posted onHadoop 2 or YARN is the new version of Hadoop. It adds the yarn resource manager in addition to the HDFS and MapReduce components. Hadoop MapReduce is a programming model and software framework for writing applications, which is an open-source variant of MapReduce designed and implemented by Google initially for processing and generating large data
Read more
ASCII Table and ASCII Code
Posted onThis post gives the ASCII table and ASCII code with ASCII control characters and ASCII printable characters and a tool to convert ASCII codes to ASCII characters. Introduction to ASCII table and ASCII code ASCII stands for American Standard Code for Information Interchange. An ASCII code is the numerical representation of a character since computers
Read more
How to Set Up eCryptFS on Linux – The Manual Way
Posted onHow to set up eCryptFS in Linux will be introduced in this post. We can store encrypted files in one eCryptFS directory, the manual way. The content can be seen only after it is mounted as eCryptFS file system. Otherwise, the users can only see garbled characters in the files. Note that this tutorial will
Read more
Mostly Used MPlayer Keyboard Control Shortcuts
Posted onMPlayer has a fully configurable, command-driven control layer which allows you to control MPlayer using keyboard. But which are these shortcuts are not immediately know to users of MPlayer. Below is a list of mostly used MPlayer keyboard control shortcuts. They come from the [[man:1|mplayer|mplayer manual]] where you can find a full list of all
Read more
Hadoop Installation Tutorial (Hadoop 1.x)
Posted onUpdate: If you are new to Hadoop and trying to install one. Please check the newer version: Hadoop Installation Tutorial (Hadoop 2.x). Hadoop mainly consists of two parts: Hadoop MapReduce and HDFS. Hadoop MapReduce is a programming model and software framework for writing applications, which is an open-source variant of MapReduce that is initially designed
Read more
mrcc – A Distributed C Compiler System on MapReduce
Posted onThe mrcc project’s homepage is here: mrcc project. Abstract mrcc is an open source compilation system that uses MapReduce to distribute C code compilation across the servers of the cloud computing platform. mrcc is built to use Hadoop by default, but it is easy to port it to other could computing platforms, such as MRlite,
Read more