Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts

Thursday, August 25, 2016

Blender missing shared library gotcha!

Here is a simple solution to Blender missing 'libavcodec.so.54' shared library on Ubuntu Xenial (16.04.1 LTS) box. There are numerous posts about this problem but very few solutions.


$ blender
blender: error while loading shared libraries: libavcodec.so.54: cannot open shared object file: No such file or directory

Solution for Blender missing library

Let me share what worked for me. Let's try to locate and add the library to ldconf path.


# Install the libavcodec-extra package using apt-get package manager.
$ sudo apt-get install libavcodec-extra-56

# Verify the location of libavcodec.so.54 file path.  
$locate libavcodec.so
/usr/lib/x86_64-linux-gnu/libavcodec.so
/usr/lib/x86_64-linux-gnu/libavcodec.so.56
/usr/lib/x86_64-linux-gnu/libavcodec.so.56.1.0


# Create a new ldconfig file with proper path to the shared library. 
$ sudo nano /etc/ld.so.conf.d/blender.conf

# Add the following line in the file. 
/usr/lib/x86_64-linux-gnu/

# Rerun ldconf 
$ sudo ldconf 

# Start blender normally. 
$ blender  


That's all folks!. Enjoy blender.

Wednesday, August 5, 2015

Mirroring gnu/Linux screens on command line

It's my turn on stage. Smiling broadly I walk over to the stage with my computer. I worked hard on my slide-deck and pre-loaded all the webpages just in case the Internet connectivity failed. Connect my computer with a VGA cable to the projector and realize that I need to mirror my screen. So that the audience could see my computer screen on projector. That should be easy to do. So I open my computers display settings on Gnome control center and hunt for the 'mirror the screens' option. I can feel scores of eyes follow my every move. There is no option to mirror the display screens, I break into a cold sweat. I regret not saying a prayer to the demo gods.

Miracles happens, my fellow presenter Yang was my guardian angel. He had one trick up his shelve. He took the computer and typed this magic command into the terminal.


xrandr --output VGA1 --same-as LVDS1

That worked! I wipe the sweat and thank Yang profusely. Now it's show time.

Saturday, July 25, 2015

Restoring Nexus 4 Factory Image

Something terribly went wrong during Android 5.1.1 Over The Air (OTA) update. The Nexus 4 mobile phone stuck in the boot loop after update. Perhaps the update failed to download the files or the device ran out of disk space. For those of you who like to debug such problems, I captured some logs for analysis with 'adb logcat' here (1,2,3,4).

Caution: Flashing a new factory image deletes all user data. Be certain to first backup any personal data such as photos.

Tools: What do you need to restore the phone?

For this tutorial I'll use a gnu/Linux computer with Android SDK Stand-alone Tools installed. We'll use the 'fastboot' program to flash the Android Nexus 4 devices with factory images from developer.android.com/nexus/images.

  1. Download Android SDK Stand-alone tools from developer.android.com.
  2. Uncompress the Android SDK to your /opt/android-sdk-linux directory.
  3. Add Fastboot to your system path
    
    $ ln -sf /opt/android-sdk-linux/platform-tools/fastboot /usr/local/bin/fastboot
    
  4. To get Fastboot working on gnu/Linux I added the follow line to /etc/udev/rules.d/51-android.rules .
    
    $ sudo nano /etc/udev/rules.d/51-android.rules 
    
    # adb protocol on mako (Nexus 4 debug)
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1",ATTR{idProduct}=="4ee2", MODE="$
    
  5. Restart udev service.Connect the Nexus 4 device to computer with USB cable and see fastboot can access it.
    
    $ sudo service udev restart 
    $ sudo fastboot devices
    
  6. Unlock the Nexus 4 phone (Optional step). The phone will reboot and follow the instructions on the phone screen to unlock the phone.
  7. $ fastboot oem unlock 
  8. Let's put the Nexus 4 in recovery mode so that we can flash the new factory image. You can use 'adb' command or press hold volume up + volume down + power buttons during the phone bootup.
      
    $ adb reboot bootloader
    
  9. Download the Nexus 4 factory image from developers.google.com/android/nexus/images. I have downloaded the Android 5.1.0 (LMY47O) factory image. Uncompress it the downloaded file and excute the 'flash-all.sh' script to flash the factory image.
    
    $ tar zxvf occam-lmy47o-factory-cae68e81.tgz 
    
    $ cd occam-lmy47o/ 
    
    $ sudo ./flash-all.sh 
    

Whew! That's all folks! Now you get enjoy the Nexus device with brand new factory image.

Sunday, October 26, 2014

Gnome 3 Massive Title Bar Solution

Upgraded to Ubuntu 14.10 (Utopic Unicorn) this weekend. The upgrade process went without a hitch and latest Gnome 3.12 desktop experience is good except for this massive title bar issue. Reblogging Mikey's solution for this minor Gnome 3 annoyance. Thanks Mikey!.



$ sudo sed -i "/title_vertical_pad/s/value=\"[0-9]\{1,2\}\"/value=\"0\"/g" /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml

Gnome 3 Desktop screenshot image with large title bar

Before

Gnome 3 Desktop screenshot image with normal title bar

After


Reported the bug, Please feel free to track the bug #1385597 and provide your feedback.

Wednesday, March 26, 2014

Managing Configuration files with etckeeper

Managing your /etc configuration files using version control is a good practice. Trust me, someday this will save your skin.

In the post I'll share setup notes for using etckeeper with git version control. You can install etckeeper and git using system package manager.


# Initialize etckeeper
sudo etckeeper init 

# Commit all your /etc/ configurations into git
sudo etckeeper commit '...enable etckeeper...'

# Check the commit history of file 
$ sudo git log /etc/passwd
commit 322b63ede6cf3073a8f48a883b49d5b3b60fdfb9
Author: arky <arky@localhost.localdomain>
Date:   Wed Mar 5 07:11:47 2014 +0000

    ...enable etckeeper...


There is very little etckeeper documentation out there. You can learn more from this dated Ubuntu Server 10.04 etckeeper wiki page.

Wednesday, January 26, 2011

HOW TO: Copy a CD-ROM in Ubuntu

Here is a quick tip on how to make a copy of CD/DVD when the standard CD/DVD burning software is not available. We can use the 'dd' command to copy the CD/DVD as an ISO image file on your harddrive.



 dd if=/dev/cdrom of=/tmp/cdimage.iso

1313832+0 records in
1313832+0 records out
672681984 bytes (673 MB) copied, 127.532 s, 5.3 MB/s


Saturday, May 2, 2009

send a twitter messages from command line with bti

bti allows you to send twitter messages right from the command line. It works with both twitter.com and identi.ca. To use this program install the Ubuntu package with the same name (sudo apt-get install bti).

I was able to post a tweet message using bti within few minutes. The configuration is easy and straight forward. Have look at the bti example config file to get started quickly (/usr/share/doc/bti/examples/bti.example). The url shorting feature (with --shrink-urls option) however didn't work as intended though. Anyway its wonderful to be able to tweet from the command line, bti does have some pretty interesting features.
And don't forget to follow my tweets @playingwithsid.

About Bti micro-blogging command line tool

bti provides an easy way to send tweet messages direct from the command line or any script. It reads the message on standard input and uses the account and password settings either from the command line options, or from a config file, to send the message out.
It's primary focus is to allow you to log everything that you type into a bash shell, in a crazy, "this is what I´m doing right now!" type of way, letting the world follow along with you constant moving between directories and refreshing your email queue to see if there´s anything interesting going on.

Wednesday, November 12, 2008

Bash Path Security Gotcha!

The devil they say is in details, even the simple Bash path variable can open some security problems on your box. Every Bash documentation out there warns us not leave '.' in the path (it matches current directory). They however don't seems to mention that leaving a dangling ':' (colon) at the beginning or the end of Bash $PATH does create the same security vulnerability.

# Standard Bash $PATH $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games # Let's get evil, append a colon at the end $ export PATH="$PATH:" # Let's check the tainted Bash $PATH $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games: # Create Trojan application (of sorts) $ echo "echo foo"> app $ chmod +x app # Run the command and Viola! $ app foo

Sunday, November 9, 2008

Locate Configuration Example

Keep things found is not an easy skill to master. The disk drive turns into a deep and dark jungle after the first few weeks on road. Traditional *nix command 'locate' helps us find files quickly by matching against a previously generated database. There are quite a few locate implementations available such as the GNU Findutils, slocate and mlocate, they have quite a few new features and security enhancements.

Unlike its first cousin the 'find' command, locate queries are faster but the exact matches are dependent on the freshness of the database. Also redundancy issue creeps in if you are not watchful. For example, searching with 'locate Simple.pm' gives undesirable results spread across all mounted partitions on this computer. /mnt/old-drive/usr/share/perl/5.8.4/Filter/Simple.pm # old Linux distro /usr/share/perl/5.8.8/Filter/Simple.pm # Current OS (Ubuntu/Debian) /mnt/windows/Perl/lib/Filter/Simple.pm # Windoze XP

Now lets see if we can remedy this by disabling locate indexing of mounted partitions and mounted Windows XP partition as well. Add '/mnt' to the PRUNEPATHS variable and 'vfat' to the PRUNEFS variable to the /etc/updatedb.conf file.

PRUNE_BIND_MOUNTS="yes" PRUNEPATHS="/tmp /var/spool /mnt " PRUNEFS="NFS nfs nfs4 afs binfmt_misc proc smbfs autofs iso9660 ncpfs coda devpts ftpfs devfs mfs shfs sysfs cifs lustre_lite tmpfs usbfs udf rpc_pipefs vfat"

Next time the 'updatedb' command is run to create the locate database it avoids indexing all the directory paths listed under PRUNEPATHS and file systems in PRUNEFS options.

Wednesday, March 12, 2008

Grep : The Torment question

Here is a favorite question often posed to novice sysadmins. Ho, how they would sweat on this one!!. I was pleasantly surprised to see it find its way into Linux Journal's Tech tips. Darn good one Alessandro!.

Thursday, January 31, 2008

Raw Control Characters In Less pager

Less is my default terminal pager program. On GNU Debian Linux pager is just a symbolic link to your less or one of other available pager progams like more , most , lv etc..( run update-alternatives —list pager to find out alternative pager programs available on your computer). Lately some funny characters started showing up in my pager .

$ ls /tmp/Foo/ | pager

ESC[0mESC[0mFooBarESC[0m
ESC[0mMaster-fooESC[0m
ESC[m

Oops, That looks like the ANSI Escape Sequences commonly used for making a shell colourful, but our pager program less seems to have some trouble with it. Let’s try to correct this but using -R option which toggles this behaviour.

$ ls /tmp/Foo/ | pager -R
FooBar
Master-foo

Ok, that seems to fix it. Now let’s set it into our shell environment.You set the same using lesskey also.

LESS=”-R”; export LESS

Please note that using -r option may cause display problems , that’s why I use -R .

Wolfgang Friebel notes in Displaying more with less that ..

Syntax highlighting is only activated if the environment variable LESS is existing and contains the option -R or -r or less is called with one of these options. This guarantees, that instead of literal escape sequences colors are displayed. The detection of the -r/-R presence at runtime is rather dependent on the operating system and may not work in all cases. Putting the option in the LESS environment variable is guaranteed to work.By installing the perl module Proc::ProcessTable the OS dependence can be reduced as well.

Website file Uploads With lftp

Keeping your website updated is tedious job,especially when you have lot of files,which you edit quite often.And having to do the such work over ftp makes it worse.

In this article we’ll use a command line based file transfer program lftp(http://lftp.yar.ru/) written by Alexander .V. Lukyanov to do website file uploads.Though there are many other ftp clients,lftp is simpler to use,feature rich,can upload several files in parallel and it comes bundled up with most Gnu/Linux distributions. lftp is a powerful tool, its built-in mirror facility is suitable for keeping your website updated and secure by replicating permissions on the uploaded files.It checks for modified files by checking the file sizes and file modification times.

Using lftp on Command Line

Now you have a local directory on your computer where you keep all your website files(/home/joe/site_files).Let upload these files to your remote webserver directory using lftp on command line.First lets connect to your hosting service providers webserver with username and password.

$ lftp -u username ftp.hostingcompany.net
Password:

The lftp program will prompt for the password,type your secret password and you will be logged in.

Now issue the ‘lcd’ command to change directory to local directory where your all website files reside.

lftp username@ftp.hostingcompany.net:~> lcd /home/joe/site_files
lcd ok, local cwd=/home/joe/site_files

Now use the lftp mirror built-in’s reverse option (-R) of lftp to
upload all files local files into remote directory on the webserver.

lftp username@ftp.hostingcompany.net:~> mirror -R
Total: 12 directories, 36 files, 0 symlinks
Modified: 13 files, 0 symlinks

You can use “ mirror -R —only-newer “ command if you want only new files to uploaded.Once the upload is finished lftp will print out a report.Now you can end the connection by typing quit.

lftp username@ftp.hostingcompany.net:~> quit

Running lftp in a Script

Now that we have seen lftp in action.Let run all the commands from script instead.Luke Vanderfluit provides this nice little script.

lftp -u username,password ftp.hostingcompany.net <<EOF
cd / # remote directory on webserver
lcd /home/joe/site_files # local directory on your computer
mirror -R # Upload the files to remote directory
quit 0 # Drop the connection
EOF

Save all the commands in a file ‘upload_mysite’ and make it executable with ‘chmod +x upload_mysite’.Run the script by typing ‘./upload_mysite’ on the command line.As your username and password are stored it file,its a better not let anyone else to view it.Changing file permissions with ‘chmod go-rwx upload_mysite’.

Maintaining Multiple Websites

Running lftp from script is not a good idea if you have to maintain multiple sites.Instead you can use lftp’s ‘-f’ option.You can store settings of different websites into separate files.Suppose you have two websites site1 and site2.

The settings of the both the sites are stored in files ‘mysite1.lftp’ and ‘mysite2.lftp.

#####mysite1.lftp#######################
open ftp.myisp.net
user username password
lcd /usr/joe/site1_files
mirror -R
exit #########################################

#####mysite2.lftp#######################
open ftp.hostingcompany.com
user username password
lcd /usr/local_site_location
mirror -R
exit #########################################

To update site1, we will run lftp with ‘-f’ option.

$ lftp -f mysite1.lftp

And to update the next website.

$ lftp -f mysite2.lftp

Some other usefull features provided by ‘mirror’ built-in are the —parallel = N where in it will use N simultaneous connections to upload the files,this speeds up the upload considerably.If you want to exclude some files from being uploaded use (- x , – X) . And —delete to remove those files which are not present in local directory.

lftp can also be run as a cron job . Jani Reinikainen shows an interesting use of lftp to periodically mirroring a directory to a remote computer.

References

lftp manual page [http://lftp.yar.ru/lftp-man.html ]
lftp FAQ [http://lftp.yar.ru/FAQ ]
lftp Download page [http://lftp.yar.ru/get.html ]

Smart URL 's in Elinks

If you have Elinks installed then it already has a bunch of smart URL’s enabled .The table below lists those in Debian’s elinks package configuration file. The Elinks Manual explains how it works and how to build your own.

Here a example, lets search for what acronym “ALSA” means with elinks.

Press g in elinks and type a: ALSA when prompted with Enter URL. The a: is the keyword and ALSA (replaced in place of %s ) is search string, elinks smart rewrite expands it to http://acronymfinder.com/af-query.asp?String=exact&Acronym=ALSA and submits it , You will be directed to the search results at acronymfinder.com.

Elinks Smart URL’s Reference:

  • a http://acronymfinder.com/af-query.asp?String=exact&Acronym=%s
  • arc http://web.archive.org/web/*/%s
  • bb http://babelfish.altavista.com/babelfish/tr?urltext=%s
  • bb_en_fr http://babelfish.altavista.com/babelfish/tr?lp=en_fr&submit=1&urltext=%s
  • bb_fr_en http://babelfish.altavista.com/babelfish/tr?lp=fr_en&submit=1&urltext=%s
  • bug http://bugzilla.elinks.or.cz/show_bug.cgi?id=%s
  • cambridge http://dictionary.cambridge.org/results.asp?searchword=%s
  • cliki http://www.cliki.net/admin/search?words=%s
  • cr http://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=%s&format=http&abstract=abson&keywords=keyon&num=25
  • czen http://www.slovnik.cz/bin/ecd?ecd_il=1&ecd_vcb=%s&ecd_trn=translate&ecd_trn_dir=1&ecd_lines=15&ecd_hptxt=0
  • d http://www.dict.org/bin/Dict?Query=%s&Form=Dict1&Strategy=*&Database=*&submit=Submit+query
  • dbug http://bugs.debian.org/%s
  • dict http://dictionary.reference.com/search?q=%s
  • dmoz http://search.dmoz.org/cgi-bin/search?search=%s
  • dpkg http://packages.debian.org/%s
  • draft http://www.rfc-editor.org/cgi-bin/idsearch.pl?searchwords=%s&format=http&abstract=abson&keywords=keyon&num=25
  • e2 http://www.everything2.org/?node=%s
  • emacs http://www.emacswiki.org/cgi-bin/wiki.pl?search=%s
  • encz http://www.slovnik.cz/bin/ecd?ecd_il=1&ecd_vcb=%s&ecd_trn=translate&ecd_trn_dir=0&ecd_lines=15&ecd_hptxt=0
  • fm http://freshmeat.net/search/?q=%s
  • foldoc http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?%s
  • fsd http://directory.fsf.org/search/fsd-search.py?q=%s
  • g http://www.google.com/search?q=%s&btnG=Google+Search
  • gd http://www.google.com/search?q=%s&cat=gwd/Top
  • gg http://www.google.com/search?q=%s&btnG=Google+Search
  • gi http://images.google.com/images?q=%s
  • gn http://news.google.com/news?q=%s
  • go http://www.google.com/search?q=%s&btnG=Google+Search
  • google http://www.google.com/search?q=%s
  • gr http://groups.google.com/groups?q=%s
  • gwhat http://www.googlism.com/?ism=%s&name=2
  • gwhen http://www.googlism.com/?ism=%s&name=4
  • gwhere http://www.googlism.com/?ism=%s&name=3
  • gwho http://www.googlism.com/?ism=%s&name=1
  • id http://www.rfc-editor.org/cgi-bin/idsearch.pl?searchwords=%s&format=http&abstract=abson&keywords=keyon&num=25
  • imdb http://imdb.com/Find?%s
  • lxr http://lxr.linux.no/ident?i=%s
  • lyrics http://music.lycos.com/lyrics/results.asp?QT=L&QW=%s
  • mw http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=%s
  • mwt http://www.m-w.com/cgi-bin/thesaurus?book=Thesaurus&va=%s
  • onelook http://onelook.com/?w=%s&ls=a
  • py http://starship.python.net/crew/theller/pyhelp.cgi?keyword=%s&version=current
  • pydev http://starship.python.net/crew/theller/pyhelp.cgi?keyword=%s&version=devel
  • pyvault http://py.vaults.ca/apyllo.py?find=%s
  • rfc http://www.rfc-editor.org/rfc/rfc%s.txt
  • rfcid http://www.rfc-editor.org/cgi-bin/idsearch.pl?searchwords=%s&format=http&abstract=abson&keywords=keyon&num=25
  • rfcs http://www.rfc-editor.org/cgi-bin/rfcsearch.pl?searchwords=%s&format=http&abstract=abson&keywords=keyon&num=25
  • savannah http://savannah.nongnu.org/search/?words=%s&type_of_search=soft&exact=1
  • sd http://slashdot.org/search.pl?query=%s
  • sdc http://slashdot.org/search.pl?query=%s&op=comments
  • sdj http://slashdot.org/search.pl?query=%s&op=journals
  • sdp http://slashdot.org/search.pl?query=%s&op=polls
  • sdu http://slashdot.org/search.pl?query=%s&op=users
  • sf http://sourceforge.net/search/?q=%s
  • sfp http://sourceforge.net/projects/%s
  • thes http://thesaurus.reference.com/search?q=%s
  • whatis http://uptime.netcraft.com/up/graph/?host=%s
  • wiki http://www.wikipedia.org/w/wiki.phtml?search=%s
  • wn http://www.cogsci.princeton.edu/cgi-bin/webwn1.7.1?stage=1&word=%s

Tuesday, January 29, 2008

Debian Dpatch How To

Tuxmaniac gets his hands dirty with dpatch and documents his experience in a easy to follow tutorial.

One review point that the packager comes across instantly is that “Do not change upstream code”. This is a Golden rule for packagers. Making these changes as patches in debian/ (for debian based distros ofcourse ;-) ) is highly recommended. One such tool for achieving this is DPATCH.

dpatch - just superb! (a short How to)

Sunday, January 27, 2008

Guide to Unix/Linux Commands

In October 2005 I contributed to the Guide to Unix/Linux commands wikibook. It is targeted at users who want to learn the shell commands by typing them on a Unix or gnu/Linux console. The wikibook is nowhere near complete but I guess it would be a good start if want to master the shell. For experienced users I request you to spare some time and contribute to this wikibook. If possible please try to adopt this documentation project.

The Guide to Unix/Linux Commands

The Guide to Unix/Linux command line is often considered difficult to learn. This book aims to help beginners by introducing various commands in lucid and simple language. Unlike most command references, this book is designed to be a self-study guide.

Contents

  • Getting Help man info apropos whatis makewhatis
  • File System Utilities ls mkdir cd pwd chroot cp mv rm touch df link ln unlink chown chmod mount
  • Finding Files find whereis which locate
  • File Viewing cat more less od head tail
  • File Editing pico nano zile vi joe emacs
  • File Compression gzip gunzip zcat gzcat tar pax bzip2 zip compress
  • File Analysingfile wc cksum stat
  • Multiuser Commandswho finger su
  • Self Information whoami groups id tty
  • System Information uptime uname dmesg free vmstat 50% top df hostname
  • Networking ifconf ifdown ifup
  • Process Managementnohup ps kill pgrep pidof killall
  • Devices fuser lsof fstat
  • Kernel Commands lsmod modprobe sysctl
  • Compress Commandstar cvf | tar xvf bunzip2
  • Miscellaneous sync echo cal date time mail clear PS1

Popular Posts