Tips & Tricks
Pipe Linux command output to the Web in real-time
If you want to share your Linux command output to your support team or colleagues, instead of sharing your screen with them, you can use ‘Seashells’ to pipe out the output to a website. It can also be used as a monitoring tool for long-running processes that are continuously producing an output in the console. There is no need to install any software for this, as ‘Seashells’ uses Netcat which comes preinstalled on most systems. Here is how it works:
$ echo ‘Hello, OpenSourceForU !’ | nc seashells.io 1337 serving at https://seashells.io/v/{random url}
If you like it and want to use it frequently, then you can install the Seashells client by running the following command:
pip install seashells
Once you have the client installed, then you can directly output to ‘seashells’ instead of ‘nc seashells.io 1337’. The client gives you additional features and to find out more about it, run ‘seashells --help’.
Here is an example:
$ python myThread.py | seashells serving at https://seashells.io/v/{url} {Output of your program}
$ top | seashells serving at https://seashells.io/v/{url} {Output of top command}
—Rushikesh Gaidhani, rushi.rg@gmail.com
Sharing files from the terminal with users present in the same network
If two users who are on the same network want to share data between them, they can type the following commands in the terminal: Receiver: nc l <port> > filename $nc l 2044 testfile
After typing the above command, hit ‘Enter’ and wait. The receiver has the IP address as 192.168.0.2
Sender:
nc <ip address of receiver> <port> < <filepath/filename> $nc 192.168.0.2 2044 < /home/test/testfile
This way, both can exchange data without using any external storage device.
Note: Sender and Receiver should use the same port number while transferring data; Receiver should first hit ‘Enter’ and wait before Sender hits ‘Enter’.
—Anirudh kalwa, anirudh.3194@gmail.com
Resolving configuration issues in LibreOffice
Here is a simple tip that will help resolve issues that often arise after the upgradation of LibreOffice on a Linux based system. These issues are due to bad profile configurations. Given below is the command that will resolve such issues, by creating a new set of configurations.
All you need to do is to rename the profile folder using the following command in the Linux terminal:
$ cd ~/.config && mv libreoffice libreoffice.old
Now, whenever you start LibreOffice, a new set of profile configurations will be created automatically.
—Amit Doegar, amit@nitttrchd.ac.in
Booting directly from an ISO image present in the hard disk
Grub2 has the capability to boot directly from the ISO file present in your hard drive’s storage. This method may also be useful for distro hoppers, who want to save time in creating bootable media and who wish to avoid inserting a USB device into their systems every time, to try live distributions. Just place your downloaded ISO in any known location inside one of your partitions.
Open the ISO in any archive manager, go inside the Casper folder and view its contents.
The file with vmlinuz.efi or a similar name is your kernel file and initrd.gz (or something similar) is your initial ramdisk whose name you require in the next step.
Open the file in a text editor:
vi /etc/grub.d/40_custom Then add the following menu entry at the end:
menuentry “New os” { loopback loop (hd0,2)/home/user/mynewos.iso linux (loop)/casper/vmlinuz.efi boot=casper isoscan/ filename=/home/user/mynewos.iso noprompt noeject initrd (loop)/casper/initrd.gz
}
Here, in (hd0,2), ‘0’ represents the internal hard disk (sda) and ‘2’ represents the partition number (sda2). Now save this file and run the following command:
$sudo updategrub
Reboot and select the new OS entry in the boot menu. If all the files’ names and configurations are correct, you will boot into the OS image that was present on your hard disk.
—Shubham Dubey, sdubey504@gmail.com
Setting a commit template for a repository in Git
Git allows us to set a user-defined commit template for a particular repository so that every time anyone performs a commit, the template will be opened and one can fill it. This method is useful to make all commit messages uniform.
Let us create a template called ‘.commit-template.txt’ in the current repository with the following contents:
$ cat .committemplate.txt
Short commit message(try to keep under 60 characters) Multiline description about this commit
Ticket: BUG123 Now set this file as a template using the following command:
$ git config commit.template .committemplate.txt
Verify that the template is set properly using the following command:
$ git config l | grep commit.template commit.template=.committemplate.txt
If everything goes fine, it means the template has been set correctly. Now, when anyone does a commit in this repository, the template will be opened in the editor.
Note: This method will not work if you use the -m option with the Git commit.
Getting the system installation time on Ubuntu
To know how old your installation is, run the following commands:
$ls ld /var/log/installer| cut d ““f 6,7,9
Output Jul 11 2013 —Kousik Maiti, kousikster@gmail.com
When we create a file with the extensions .c or .cpp in a directory that already has many similar files, we can easily execute the last or the latest file by executing one of the following commands at the terminal:
$gcc [file_name] lm //for C …or: g++ [file_name] lm //for C++ —Madhav Dixit, madhav0404dixit@gmail.com