Linux and Unix How To
| Linux and Unix |
|---|
| Linux and Unix How To's |
| General · Backup and Networking · Disk · Look & Feel · Scripting |
| Linux and Unix Topics |
| How To · Troubleshooting · Technical Notes |
| Related topics |
| Thunderbird and Lightning How To · AIX Notes · Networking How To's · iPhone How To's |
[edit] How to roll back to a stable version with aptitude aka How to downgrade a package
If you got it from a PPA that you need to disable, use ubuntu-tweak.
- Open Ubuntu Tweak, and select Package Cleaner in the list on the left.
- Click on the Purge PPAs button near the right.
- Select the PPA in question and click apply. You'll be prompted to downgrade related packages
To do it manually, first find the version you want to use:
sudo apt-cache showpkg <pkg>
Then install the version you need:
sudo aptitude install <pkg>=<version>
[edit] How to enable or disable KDE compositing from the command line
export DISPLAY=:0.0 qdbus org.kde.kwin /KWin org.kde.KWin.toggleCompositing
[edit] How to reinforce directory and file access limits
find . -perm /077 -type d -exec chmod -v 700 {} \;
find . -perm /077 -type f -exec chmod -v o-rwx,g-rwx {} \;
[edit] How to change system wide umask to the most secure one
Edit /etc/profile as root and set
umask 0077
For a personal umask edit ~/.bashrc
[edit] How to cp (copy) in a command line with a progress indicator
rsync -ghop --progress source destination
[edit] How to attach a console/stdout to an already running process
First find out what your console device is
tty
Then connect to the process and modify it's handles
gdb -p `pgrep processname`
p dup2(open("/dev/pts/3",1),0)
p dup2(open("/dev/pts/3",1),1)
p dup2(open("/dev/pts/3",1),2)
quit
Where /dev/pts/3 is the name of your stdout device. To check where a running process is sending it's redirects run
ls -al /proc/`pgrep processname`/fd
[edit] How to make an already running job survive a logout
Ctrl-Z to suspend it, then type
bg
to make it a background job. Then type
disown -a
to make it ignore SIGHUP signals sent on a shell logout (similar to nohup)
[edit] How to check Ubuntu version
lsb_release -a
[edit] How to install OpenCV 2.0 on Ubuntu 9.10 Karmic Koala
OpenCV is a widely used computer vision library for research and development. I've tried using instructions for installing it from the official manual, but it failed miserably. It seems that 2.0 code is incompatible with the latest incarnation of ffmpeg. Couple minutes in googling and I had it working.
UPDATE The following process describes building the latest stable version from the sources. There is an easier way tin install it by using a third-party repository. Configure it in with add-apt-repo and install.
Here is what needs to be done if you want to build OpenCV from sources:
Get all the prerequisites:
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg62-dev libtiff4-dev sudo apt-get build-dep libswscale-dev swig
Get OpenCV 2.0, and unpack it somewhere.
Fix ffmpeg links. Make sure you are root (sudo -s) and do the following:
mkdir /usr/include/ffmpeg ln -s /usr/include/libavcodec/avcodec.h /usr/include/ffmpeg/avcodec.h ln -s /usr/include/libavformat/avformat.h /usr/include/ffmpeg/avformat.h ln -s /usr/include/libavformat/avio.h /usr/include/ffmpeg/avio.h ln -s /usr/include/libavutil/avutil.h /usr/include/ffmpeg/avutil.h
Configure OpenCV. In the folder you've unpacked it to run:
./configure --prefix=/usr/local/opencv --enable-apps --enable-shared --enable-swscale --enable-gpl --with-swig sudo ln -s /usr/include/libswscale/swscale.h /usr/include/ffmpeg/swscale.h
Make and install it:
make sudo make installYou could also test it by running make test
Configure your system to look for opencv libraries:
echo /usr/local/opencv/lib > /etc/ld.so.conf.d/opencv.confReload the libraries and make sure opencv shows up now ldconfig -v | grep opencvYou may get warnings on unaccessible lib paths, that is ok. You are looking for a line that says "/usr/local/opencv/lib"
Set-up pkg-config:
echo 'export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv/lib/pkgconfig' >> /etc/bash.bashrc echo 'export PYTHONPATH=/usr/local/opencv/lib/python2.6/site-packages/opencv' >> /etc/bash.bashrcRestart your terminal to get the new paths
Test by building samples:
cd ~/Programs/OpenCV-2.0.0/samples/c . build_all.sh
You're done.
[edit] How to check why a system reboot/restart is required
The following will tell you which packages require a reboot
cat /var/run/reboot-required.pkgs
[edit] How to prevent a package from being upgraded
Normally it could be done with aptitude
sudo aptitude hold [packagename]
But sometimes aptitude does not work. Use dpkg:
sudo -s echo linux-image-generic hold | dpkg --set-selections
Check with
dpkgs --get-selection | grep linux-image-generic
Reset with
echo linux-image-generic install | dpkg --set-selections
[edit] How to change default java used on Ubuntu
Assuming you have more than one java installed. Run:
sudo update-alternatives --config java
Or if you want graphical interface do
sudo apt-get install galternatives galternatives
[edit] How to enable screen switching functionality on Thinkpads using Fn-F7
Only works for Thinkpads with Nvidia right now. Get disper either from its website or set the repos, apt-get update and then apt-get install. do as super user:
echo "event=ibm/hotkey HKEY 00000080 00001007" > /etc/acpi/events/ibmvideobtn echo "action=/home/CHANGE ME/bin/thinkpad-screen-switcher.sh fnf7 >/var/log/thinkpad-screen 2>&1" >> /etc/acpi/events/ibmvideobtn echo "echo enable,0x084e > /proc/acpi/ibm/hotkey" > /etc/acpi/resume.d/91-ibm-hotkey-enable.sh
Add manually "echo enable,0x084e > /proc/acpi/ibm/hotkey before the end /etc/rc.local for the mapping to survive reboot and suspend. thinkpad-screen-switcher.sh is the great Thinkpad Display Script written by Stuart Hopkins
[edit] How to forcefully clear memory used by kernel for caching
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches"
[edit] How to find out biggest memory consuming processes with ps
For the real memory:
sudo ps -eo pmem,vsize,pcpu,rss,vsize,args | sort -rnk 1 | head
For the virtual memory
sudo ps -eo vsize,pmem,pcpu,rss,vsize,args | sort -rn | head
[edit] How to remove Alt-F2 popup after having xfc installed
Run xfc_settings_editor Go to custom and delete the Alt-F2 entry
[edit] How to clean up disk space in Ubuntu
- Clean package infromation and obsolete/unused packages
sudo aptitude clean sudo aptitude autoclean sudo apt-get autoremove sudo apt-get install localepurge sudo localepurge sudo apt-get install deborphan sudo deborphan | xargs sudo apt-get -y remove --purge
Start Synaptic Package Manager. Click the Status button and remove all residiual configurations (if present)
- Clean kernels
Edit /boot/grub/menu.lst and change
# howmany=all
to
# howmany=2
then save it and run
sudo update-grub
this keeps the kernels installed, but limits your grub menu to the latest 2 kernels at all times.
- Other tools that could help: fslint, gtkorphan
[edit] How to add openclipart galleries to open office 3
Install first:
sudo apt-get install openclipart
then run
dpkg-query -L openclipart-openoffice.org
Note the many files in /usr/lib/openoffice/share/gallery/. You should see the same thing. In OpenOffice 3, go to Tools > Options. Click Paths in the left panel, then Gallery in the right. Click Edit. Add a new path '/usr/lib/openoffice/share/gallery' . After a few clicks of OK to accept the changes, restart open office.
[edit] How to edit an apt-get key
sudo gpg --keyring /etc/apt/trusted.gpg --trustdb-name /etc/apt/trustdb.gpg --edit-key 7EBC211F trust
[edit] How to lower ati power consumption
aticonfig --set-powerstate 1
[edit] How to save power under Linux on a ThinkPad
Ubuntu mostly has everything you need. You could get powertop and follow its recommendations. Alternatively you can go to [1], download debian package and install. Then edit
/etc/default/acpi-support
Set
ENABLE_LAPTOP_MODE=true.
[edit] How to set hardware time
echo "About to set date with following parameters :" echo "YEAR=$2" echo "MONTH=$3" echo "DAY=$4" echo "HOUR=$5" echo "MINUTE=$6" echo "SECOND=$7" date -s "YEAR.MONTH.DAY-HOUR$2.$3.$4-$5:$6:$7" > /dev/null hwclock -w
[edit] How to get a boot log in Ubuntu
Enable the bootlogd deamon by editing the file in /etc/defaults/bootlogd, and setting
BOOTLOGD_ENABLE=Yes
Reboot. The boot daemon is started at the beginning and stopped at the end of the system uptime. Check out /var/log/boot for all the informations that was pushed out during the boot time.
[edit] How to start OpenVPN on boot
sudo update-rc.d -n openvpn defaults 96 4
then
sudo update-rc.d openvpn defaults 96 4
|
|||||||||||