tisdag 24 februari 2015

Recept på klassisk sockerkaka som är god till kaffet.

Recept på klassisk sockerkaka som är god till kaffet. Tillsammans med färska bär och vispad grädde blir kakan en fin dessert.

Receptet gäller för 10 bitar

Ingredienser

  • 75 g Arla® Svenskt Smör
  • 1 dl Arla® mjölk
  • 2 st ägg
  • 2 dl strösocker
  • 2 tsk vaniljsocker
  • 3 dl vetemjöl
  • 1 12 tsk bakpulver

Gör så här:

Sätt ugnen på 175°. Smörj och bröa en form som rymmer ca 1,5 liter. Smält smöret, häll i mjölken och låt det svalna. Vispa ägg och socker ljust och pösigt, gärna med elvisp. Tillsätt vaniljsocker eller rivet citronskal, mjölet blandat med bakpulvret och mjölkblandningen. Rör snabbt ihop till en jämn smet, häll den i formen. Grädda i nedre delen av ugnen i ca 35 min.

Tips:

Vaniljsockret kan ersättas med rivet skal av 1/2 citron.

Linux - Bash alias - mkdir (name = date)

add to your alias file:

alias datefolder="sudo mkdir $(date '+%d-%b-%Y')"

tool to create a Firefox extension (.xpi) from a greasemonkey script.

Type in the appropriate details below, you may leave the default random GUID if you do not have one, or replace it with your own value, which you should definitely do for upgrades to an existing extension.

Link

Linux - Debian Linux apt-get package management cheat sheet

by on May 9, 2005 · 20 comments· LAST UPDATED September 9, 2012

in , ,

Both Debian and Ubuntu Linux provides a number of package management tools. This article summaries package management command along with it usage and examples for you.

  • apt-get : APT is acronym for Advanced Package Tool. It supports installing packages over internet using ftp or http protocols. You can also upgrade all packages in a single operations, which makes it even more attractive.
  • dpkg : Debian packaging tool which can be use to install, query, uninstall packages.
  • Gui tools: You can also try GUI based or high level interface to the Debian GNU/Linux package system. Following list summaries them:

    • aptitude: It is a text-based interface to the Debian GNU/Linux package system.
    • synaptic: GUI front end for APT

Red hat Linux package names generally end in .rpm, similarly Debian package names end in .deb, for example:

apache_1.3.31-6_i386.deb

Where,

  1. apache : Package name
  2. 1.3.31-6 : Version number
  3. i386 : Hardware Platform on which this package will run (i386 == intel x86 based system)
  4. .deb : Extension that suggest it is a Debian package

Remember whenever I refer .deb file it signifies complete file name, and whenever I refer package name it must be first part of .deb file. For example, when I refer to a package sudo it means sudo only and not the .deb file i.e. sudo_1.6.7p5-2_i386.deb. You can find out debian package name with the following command:

apt-cache search {package-name}
apt-cache search apache

Finally, most of the actions listed in this post are written with the assumption that they will be executed by the root user running the bash or any other modern shell.

apt-get add a new package

Add a new package called samba. The syntax is:

 apt-get install {package-name} 

To install a package called samba, run:

# apt-get install samba

apt-get remove the package called samba but keep the configuration files

The syntax is:

 apt-get remove {package-name} 

Example:

# apt-get remove samba

apt-get remove (erase) package and configuration file

The syntax is:

 apt-get --purge remove {package-name} 

Example:

# apt-get --purge remove samba

apt-get update (upgrade) package

The syntax is:

 apt-get upgrade 

To upgrade individual package called sudo, enter:
# apt-get install sudo

apt-get display available software updates

Following command will display the list of all available upgrades (updates) using -u option, if you decided to upgrade all of the shown packages just hit 'y'

# apt-get upgrade samba

However if you just wish to upgrade individual package then use apt-get command and it will take care of rest of your worries:

 apt-get install {package-name} 

dpkg command to get package information such as description of package, version etc.

The syntax is:

 dpkg --info {.deb-package-name} 

Example:

# dpkg --info sudo_1.6.7p5-2_i386.deb | less

List all installed packages

The syntax is:

dpkg -l

Example:

# dpkg -l

To list individual package try such as apache

# dpkg -l apache

You can also use this command to see (verify) if package sudo is install or not (note that if package is installed then it displays package name along with small description):

# dpkg -l | grep -i 'sudo'

To list packages related to the apache:

# dpkg -l '*apache*'

List files provided (or owned) by the installed package (for example what files are provided by the installed samba package). The syntax is:

 dpkg -L {package-name} 

Example:

# dpkg -L samba

(H) List files provided (or owned) by the package (for example what files are provided by the uninstalled sudo package). The syntax is:

 dpkg --contents {.deb-package-name} 

Example:

# dpkg --contents sudo_1.6.7p5-2_i386.deb

Find, what package owns the file /bin/netstat?

The syntax is:

 dpkg -S {/path/to/file} 

Example:

# dpkg -S /bin/netstat

Search for package or package description

Some times you don't know package name but aware of some keywords to search the package. Once you got package name you can install it using apt-get -i {package-name} command:

 apt-cache search "Text-to-search"apt-cache search "httpd"apt-cache search "web server"apt-cache search "web server"| grep something 

Find out all the Debian package which can be used for Intrusion Detection

Type the following command:

# apt-cache search "Intrusion Detection"

Find out all sniffer packages, run:

# apt-cache search sniffer

Find out if Debian package is installed or not (status)

The syntax is:

 dpkg -s {package-name} |  grep Status 

Example:

# dpkg -s samba| grep Status

List ach dependency a package has...

Display a listing of each dependency a package has and all the possible other packages that can fulfill that dependency. You hardly use this command as apt-get does decent job fulfill all package dependencies. The syntax is:

 apt-cache depends package 

Display dependencies for lsof and mysql-server packages:

# apt-cache depends lsof
# apt-cache depends mysql-server

Further reading

Linux - Bash add ppa if not already exist

måndag 23 februari 2015

Linux - Should I use "apt-get remove" or "apt-get purge"?

If you have customized the package/software at all, either by editing the config files directly, or via a GUI, you may want to keep your customizations. Usually in Unix/Linux systems, configurations are saved in text files, even if the configuration/customization is done via the GUI.

Each Debian binary deb package has a list of files which it identifies as config files. dpkg, and thus apt honor this identification when removing packages, and also on upgrades. By default apt/dpkg will not remove config files on package removal. You have to request a purge. On upgrade it will ask you to choose between the current version and the new version (if they differ) before overwriting config files. Even in that case, it saves a copy of the original file. Here Debian is trying to help you, based on the assumption that your config files may contain valuable information.

So, if you have not configured the package, or you don't want to keep your configurations, you can use apt-get purge.

If you do keep the config files, then if/when you reinstall the package, Debian will attempt to reuse the saved configuration information. If the version of the package you are trying to (re)install has config files that conflict with the configuration files that are already installed, it will again ask you before overwriting, as it does on upgrade.

Minor comment: if you have removed the package and later want to remove the config files, you will need to call dpkg directly, because apt will not remove the config files if the package is no longer installed.

dpkg -P packagename

should remove the config files for you in that case.

Are these equivalent: apt-get remove --purge APP VS apt-get purge APP? –  mini Jul 26 '14 at 8:18
    
@mini: Yes. Quote from the apt-get man page, "remove --purge is equivalent to the purge command." –  Faheem Mitha Jul 26 '14 at 8:39

From the man page of apt-get:

   remove
        remove is identical to install except that packages are removed 
        instead of installed. Note that removing a package leaves its 
        configuration files on the system. If a plus sign is appended to the 
        package name (with no intervening space), the identified package 
        will be installed instead of removed.

   purge
        purge is identical to remove except that packages are removed and 
        purged (any configuration files are deleted too).

I would tend to use purge if you tend to not want to keep any configuration files around.

purge remove configuration files of your packages, but remove keep configuration files of your package.

But advantages or disadvantages: It's related to your system, your packages, your machine, install it or not, and so on.


Linux - Installera Linux-program med Aptitude

Av i Linux - Senaste uppdatering: November 28, 2012 

För er som gillar lite mer kraft bakom dina verktyg kommer du säkert att uppskatta Aptitude front-end för paketet apt hanteringssystem. Aptitude är baserad på ncurses datorterminal bibliotek så att du vet att det är en pseudo-hybrid mellan konsol och gui. Aptitude har en kraftfull söksystem samt en enastående ncurses baserat menysystem som gör att du kan flytta runt markeringar med tabbtangenten och piltangenterna.

Men tror inte, när du skjuter upp Aptitude, du kommer att hälsas med en sexig grafiskt gränssnitt. Nej, när du startar upp det här programmet du kommer att bli teleporterad tillbaka till mitten av 90-talet när front-end-applikationer var bara anländer på scenen. Men Aptitude är så mycket mer än så. Aptitude är ett kraftfullt verktyg för att hjälpa dig att använda apt pakethanteringssystem.

För att öppna Aptitude måste du först öppna ett terminalemulator (t.ex. aterm, gnome-terminal eller konsole). Jag varnar dig, om du är som jag och använder aterm i fullt utvecklad öppenhet Aptitude kan titta på lite konstigt. Så istället ska du skjuta upp en annan terminal eller använd aterm utan insyn.

För att starta upp aptitude behöver du root eller sudo åtkomst. Använder sudo du skulle börja Aptitude som så: sudo aptitude.

Aptitude Main Window

Aptitude Huvudfönstret

Det finns två huvuddelar att fokusera på. Först är huvudfönstret. Det är där du kommer att se en lista över de vad som finns tillgängligt. Som ni kan se från bilden ovan finns uppgraderingspaket, nya paket, etc. Vad du inte ser är Aptitude menyn. För att komma åt den här menyn måste du slå Ctrl-T kombination (dvs Ctrl plus "t" -tangenten samtidigt.) När du öppnar upp Aptitude menyn du navigerar här menyn med piltangenterna.

Aptitude Menu

Aptitude Meny

Innan du faktiskt komma in installation av paket med Aptitude, måste du välja paket att installera. Du gör detta utanför menyn i huvudfönstret. Utan menyn öppnar du kan gå upp och ned fönsterposter med piltangenterna. När du landar på en post som du vill utöka du trycker på Enter. Låt oss installera något.

Använda piltangenterna flytta ner till "inte installerat paket" och tryck på Retur. Detta kommer att expandera för att avslöja ett antal undermenyer. Nu rulla ned till nätet undermeny och tryck på Enter. Ännu en undermeny visas innehåller tre poster. Flytta till "main" huvudposten och tryck Enter för att avslöja alla möjliga program som ska installeras.

Network Applications Available

Network Applications Tillgängliga

Låt oss installera Gobby (en textredigerare / källa redaktör som kan göra online-samarbete). Med piltangenterna flytta ner tills du ser Gobby posten. När du hittar Gobby slog på Enter som kommer att avslöja alla de blodiga detaljerna bakom Gobby.

Gobby details

Gobby detaljer

Detta bör berätta allt du behöver för att hjälpa dig att göra beslutet att installera eller inte installera Gobby. Låt oss installera det.

För att välja ett program för installation hit "+" knappen (du behöver använda Skift-tangenten för detta) för att markera paket för installation. Hit nu "g" tangenten och installationen ska börja. Låt dig inte luras när det verkar som om Aptitude har hoppat av ncurses läge och är i full konsolläge, återgår den till det ncurses ära när efter att du slog på Enter när du blir uppmanad (när installationen är klar.)

När installationen är klar kommer du tillbaka till beskrivningen av det paket du just installerat. För att gå tillbaka till huvudfönstret kan du öppna upp menyn (Ctrl-t) och sedan använda högerpilen gå till View posten. Använda på nedknappen välj "Föregående" för att gå till föregående skärm. Du kan också träffa F7 för samma åtgärd.

Och där är du, du bara har installerat ett program med Aptitude. Naturligtvis Aptitude är mycket kraftfullare än detta. I senare artiklar kommer vi att diskutera söka, uppgradering, ta bort, och mycket mer med Aptitude.

Under tiden, ha kul installation med Aptitude!

Linux Extract MySelf *.run files to folder

sh zdeb.x86_64.run --target /media/hynt/EXTERN/

4shared - slipp vänta på din nerladdning

http://www.4shared.com/file/TW4Juqw0ce/4sharedcompremiumdownload.html

Linux - A tool to turn a Greasemonkey user script into a Firefox (XPI) extension.

Live:
https://arantius.com/misc/greasemonkey/script-compiler.php

Download:
https://github.com/arantius/greasemonkey-compiler.git

torsdag 19 februari 2015

Linux - How To Boot An ISO File From Your Hard Drive Via Grub2 Under Ubuntu/Linux Mint

In this tutorial, we will see how to boot an iso file stored in your hard drive via the Grub2 boot menu. This tip is useful for users who don't have a live CD/DVD/USB, only the iso file of Ubuntu/Linux Mint. In this example, we will see how to boot from Ubuntu 12.10 iso file.

Getting Started

Create a directory named in your root folder using this command:
sudo mkdir /
Now move your iso file (ubuntu-12.10-desktop-i386.iso) to this folder. Cd to the folder containing your iso file and run this command:
sudo mv ubuntu-12.10-desktop-i386.iso
Identify now your hard disk with this command from the terminal:
 sudo fdisk -l
For my system, the hard disk is mounted as /dev/sda1:
Edit now the grub.cfg file with this command:
sudo gedit /boot/grub/grub.cfg
At the end of the file, add these lines:
menuentry "Ubuntu 12.10 LiveCD
    set root=(hd0,
    loopback loop/iso/ubuntu-12.10-desktop-i386.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/ubuntu-12.10-desktop-i386.iso noprompt noeject
    initrd (loop)/casper/initrd.lz 
}
You can change "Ubuntu 12.10 LiveCD" to any name of your choice. For the "set root=(hd0," option, I inserted the number "" referring to my hard disk (dev/sda1). If your hard disk is mounted as /dev/sda2, then set "", for /dev/sda5, set "" and so on.

Save your file and exit. Then reboot your system and hold down the Shift key to bring up the Grub boot menu. As you can see, I can now boot into the Ubuntu 12.10 iso file stored in my hard drive from the Grub menu:
That's it!

Linux - skapa en DEB Fil / Ändrar


#Packar upp remastersys till mappen remastersys
sudo dpkg -x remastersys-install.deb remastersys
dh_make
#packar upp DEBIAN
sudo dpkg-deb -e remastersys.deb

#Flyttar DEBIAN till remastersys   
sudo mv DEBIAN /remastersys/ 
#Skapar den nya Deb filen
sudo dpkg-deb -b remastersys remastersys-mint-17.1-kde.deb 

sudo autoreconf -i -f
sudo dh_auto_configure
./configure && make
./configure --prefix=/usr
sudo dpkg-depcheck -d ./configure
sudo debian/rules binary-arch         
sudo dpkg-buildpackage -B
sudo debian/rules clean
sudo dh_auto_configure command dpkg-depcheck -d ./configure

#Gör en deb fil av redan installerat program 

fakeroot -u dpkg-repack aptoncd checkinstall 


apt-get install  pbuilder-uml cowdancer
deb-src http://ftp.nl.debian.org/debian/ squeeze-updates main contrib non-free
sudo pbuilder create

#Source mapp till deb fil
sudo cd grub-customizer-4.0.6
sudo cmake . && make     

Linux - Tor Browser Bundle Ubuntu PPA

 Author: Andrew| Date: Monday, December 02, 2013

Tor Browser Bundle is a web browser based on Firefox ESR (Firefox with extended support), configured to protect users' privacy and anonymity by using Tor and Vidalia, tools that come bundled with it. The bundle also includes 4 Firefox extensions: TorButton, TorLauncher, NoScript and HTTPS-Everywhere.
Tor Browser Bundle Ubuntu
When launching TorBrowser, it automatically starts the bundled Tor, anonymizing the origin of your traffic and encrypting everything inside the Tor network. Because the traffic between the Tor network and its final destination is not encrypted, Tor Browser ships with HTTPS-Everywhere, an extension produced as a collaboration between The Tor Project and the Electronic Frontier Foundation that encrypts your communications with many major websites, making your browsing more secure.
Once you close TorBrowser, the list of visited websites and the cookies are deleted.
Tor Browser Bundle is easy to run on Ubuntu / Linux, but to make it integrate with the menu / Dash and for easier updates (since you must manually download and install newer versions), I've created an Ubuntu PPA so you can easily install and stay up to date with the latest Tor Browser Bundle.
The Ubuntu package uses the tor-browser-en AUR script, based on work by Alessio Sergi, Benjamin Drung and Max Roder (many thanks!). That's because Tor Browser Bundle runs from a single folder where it creates temporary files, etc., and with the script I mentioned, Tor Browser is automatically installed (or updated) to your home folder the first time you launch it.
But that's not something you need to worry about, as everything is done in the background so all you have to do is add the PPA, install Tor Browser Bundle and start the browser from the menu / dash, like with any other application.
Important notes: 
  • because there are separate packages for the supported languages, the Ubuntu PPA packages only support English;
  • any TorBrowser changes you make (bookmarks, addons you install, etc.) are deleted on upgrade, unfortunately there's no way around this due to the way TorBrowser works.

Install Tor Browser Bundle in Ubuntu or Linux Mint via PPA

To add the WebUpd8 Tor Browser Bundle PPA and install the application in Ubuntu / Linux Mint and derivatives, use the following commands in a terminal:
sudo add-apt-repository ppa:webupd8team/tor-browser
sudo apt-get update
sudo apt-get install tor-browser

Removing Tor Browser Bundle

Removing Tor Browser Bundle requires, besides removing the installed package, to also remove the ~/.tor-browser-en folder - that's where the package is installed after you run it from the menu / Dash for the first time. So if you want to remove Tor Browser Bundle, close it and use the following commands:
sudo apt-get remove tor-browser
rm -r ~/.tor-browser-en

Linux - How To Install Oracle Java 8 In Debian Via Repository [JDK8]

Oracle Java 8 was released yesterday and it can be installed in Debian by using the WebUpd8 Java PPA repository.

Usually, the packages available in Launchpad PPAs don't support Debian because they are built against specific Ubuntu libraries, but since the WebUpd8 Oracle Java PPA contains just an installer, it works on Debian too.

Using this PPA repository, you'll be able to install Oracle Java 8 (which includes both JRE8 and JDK8) in Debian for both 32bit and 64bit as well as ARM (ARM v6/v7 Hard Float ABI - there's no JDK 8 ARM Soft Float ABI archive available for download on Oracle's website).

The installer automatically downloads and installs Oracle JDK8, but no actual Java files are available in our repository (that's not allowed by the Oracle Java license).

For Ubuntu / Linux Mint installation instructions, see: Install Oracle Java 8 In Ubuntu Via PPA Repository [JDK8]


Install Oracle Java 8 (both JDK8 and JRE8) in Debian


Oracle Java 8 installed Debian
Tested on Debian Wheezy but it should work with any Debian version

To add the WebUpd8 Oracle Java PPA repository and install Oracle Java 8 in Debian, use the following commands:
su -echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.listecho "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.listapt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886apt-get updateapt-get install oracle-java8-installerexit

And that's it, Oracle Java 8 should now be installed and you should get automatic updates for future Oracle Java 8 versions, under Debian.

Tip: if you're behind a firewall / router that blocks some of the redirects required to download the Oracle Java archive, you can download the JDK tar.gz archive manually and place it under /var/cache/oracle-jdk8-installer - then, installing the "oracle-java8-installer" package will use the local archive instead of trying it to download it itself.

You can check out the Java version on your system by using these commands:
java -version
This should display something like this:
java version "1.8.0_31"Java(TM) SE Runtime Environment (build 1.8.0_31-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
Or:
javac -version
Which will display:
javac 1.8.0_31

For how to install Oracle Java 7 in Debian, see THIS article.


How to accept the Oracle JDK8 license automatically


The Oracle Java 8 installer requires you to accept the Oracle license before the installation begins. If for some reason you want to accept the license automatically, you can use the following command:
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections


How to set the Java environment variables


There is a package in our repository that automatically sets the Java 8 environment variables and sets JDK8 as the default JDK. To install it, use the following command:
sudo apt-get install oracle-java8-set-default
If you've already installed oracle-java6-set-default or oracle-java7-set-default, they will be automatically removed when installing oracle-java7-set-default (and the environment variables will be set for Oracle Java 8 instead).

dont work try

apt-get download update-sun-jre

onsdag 18 februari 2015

Linux Simple Bash h CP backup script

Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. clear
  2. kalladir=home/hynt
  3. backupdir=media/hynt/EXTERN/backup
  4. now=$(date +"%m_%d_%Y")
  5.  
  6. #Om mappen inte finns skapa den, detta är för slippa gnället om att mappen redan finns
  7.             [ ! -d  /$backupdir/$now/ ] && mkdir -p /$backupdir/$now/
  8.   [ ! -d /$backupdir/$now/Hämtningar/ ] && mkdir -p /$backupdir/$now/Hämtningar/
  9.     [ ! -d /$backupdir/$now/Dokument/ ] && mkdir -p /$backupdir/$now/Dokument/
  10.       [ ! -d /$backupdir/$now/Bilder/ ] && mkdir -p /$backupdir/$now/Bilder/
  11.        [ ! -d /$backupdir/$now/Musik/ ] && mkdir -p /$backupdir/$now/Musik/
  12.          [ ! -d /$backupdir/$now/PDF/ ] && mkdir -p /$backupdir/$now/PDF/
  13.      [ ! -d /$backupdir/$now/Projekt/ ] && mkdir -p /$backupdir/$now/Projekt/
  14.    [ ! -d /$backupdir/$now/Skrivbord/ ] && mkdir -p /$backupdir/$now/Skrivbord/
  15.     [ ! -d /$backupdir/$now/archives/ ] && mkdir -p /$backupdir/$now/archives/
  16.          [ ! -d /$backupdir/$now/tmp/ ] && mkdir -p /$backupdir/$now/tmp/
  17.     [ ! -d /$backupdir/$now/.mozilla/ ] && mkdir -p /$backupdir/$now/.mozilla/
  18. [ ! -d /$backupdir/$now/.thunderbird/ ] && mkdir -p /$backupdir/$now/.thunderbird/
  19.     [ ! -d /$backupdir/$now/archives/ ] && mkdir -p /$backupdir/$now/archives/
  20.     [ ! -d /$backupdir/$now/packages/ ] && mkdir -p /$backupdir/$now/packages/
  21.  
  22. echo "---------------------------------------------"
  23. echo "From: /$kalladir/"
  24. echo "To: /$backupdir/$now/"
  25. echo "---------------------------------------------"
  26. echo "Backup Folder: Bilder" && sudo cp -R -n /$kalladir/Bilder/ /$backupdir/$now/
  27. echo "Backup Folder: Dokument" && sudo cp -R -n /$kalladir/Dokument/ /$backupdir/$now/
  28. echo "Backup Folder: Hämtningar" && sudo cp -R -n /$kalladir/Hämtningar/ /$backupdir/$now/
  29. echo "Backup Folder: Musik" && sudo cp -R -n /$kalladir/Musik/ /$backupdir/$now/
  30. echo "Backup Folder: PDF" && sudo cp -R -n /$kalladir/PDF/ /$backupdir/$now/
  31. echo "Backup Folder: Projekt" && sudo cp -R -n /$kalladir/Projekt/ /$backupdir/$now/
  32. echo "Backup Folder: Skrivbord" && sudo cp -R -n /$kalladir/Skrivbord/ /$backupdir/$now/
  33. echo "Backup Folder: tmp" && sudo cp -R -n /$kalladir/tmp/ /$backupdir/$now/
  34. echo "Backup Folder: Video" && sudo cp -R -n /$kalladir/Video/ /$backupdir/$now/
  35. echo "Backup Folder: .mozilla" && sudo cp -R -n /$kalladir/.mozilla/ /$backupdir/$now/
  36. echo "Backup Folder: .thunderbird" && sudo cp -R -n /$kalladir/.thunderbird/ /$backupdir/$now/
  37. echo "Backup File: .bash_aliases" && sudo cp -R -n /$kalladir/.bash_aliases /$backupdir/$now/
  38. echo "Backup File: .bashrc " && sudo cp -R -n /$kalladir/.bashrc /$backupdir/$now/
  39. echo "Backup Folder: .archives" && sudo cp -R -n /var/cache/apt/archives/*.deb /$backupdir/$now/archives/
  40.  
  41. cd /$backupdir/$now/
  42. sudo dpkg --get-selections > /$backupdir/$now/packages/Package.list
  43. sudo cp -R /etc/apt/ /$backupdir/$now/packages/
  44. sudo apt-key exportall > /$backupdir/$now/packages/Repo.keys

Linux - How to Backup and Restore Your Apps and PPAs in Ubuntu Using Aptik

00_lead_image_aptik

If you need to reinstall Ubuntu or if you just want to install a new version from scratch, wouldn’t it be useful to have an easy way to reinstall all your apps and settings? You can easily accomplish this using a free tool called Aptik.

Aptik (Automated Package Backup and Restore), an application available in Ubuntu, Linux Mint, and other Debian- and Ubuntu-based Linux distributions, allows you to backup a list of installed PPAs (Personal Package Archives), which are software repositories, downloaded packages, installed applications and themes, and application settings to an external USB drive, network drive, or a cloud service like Dropbox.

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

To install Aptik, you must add the PPA. To do so, press Ctrl + Alt + T to open a Terminal window. Type the following text at the prompt and press Enter.

sudo apt-add-repository –y ppa:teejee2008/ppa

Type your password when prompted and press Enter.

01_command_to_add_repository

Type the following text at the prompt to make sure the repository is up-to-date.

sudo apt-get update

02_update_command

When the update is finished, you are ready to install Aptik. Type the following text at the prompt and press Enter.

sudo apt-get install aptik

NOTE: You may see some errors about packages that the update failed to fetch. If they are similar to the ones listed on the following image, you should have no problem installing Aptik.

03_command_to_install_aptik

The progress of the installation displays and then a message displays saying how much disk space will be used. When asked if you want to continue, type a “y” and press Enter.

04_do_you_want_to_continue

When the installation if finished, close the Terminal window by typing “Exit” and pressing Enter, or by clicking the “X” button in the upper-left corner of the window.

05_closing_terminal_window

Before running Aptik, you should set up a backup directory on a USB flash drive, a network drive, or on a cloud account, such as Dropbox or Google Drive. For this example, will will use Dropbox.

06_creating_backup_folder

Once your backup directory is set up, click the “Search” button at the top of the Unity Launcher bar.

07_opening_search

Type “aptik” in the search box. Results of the search display as you type. When the icon for Aptik displays, click on it to open the application.

08_starting_aptik

A dialog box displays asking for your password. Enter your password in the edit box and click “OK.”

09_entering_password

The main Aptik window displays. Select “Other…” from the “Backup Directory” drop-down list. This allows you to select the backup directory you created.

NOTE: The “Open” button to the right of the drop-down list opens the selected directory in a Files Manager window.

10_selecting_other_for_directory

On the “Backup Directory” dialog box, navigate to your backup directory and then click “Open.”

NOTE: If you haven’t created a backup directory yet, or you want to add a subdirectory in the selected directory, use the “Create Folder” button to create a new directory.

11_choosing_directory

To backup the list of installed PPAs, click “Backup” to the right of “Software Sources (PPAs).”

12_clicking_backup_software_sources

The “Backup Software Sources” dialog box displays. The list of installed packages and the associated PPA for each displays. Select the PPAs you want to backup, or use the “Select All” button to select all the PPAs in the list.

13_selecting_all_software_sources

Click “Backup” to begin the backup process.

14_clicking_backup_for_all_software_sources

A dialog box displays when the backup is finished telling you the backup was created successfully. Click “OK” to close the dialog box.

A file named “ppa.list” will be created in the backup directory.

15_closing_finished_dialog_software_sources

The next item, “Downloaded Packages (APT Cache)”, is only useful if you are re-installing the same version of Ubuntu. It backs up the packages in your system cache (/var/cache/apt/archives). If you are upgrading your system, you can skip this step because the packages for the new version of the system will be newer than the packages in the system cache.

Backing up downloaded packages and then restoring them on the re-installed Ubuntu system will save time and Internet bandwidth when the packages are reinstalled. Because the packages will be available in the system cache once you restore them, the download will be skipped and the installation of the packages will complete more quickly.

If you are reinstalling the same version of your Ubuntu system, click the “Backup” button to the right of “Downloaded Packages (APT Cache)” to backup the packages in the system cache.

NOTE: When you backup the downloaded packages, there is no secondary dialog box. The packages in your system cache (/var/cache/apt/archives) are copied to an “archives” directory in the backup directory and a dialog box displays when the backup is finished, indicating that the packages were copied successfully.

16_downloaded_packages_backed_up

There are some packages that are part of your Ubuntu distribution. These are not checked, since they are automatically installed when you install the Ubuntu system. For example, Firefox is a package that is installed by default in Ubuntu and other similar Linux distributions. Therefore, it will not be selected by default.

Packages that you installed after installing the system, such as the package for the Chrome web browser or the package containing Aptik (yes, Aptik is automatically selected to back up), are selected by default. This allows you to easily back up the packages that are not included in the system when installed.

Select the packages you want to back up and de-select the packages you don’t want to backup. Click “Backup” to the right of “Software Selections” to back up the selected top-level packages.

NOTE: Dependency packages are not included in this backup.

18_clicking_backup_for_software_selections

Two files, named “packages.list and “packages-installed.list”, are created in the backup directory and a dialog box displays indicating that the backup was created successfully. Click “OK” to close the dialog box.

NOTE: The “packages-installed.list” file lists all the packages. The “packages.list” file also lists all the packages, but indicates which ones were selected.

19_software_selections_backed_up

To backup settings for installed applications, click the “Backup” button to the right of “Application Settings” on the main Aptik window. Select the settings you want to back up and click “Backup”.

NOTE: Click the “Select All” button if you want to back up all application settings.

20_backing_up_app_settings

The selected settings files are zipped into a file called “app-settings.tar.gz”.

21_zipping_settings_files

When the zipping is complete, the zipped file is copied to the backup directory and a dialog box displays telling you that the backups were created successfully. Click “OK” to close the dialog box.

22_app_settings_backed_up

Themes from the “/usr/share/themes” directory and icons from the “/usr/share/icons” directory can also be backed up. To do so, click the “Backup” button to the right of “Themes and Icons”. The “Backup Themes” dialog box displays with all the themes and icons selected by default. De-select any themes or icons you don’t want to back up and click “Backup.”

22a_backing_up_themes_and_icons

The themes are zipped and copied to a “themes” directory in the backup directory and the icons are zipped and copied to an “icons” directory in the backup directory. A dialog box displays telling you that the backups were created successfully. Click “OK” to close the dialog box.

22b_themes_and_icons_backed_up

Once you’ve completed the desired backups, close Aptik by clicking the “X” button in the upper-left corner of the main window.

23_closing_aptik

Your backup files are available in the backup directory you chose.

24_backup_files_in_directory

When you re-install your Ubuntu system or install a new version of Ubuntu, install Aptik on the newly installed system and make the backup files you generated available to the system. Run Aptik and use the “Restore” button for each item to restore your PPAs, applications, packages, settings, themes, and icons.

LInux - Poppler is a pdf rendering library based on xpdf pdf viewer. [poppler-utils]

Poppler is a pdf rendering library based on xpdf pdf viewer.

this package contains command line utilities (based on poppler) for getting information of pdf documents, convert them to other formats, or manipulate them:
* pdfdetach -- lists or extracts embedded files (attachments)
* pdffonts -- font analyzer
* pdfimages -- image extractor
* pdfinfo -- document information
* pdfseparate -- page extraction tool
* pdftocairo -- pdf to png/jpeg/pdf/ps/eps/svg converter using cairo
* pdftohtml -- pdf to html converter
* pdftoppm -- pdf to ppm/png/jpeg image converter
* pdftops -- pdf to postscript (ps) converter
* pdftotext -- text extraction
* pdfunite -- document merging tool

Linux - Rensa terminalens history med bash

Rensa det aktuella skalet historia: 
 history -c 
 
När du loggar ut, är din nuvarande skal historia bifogas ~ / .bash_history,
vilket är en cache av tidigare skal "historier, till ett maximalt antal (se HISTFILESIZE i" Mannen bash ").

Om du vill ta bort historiken helt och hållet, då du i huvudsak har att tömma ut ~ / .bash_history som många
av de ovanstående poster har föreslagit.
Såsom:
 
 history -c && history -w 
Detta raderar det aktuella skalet historia och sedan tvingar det aktuella skalet historia (tom) för att skriva
över ~ / .bash_history .... eller för att vara mer exakt, tvingar den att 

skriva över HISTFILE (vilka standard ~ / .bash_history).
Hoppas att detta hjälper.

gjorde en alias : i min   .bash_aliases
alias clearhist='history -c && history -w' 
 
en annan skriver att fysiskt radera bash filen enligt     

Linux - BASH - erhålla extern ip-nummer

#!/bin/bash 
echo "Your External ip:"
dig +short myip.opendns.com @resolver1.opendns.com

Linux - Sätt ihop flera pdf filler till en med pdfunite

pdfunite version 0.24.5
Copyright 2005-2013 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC
Usage: pdfunite [options] <PDF-sourcefile-1>..<PDF-sourcefile-n> <PDF-destfile>
  -v             : print copyright and version info
  -h             : print usage information
  -help          : print usage information
  --help         : print usage information
  -?             : print usage information

alias pdfbundle='sudo pdfunite *.pdf output.pdf'

måndag 16 februari 2015

Linux - Bash .sh Easily modify dependencies of a .deb file

#!/bin/bashEDITOR=geditif [[ -z "$1" ]]; then  echo "Syntax: $0 debfile"  exit 1fiDEBFILE="$1"TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1OUTPUT=`basename "$DEBFILE" .deb`.modfied.debif [[ -e "$OUTPUT" ]]; then  echo "$OUTPUT exists."  rm -r "$TMPDIR"  exit 1fidpkg-deb -x "$DEBFILE" "$TMPDIR"dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIANif [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then  echo DEBIAN/control not found.  rm -r "$TMPDIR"  exit 1fiCONTROL="$TMPDIR"/DEBIAN/controlMOD=`stat -c "%y" "$CONTROL"`$EDITOR "$CONTROL"if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then  echo Not modfied.else  echo Building new deb...  dpkg -b "$TMPDIR" "$OUTPUT"firm -r "$TMPDIR"

fredag 13 februari 2015

Linux - pdfiff / pdf-diff - Receive PDF 2 and wonder what the changes are to PDF 1

pdfdiff.py

A Python script to inspect the difference between two PDF files.             
sudo apt-get install pdfdiff

pdf-diff

Bash script to inspect the difference between two PDF files in the terminal.
sudo apt-get install pdf-diff             


torsdag 12 februari 2015

Linux - Refresh Alias from Bash

. /home/$USER/.bash_aliases

Linux - problem starta firefox som root / säger att den redan körs

#!/bin/bash
clear
echo "                                                         "
echo "                                                         "
echo "                          ''~''                          "
echo "                         ( o o )                         "
echo " +------------------.oooO--(_)--Oooo.------------------+ "
echo " |                                                     | "
echo " |     LINUX..                           BASH...       | "
echo " |                      .oooO                          | "
echo " |                    (   )   Oooo.                    | "
echo " +---------------------\ (----(   )--------------------+ "
echo "                        \_)    ) /                       "
echo "                              (_/                        "
echo "           http://verklighetochdrom.blogspot.se/         "            
echo "                                                         "
echo "                  hynt@speed-mailer.com                  "

# Check if user is is running as root.  If not warning message, Exit
if [ $UID -ne 0 ]
    then
        echo -e "\033[31mYou MUST be root\033[m"
        sleep 15
        exit 0
fi
#[-Vem Är du-]------------------------------------------
function findUser() {
    thisPID=$$
    origUser=$(whoami)
    thisUser=$origUser

    while [ "$thisUser" = "$origUser" ]
    do
        ARR=($(ps h -p$thisPID -ouser,ppid;))
        thisUser="${ARR[0]}"
        myPPid="${ARR[1]}"
        thisPID=$myPPid
    done

    getent passwd "$thisUser" | cut -d: -f1
}
user=$(findUser)
echo "logged in: $user"
#-------------------------------------------------------
sudo chown -R $user:$user /home/$user/.mozilla
echo "Rättigheter till .mozzila ändrade"

files=`find ~/.mozilla -name "*lock"`
for file in `echo $files`
do
    echo "removing $file..."
    rm "$file"
done


Linux - Ändra beroenden i *.deb fil med bash

#!/bin/bash

EDITOR=nano

if [[ -z "$1" ]]; then
  echo "Syntax: $0 debfile"
  exit 1
fi

DEBFILE="$1"
TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
#OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb
OUTPUT="."

#if [[ -e "$OUTPUT" ]]; then
#  echo "$OUTPUT exists."
#  rm -r "$TMPDIR"
#  exit 1
#fi

dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN

if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then
  echo DEBIAN/control not found.

  rm -r "$TMPDIR"
  exit 1
fi

CONTROL="$TMPDIR"/DEBIAN/control

MOD=`stat -c "%y" "$CONTROL"`
$EDITOR "$CONTROL"

if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then
  echo Not modfied.
else
  echo Building new deb...
  dpkg -b "$TMPDIR" "$OUTPUT"
fi

rm -r "$TMPDIR"

Linux - Glöm Docker LXC-DOCKER är bättre

What is lxc:

  The container technology is actively being pushed into the mainstream linux
  kernel. It provides the resource management through the control groups  aka
  process containers and resource isolation through the namespaces.

  The  linux  containers, lxc, aims to use these new functionalities to pro-
  vide a userspace container object which provides full  resource  isolation
  and resource control for an applications or a system.

  The first objective of this project is to make the life easier for the ker-
  nel developers involved in the containers project and  especially  to  con-
  tinue  working  on  the  Checkpoint/Restart  new features. The lxc is small
  enough to easily manage a container with simple command lines and  complete
  enough to be used for other purposes.

PDF

onsdag 11 februari 2015

Linux - Get a list of all packages last installed

awk '!/^Commandline:|^Start-Date:|^End-Date:|^Upgrade:|^Error:/ { gsub( /\([^()]*\)/ ,"" );gsub(/ ,/," ");sub(/^Install:/,""); print}' /var/log/apt/history.log

tisdag 10 februari 2015

Linux - Vem är jag /home/user/ men sudo whoami säger root - FIX bash

$SUDO_USER doesn't work if you are using sudo su -.
It also requires multiple checks - if $USER == 'root' then get $SUDO_USER.
Instead of the command whoami use who am i. This runs the who command filtered for the current session. It gives you more info than you need. So, do this to get just the user:

who am i | awk '{print $1}'
 
Alternatively (and simpler) you can use logname. It does the same thing as the above statement.

This gives you the username that logged in to the session.
These work regardless of sudo or sudo su [whatever]. It also works regardless of how many times su and sudo are called.


 #----------------------------------------------------------
#Ta reda på vem du är
function findUser() {
    thisPID=$$
    origUser=$(whoami)
    thisUser=$origUser

    while [ "$thisUser" = "$origUser" ]
    do
        ARR=($(ps h -p$thisPID -ouser,ppid;))
        thisUser="${ARR[0]}"
        myPPid="${ARR[1]}"
        thisPID=$myPPid
    done

    getent passwd "$thisUser" | cut -d: -f1
}
user=$(findUser)
echo "logged in: $user"
#----------------------------------------------------------

Linux - 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X

by on June 11, 2012 · 144 comments· LAST UPDATED December 9, 2014

An alias is nothing but shortcut to commands. The alias command allows user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display list of all defined aliases. You can add user defined aliases to ~/.bashrc file. You can cut down typing time with these aliases, work smartly, and increase productivity at the command prompt.

Linux - 20 Unix Command Line Tricks – Part I

by on January 13, 2015 · 7 comments· LAST UPDATED January 14, 2015

Let us start new year with these Unix command line tricks to increase productivity at the Terminal. I have found them over the years and I'm now going to share with you.

unix-command-line-tricks.001

Deleting a HUGE file