Showing posts with label Operating system. Show all posts
Showing posts with label Operating system. Show all posts

Sep 20, 2014

PATH variable

---------------------------------
Find the required location of the file, eg. java. Put the directory into the PATH variable.
touch ~/.bash_profile
open ~/.bash_profile

PATH=/opt/local/lib:/System/Library/Frameworks/Python.framework/Versions/2.5/bin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin

source ~/.bash_profile


Python in OSX

Though OSX comes with a version of python, if another version is required here are some guidelines.


# I have used macport to install the desired version of python (eg., 2.7). This will be installed in the following directory.
cd /Library/Frameworks/Python.framework/Versions/
ls
2.7 Current

# Now move the installed version into the directory /System/Library/Frameworks/Python.framework/Versions/
where all other previously installed python version are.
sudo mv /Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/

# remove the older version of "Current" from /System/Library/Frameworks/Python.framework/Versions/

$ sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/2.7
$ sudo rm /System/Library/Frameworks/Python.framework/Versions/Current

# create new symbolic link for the newly installed python version (eg, 2.7)
$ sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/Current

# remove the old python symbolic link
$ sudo rm /usr/bin/pydoc
$ sudo rm /usr/bin/python
$ sudo rm /usr/bin/pythonw
$ sudo rm /usr/bin/python-config 

# create the new symbolic links so that when you type on the terminal this is the desired python that would execute. This is because python
$ sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc /usr/bin/pydoc
$ sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/bin/python
$ sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw /usr/bin/pythonw
$ sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config /usr/bin/python-config

# update the ~/.bash_profile PATH variable to link the current python path
touch ~/.bash_profile
open ~/.bash_profile

PATH=/opt/local/lib:/System/Library/Frameworks/Python.framework/Versions/2.5/bin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin:/usr/X11R6/bin

source ~/.bash_profile


Installed modules via macport successfully get installed into /opt/local/lib/python2.5/site-packages/
But when compiling a python script it doesn't find the path of the modules that are included using import statement such as 

import path
import json
import numpy
import Image

The following error message pops up "ImportError: No module named Image" or "ImportError: No module named simplejson".

Updating the PATH variables to point to the python version or macport installation path did not help. Explicit location of the installed modules needs to be shown to get rid of the error.

Add the path in the python code to show the path of the installed package. For example, to show the installed packages via macport find the path of the location of where the modules get installed:
$port content py25-numpy
It will show the /opt/local/lib/python2.5/site-packages/
Add the path using 
sys.path.append("/opt/local/lib/python2.5/site-packages/")

Similarly, for the downloaded package such as path, add the location of the downloaded copy using sys.path.append() method.
sys.path.append("~
/Desktop/seeing3d_renderer/seeing3d-master/pathpy/
)


One solution could be use the try-catch:
try:
    import json
except ImportError:
    import simplejson as json 


with open(access) as log_file:
Should be replaced with the following for the earlier python version such 2.5.
stream = None
log_file = None
try:
    stream = open(access, 'r')
    log_file = stream.readlines()
except IOError:
    print "Cannot find open the file", access

Jul 23, 2014

Aptitude for Ubuntu

There is fink or macport (for OSX) type of thing in Ubuntu. How come I did not know about that? It is called "aptitude".
Get aptitude and look for the library you want to install:
  • sudo apt-get install aptitude
  • aptitude search LIBRARY_YOU_WANT

Aug 11, 2012

Linux hacks


  1. Synaptic package manager vs Ubuntu software center:Ubuntu 10.04 version provides synaptic package manager to install additional packages you require. In Ubuntu 12.04 you have Ubuntu software center to do that. 12.04 doesn't come with it in favor of software center. Still you can install it if you want. Reference
  2. Ubuntu 10.04, 12.04 dual booting:
    Reference 
  3. Skype on Ubuntu 12.04: Reference
  4. starting up Matlab from command prompt:
    1. open up ~/.bashrc file
    2. export PATH=$PATH:/usr/local/MATLAB/R2011a/bin
  5. Changing the order of GRUB bootloader:
    1. Manually editing the configuration file
    2. Startup-manager a graphical tool but this is obsolete.
    3. Grub-customizer
    4. Desktop shortcut for application: Additionally I made the Terminal flag set to true while creating my matlab shortcut. (For matlab installed from iso, choose the option application in terminal from the drop-down list type).
    5. Ubuntu-tweak: kernel, app, etc cleaner. Installation.
    6. ppa-for-netflix-desktop-app
  6. Bootable disk:
    1. Startup disk creator sucks. Pain in the butt.
    2. Download Unetbootin from software center.
    3. Format the usb in FAT. and reinsert the disk.
    4. Reference.
  7.    
  8.  


Aug 9, 2012

Ubuntu 12.04 from USB

First time I have installed Ubuntu from USB.
1. downloaded the .iso file from here
2. made a copy into the usb drive
3. MOST IMPORTANTLY created the bootable USB drive using usb-creator.
(If you don't have the package then install it from Synaptic Package Manager.)
     -open up the Synaptic Package Manager
     -search for package usb-creator
     -Go to System - Administration - Startup Disk Creator (linux 12.04 version)
     -Show the source file path and destination drive

All set to install.

Useful reference

Problems: If GRUB is missing then use the following solution.
                 Initially started by downloading the 32 bit version. And formatted the usb using FAT. Did not work. Later installed the 64 bit version using the NTFS formatted flash drive. 

Feb 6, 2012

Time for Ubuntu

First job is to install MeshLab, a visualization software.
Compiling MeshLab
Note:
Some plugins of MeshLab invokes functions exported by external libraries. You have to compile these libraries before attempting to compile the whole MeshLab's code. 

To compile MeshLab and all MeshLab plugins:
First compile the needed external libraries

cd MESHLAB_DIRECTORY/src/external
qmake -recursive external.pro
make

then compile MeshLab and its plugins
cd MESHLAB_DIRECTORY/src/
qmake -recursive meshlab_full.pro
make

Alternatively you can directly compile only a subset of the whole meshlab by using the meshlab_mini.pro. This minimal subset does not require any external library (give a look at the .pro itself for more info).

Ended up getting with some errors:
Compiling MeshLab
Note:
Some plugins of MeshLab invokes functions exported by external libraries. You have to compile these libraries before attempting to compile the whole MeshLab's code. 

To compile MeshLab and all MeshLab plugins:
First compile the needed external libraries

cd MESHLAB_DIRECTORY/src/external
qmake -recursive external.pro
make

then compile MeshLab and its plugins
cd MESHLAB_DIRECTORY/src/
qmake -recursive meshlab_full.pro
make

Alternatively you can directly compile only a subset of the whole meshlab by using the meshlab_mini.pro. This minimal subset does not require any external library (give a look at the .pro itself for more info).



Then install it from the Ubuntu Software Center. This is easy few click installation.


Dec 20, 2011

Double sided disabled during printing in OSX

Whenever I add a new printer the double-sided option is generally disabled. It is not about installing the printer driver in OSX. Just let the system know that it should allow duplex printing. Change the settings from system preference. Here is the helpful instruction to enable the setting.
Reference: enabling-two-sided-duplex-printing-on-mac

May 9, 2011

Unix copy with regular expression

measlog0, measlog2, measlog3, measlog4, measlog5, measlog6, measlog7, measlog8, measlog9, measlog10, measlog11.

I'd like to copy these files to different directory, using "cp" command with some regular expressions:

1. cp measlog?? /tmp/testdir

2. cp measlog*[0-9] /tmp/testdir

3. cp measlog[0-90-9] /tmp/testdir

4. for fn in measlog*
do cp $fn /tmp/testdir
done

5. cp measlog[0-9] measlog[0-9][0-9] /somedir

echo cp measlog[0-9] measlog[0-9][0-9] /somedir

cp knows nothing about regular expresions (or more accurately, filename generation) so the echo will show you what cp will see.

Reference

Apr 29, 2011

Importing Bookmarks into "Opera"

Recently I am into the Opera Browser. I am liking it. Something happened to my Firefox browser. It just was not enabling the auto-suggestion, when I type in the names in the address bar. I tried suggested approaches (by doing a google) to solve this issue. It seems nothing was working for me. I am suspecting this misbehavior happened due to my sudden impulse for upgrading Firefox to its latest version(Version 4.0). Though it is good to enhance the browser to latest version, unfortunately it does not work on some bengali website that I accidentally visit (e.g., Sachalayatan et cetera). That led me to uninstall Version 4.0 and revert back into my older version.

I decided to import those saved bookmarks that I saved for a period of more than a year. Here are the steps I followed:
1. Go to the Bookmarks tab.
2. Select Manage Bookmarks.
3. Choose the File tab from several others(Add, Open, Properties, Delete, etc)
4. Pick Import from Firefox Bookmarks.(from the various others Import from Opera, Import from Safari etc)
5. Point it to the location of the bookmarks.html file that is saved in your computer. In Mac OSX,
it is stored in /Users/currentUser/Library/Application support/Profiles/xxxx.default/bookmarks.html
Alternately, I saved the bookmarks.html file in a known location by exporting it from the Firefox menus.

Helpful other hints.

Mar 27, 2011

Opera as default browser in Mac OSX

Mac OS X

You can set Opera as your default browser on your Macintosh by doing the following:
Open Safari.
In the Safari menu, select Preferences > General.
Under "Default Web Browser", select Opera.

Note: On Mac OS X 10.2, you can also select a default browser using System Preferences > Internet > Web > Default Web Browser.

Mar 22, 2011

My machine performance

Md-Alimoor-Rezas-MacBook:~ alimurreza$ top

Processes: 50 total, 2 running, 48 sleeping, 230 threads 13:09:45
Load Avg: 0.19, 0.22, 0.24 CPU usage: 8.83% user, 5.58% sys, 85.58% idle
SharedLibs: 5504K resident, 4608K data, 0B linkedit.
MemRegions: 18163 total, 584M resident, 15M private, 254M shared.
PhysMem: 446M wired, 1121M active, 277M inactive, 1843M used, 203M free.
VM: 117G vsize, 1040M framework vsize, 161523(0) pageins, 10405(0) pageouts.
Networks: packets: 1507335/1442M in, 1138087/181M out.
Disks: 181528/3605M read, 106422/6801M written.

Tuning Mac OSX performance
Insufficient RAM
Freeing space
Running maintenance script

Oct 21, 2010

Heap Memory and stack memory

I have read through several times about the distinction between the heap memory and stack memory. But when I recollect I always mix up 1 or 2 things that are stored there.
Here is the separation and please Alimoor never mix this up again.

Heap memory:
-------------
For dynamic allocation of memory.
1. Global variables
2. Static variables
3. Dynamically allocated memory (vector, queue in c++ or malloc, calloc, realloc in c).


Stack memory:
-------------
1. local variables
2. function parameters
3. function return address
3. LIFO order

Useful links:
vector : pass by value/pass by reference/pass by const reference
Stack/Heap : ee.hawaii.edu
Buffer overflow
C++ new
IBM Mac OS X compilers
Vector(C++)
stackoverflow
Learncpp:Nice article

Sep 29, 2010

OmniDiskSwapper: Hard disk space checker

I was running out of space of my Mackbook. I got the start up message when rebooted my laptop saying:

"Your start up disk is nearly full and you need to delete some items"

Then I found the OmniDiskSweeper. It is useful to scan your hard disk and know which files is eating up too much memory.

OmniDiskSweeper

Sep 24, 2008

Mac OS commands

Apple OS commands Link 1

Apple OS commands Link 2

1.showing all the process
top

2. to kill a process from top menu
kill processID

3.exit from an existing menu
q

4.clear screen
clear

5.killing a process from command promt
pkill -9 processname (kill dile kernel er kase request, but pkill -9 is force command)
pkill -SIGKILL processname(9 is the id of SIGKILL)

6a). list of every files in the current directory
ls filename

6b). list of files with the permission
ls -l filename

7.running a jar file form command prompt using the stack size and other sizes
java -jar Xms256m Xmx256m Xss64m ./jarname.jar

8. copy a folder from desktop to pendrive
cp -r /home/user12/Desktop/foldername /home/media/
-r stand for recursively copying all the files in the folder

9. unzip a zip file
unzip -x zipfilename.zip

10. adding environment variable
following to commands sets ARCHDIR and PATH environmental variables for nachos
export ARCHDIR=/home/mar343/mips-x86.linux-xgcc/mips-gcc
export PATH=/home/mar343/mips-x86.linux-xgcc/mips-gcc:$PATH

11. change permission of the file
chmod 644 profile
this will give the read/write permission to the user and read permission to group and other users

12. copy files from a remote host
scp aladin@uranus.cs.drexel.edu:/Users/aladin/data/a.png /Users/reza/Desktop/
It will prompt for password for the remote user name.
To do recursively add -r after scp.

// problem occurs when user do not have the permission on the disk to write.
// if the user still having an admin account, then create a directory with sudo
// command at the beginning. Then chmod the folder with 777. read/write/execute with
// sudo. Then write on the folder using sudo scp command.

13. renaming a folder
mv oldname newname


14. version of GCC.
g++ --version
or
gcc --version

15. compile C++ file using the specific gcc version
g++-verion for example
This command will compile a cpp file named test.cpp resulting in an object file named a.out

g++-4.2 -o a.out test.cpp

16. unzip a rar file
unrar e file.rar

17. see the value of an environment variable
echo $MAGICK_HOME

18. creating a directory
mkdir dir_name

19. making a symbolic link (not alias)
ln -s /Volumes/Macintosh\ HD/FolderName/ FolderNameAsLink
It will create a link name FolderNameAsLink. So when accessing
the folder using command prompt cd FolderNameAsLink, it will
go inside the /Volumes/Macintosh\ HD/FolderName/ folder.

20. remote login using ssh with X11 for display purpose.
ssh -X name@domain

21. disk space used+available
df -k or df -kh for human readability

22. du shows how much space one ore more files or current directories is using.
du -sh

23. multiple directory creation(used when i was compiling a java program)
mkdir -p src/test

24. show the hidden files
defaults write com.apple.finder AppleShowAllFiles TRUE
Then alt+click-on-the-Finder will show a refresh button. Clicking that will ensure that the hidden files are visible. Do the same command with FALSE to make invisible the hidden files.

25. Rich Socher's unix utils:
http://www.socher.org/index.php/Main/LinuxUnixCommands#ntoc5

26. X-server not displaying anything when I do
$ssh -x server
aparently the solution is to install XQuartz then everything works.
$echo $DISPLAY
$localhost:10.0 Reference

27.

28

29.

30.




Sep 17, 2008

Linux commands

1.showing all the process
$ top



2. to kill a process from top menu
$ kill processID



3.exit from an existing menu
$q



4.clear screen
$ clear



5.killing a process from command promt
$ pkill -9 processname (kill dile kernel er kase request, but pkill -9 is force command)
pkill -SIGKILL processname(9 is the id of SIGKILL)



6a). list of every files in the current directory
ls filename



6b). list of files with the permission
$ ls -l filename



7.running a jar file form command prompt using the stack size and other sizes
$ java -jar Xms256m Xmx256m Xss64m ./jarname.jar



8. copy a folder from desktop to pendrive
$ cp -r /home/user12/Desktop/foldername /home/media/
-r stand for recursively copying all the files in the folder



9. unzip a zip file
unzip -x zipfilename.zip



10. adding environment variable
following to commands sets ARCHDIR and PATH environmental variables for nachos
export ARCHDIR=/home/mar343/mips-x86.linux-xgcc/mips-gcc
export PATH=/home/mar343/mips-x86.linux-xgcc/mips-gcc:$PATH



11. change permission of the file
$ chmod 644 profile
this will give the read/write permission to the user and read permission to group and other users



12. copy files from a remote host
$ scp aladin@uranus.cs.drexel.edu:/Users/aladin/data/a.png /Users/reza/Desktop/
It will prompt for password for the remote user name.
To do recursively add -r after scp.



13. renaming a folder
$ mv oldname newname



14. List all the installed packages:
$ dpkg --list
list all the installed packages



dpkg --list | less
list all the installed packages with scolling up down and side navigation help allowed by less command



dpkg --list | grep -i 'http'



15. grep
General Regular ExpressionP
grep apple fin.txt: will find all the lines in the text file fin.txt that has apple in it.
grep -i apple fin.txt: will do the same thing and find all upper lower letter version of apple in fin.txt
grep -w apple *.txt will find apple as a word in all the text file in current directory.



16. | pipe command
connect multiple command



17. directory size information
$ du directoryName
$ du -c directoryName[summary of the total sizes in the end]
$ du -h directoryName[human readable form G=gigabyte M=megabyte K=kilobyte]
$ du -h -max-depth=1 /home/reza




18. Adding package name in environment variable:
$ export ROS_PACKAGE_PATH=~/ros/stacks/jsk_common:$ROS_PACKAGE_PATH



NOTICE: environment variable ROS_PACKAGE_PATH gets the value first. Then we add the old value of ROS_PACKAGE_PATH using the ':' operator. Value of environment variable is found by the $ character.



19. Changing the default editor:
      - open up the .bashrc file. vi ~/.bashrc
      - append the following line: export editor='gedit'



DON'T FORGET that you can always get the home directory just by writing '~/'. You don't have to write the tedious path '/home/your_name/'.



20. cpu information:
$ cat /proc/cpuinfo



21. find the file you are looking for:
$ locate libpng



22. find the string inside the library
$ strings /usr/lib/libstdc++.so.6 | grep GLIBCXX
Here I was looking for strings with prefix GLIBCXX

23. Memory usage: egrep --color 'Mem|Cache|Swap' /proc/meminfo

24. Memory usage
$ date; free -m


25. Video from images using ffmpeg
ffmpeg -r 24 -b 16777216 -i /home/luke/scenes/nodeParameters/preview/preview%05d.png /home/luke/Desktop/test.mp4
better reference
ffmpeg -r 10 -start_number 1 -i  %04d.png -vframes 250  dining_room_0022.mp4
-r : rate eg, 10 frames per sec here
-start_number: frame 1
-vframes: how many frames
  
26. Images from Video ffmpeg
$ ffmpeg -i manhattan_test1.wmv test%03d.jpg
reference


27. Day information of the year/month/day
$ date -d 2013-02-20
Answer: Wed Feb 20 00:00:00 EST 2013

28. Brace to create a copy for later reference.
$ cp -pv american_breakfast_at_SFO.odt{,-orig}

29. create a password hash string.
$ mkpasswd -m SHA-512 

30. Use your webcam as a mirror using mplayer
$ mplayer -vf mirror -v tv:// -tv device=/dev/video0:driver=v4l2

31.  File name with .odt extention
du -a | egrep '\.(odt)$'

32. extracting a .tgz file:
$ tar -xvf model.tgz
dont use tar -zxvf model.tgz

33. watching the copying file to the DEST folder
$ watch ls -l /DEST/
reference

34. Mounting the drive
$ sudo /bin/bash
$ ls /media/
$ mkdir /media/disk
$ mount -t ntfs-3g /dev/sda2 /media/disk -o force
Reference

35. Root access to the drive when running Ubuntu from the livecd(eg usb drive)
$ gksudo nautilus

Reference


36. single pdf from multiple docs
$ pdftk 0.pdf Md_Reza_1.pdf 2.pdf Md_Reza_3.pdf cat output Md_Reza_output.pdf


37. Change default wifi connection auto-connect:
1. choose the edit connections from the wifi icon top right. 2. select the wireless connection. 3. check the box connect automatically and for all users options and save. 4. deselect any other wifi connection whose above boxes are selected similarly.

38. snap a photo:
use vlc-player. Other options are: install software 'cheese'


39. un-installing the some libraries.
http://www.wikihow.com/Uninstall-Ubuntu-Software

40. find the installed lib* file:
$ locate libxml


41. find the file with some prefix/suffix inside some directory:
$ find  . -name '*joydeep*' |xargs -0  grep 'joydeep' 
grep : ./papers/valeso_joydeep_icra2012_kinectLocalization.pdf
./papers/valeso_joydeep_polygon_merging_iros2012_planes.pdf

Reference 

42. ps to pdf convert:
$ ps2pdf la.ps

43. root filemanger access to all volumes
$ gksudo nautilus 

43. change user ownership of the mounted file system
$ sudo chown your_user_name:your_user_name /media/New\ Volume

44.hardware details
$ sudo lshw 
 
45. See image file details
file a.png
a.png: PNG image data, 100 x 80, 8-bit grayscale, non-interlaced

46.changing forgotten password for ubuntu user account.
- get the grub menu (not exactly sure which button worked, ideally it should be holding the SHIFT key)
- enter recovery mode
- pick the option 'drop to root shell prompt'
- mount -o remount, rw / (mount the file system as read-write mode)
- chmod 640 /etc/shadow
- passwd USERNAME
- choose the new password

47. uncompressing a *.7z zipped file
install p7
$ sudo apt-get install p7zip-full

then uncompress using

$ 7za x matio.7z

48. trim the directory display info in terminal
PROMPT_DIRTRIM=1
put it in the .bashrc file.

49. add the file path from ~/.bashrc into PATH environment variable
$ source ~/.bashrc

50. deleting installed app: Open the synaptic package manager and search for the google earth package. Mark the package for complete removal and select apply.

alternately, open the .deb file you will be shown the uninstaller button.

51. changing the column number and row number of the terminal.
$ stty columns 160 rows 50


52. OpenGL version
$ glxinfo | grep "OpenGL version" 
53. switch user:
$ su mreza
Reference

54.  cuda supported gpu:
$ lspci | grep -i nvidia

55. supported version of linux:
$ uname -m && cat /etc/*release

56. linux kernel version:
$ uname -r

57. noveau present:
$lsmod | grep nouveau
If returns anything then it is present

58. Forcing to install something from .deb file after encountering error
$sudo dpkg -i teamviewer_*.deb

=>Errors were encountered while processing: teamviewer:i386
$ sudo apt-get update
$ sudo apt-get install -f

59. mount/umount:
Reference: https://www.cyberciti.biz/faq/mount-drive-from-command-line-ubuntu-linux/

60. rsync (remote versatile remote copying) (shows progress of copying 'cp' doesn't have --verbose mode)
$rsync -ah --progress source destination

Reference:

61. shutdown
$ sudo poweroff
or
$ sudo shutdown -p (shuts down now)

62. selecting 'lightdm' display manager over 'gdm3'
$ sudo dpkg-reconfigure lightdm

63. discovering bluetooth
reference:
reference:

64. change password
$sudo passwd user

65. changing gcc version
https://askubuntu.com/questions/26498/choose-gcc-and-g-version

66. version of the linux:
how-to-check-os-version-in-linux-command-line


67. remove suppressing command
$rm -rf ~/work/matlab

flag r: recursive
flag f: force warnings

68. file count in current directory
 $ ls -l | wc -l

69. "I think our server support p2p, but it's a little tricky. You can use this command to download torrent:"
$aria2c --file-allocation=none --torrent-file=yourTorrentFile.torrent --listen-port=XXXX

"For large files you will need --file-allocation=none flag to prevent pre-allocating space otherwise, it will freeze the whole server (not sure why).
Using an unused port with --listen-port flag."

70. copy by excluding a particular folder
$rsync -av --progress /SOURCE/PSMNet/* /DEST/PSMNet/ --exclude trained

71. 





Notebooks

illuminate.google.com notebooklm.google.com