Sunday, January 7, 2018

How to install a deb file

When you use apt to install a package, internally it uses dpkg. When you install a package using apt, it first creates a list of all the dependencies and downloads it from the repository.
Once the download is finished it calls dpkg to install all those files, satisfying all the dependencies.
So if you have a .deb file:
  • You can install it using sudo dpkg -i /path/to/deb/file followed by sudo apt-get install -f.
  • You can install it using sudo apt install ./name.deb (or /path/to/package/name.deb).
    With old apt-get versions you must first move your deb file to /var/cache/apt/archives/ directory. For both, after executing this command, it will automatically download its dependencies.
  • Install gdebi and open your .deb file using it (Right-click -> Open with). It will install your .deb package with all its dependencies.
    (Note: APT maintains the package index which is a database of available packages available in repo defined in /etc/apt/sources.list file and in the /etc/apt/sources.list.d directory. All these methods will fail to satisfy the software dependency if the dependencies required by the deb is not present in the package index.)

Why to use sudo apt-get install -f after sudo dpkg -i /path/to/deb/file (mentioned in first method). From man apt-get
 -f, --fix-broken
           Fix; attempt to correct a system with broken dependencies in place.
When dpkg install a package and package dependency is not satisfied, it leaves the package in unconfigured state and that package is considered as broken.
sudo apt-get install -f command tries to fix this broken package by installing the missing dependency.

Saturday, January 6, 2018

Installing WineHQ packages on Ubuntu

If you have previously installed a Wine package from another repository, please remove it and any packages that depend on it (e.g., wine-mono, wine-gecko, winetricks) before attempting to install the WineHQ packages, as they may cause dependency conflicts.
If your system is 64 bit, enable 32 bit architecture (if you haven't already):
sudo dpkg --add-architecture i386 
Add the repository:
wget -nc https://dl.winehq.org/wine-builds/Release.key
sudo apt-key add Release.key
sudo apt-add-repository https://dl.winehq.org/wine-builds/ubuntu/
Dialog-warning.svg On Linux Mint 17.x, the last line should be the following:
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ trusty main'
Dialog-warning.svg On Linux Mint 18.x, the last line should be the following:
sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'
Update packages:
sudo apt-get update
Then install one of the following packages:
Stable branch
sudo apt-get install --install-recommends winehq-stable
Development branch
sudo apt-get install --install-recommends winehq-devel
Staging branch
sudo apt-get install --install-recommends winehq-staging
If apt-get complains about missing dependencies, install them, then repeat the last two steps (update and install).

If you have previously used the distro packages, you will notice some differences in the WineHQ ones:
  • Files are installed to /opt/wine-devel.
  • Menu items are not created for Wine's builtin programs (winecfg, etc.), and if you are upgrading from a distro package that had added them, they will be removed. You can recreate them yourself using your menu editor.
  • Binfmt_misc registration is not added. Consult your distro's documentation for update-binfmts if you wish to do this manually.
  • WineHQ does not at present package wine-gecko or wine-mono. When creating a new wine prefix, you will be asked if you want to download those components. For best compatibility, it is recommended to click Yes here. If the download doesn't work for you, please follow the instructions on the Gecko and Mono wiki pages to install them manually.

Installing without Internet

To install Wine on an Ubuntu machine without internet access, you must have access to a second Ubuntu machine (or VM) with an internet connection to download the Wine .deb package and its dependencies.
The procedure goes like this: On the machine with internet, add the WineHQ PPA, then cache just the necessary packages without actually extracting them:
sudo add-apt-repository ppa:wine/wine-builds
sudo apt-get update
Then cache just the packages necessary for installing wine, without extracting them:
sudo apt-get clean
sudo apt-get --download-only install winehq-devel
sudo apt-get --download-only dist-upgrade
Copy all of the .deb files in /var/cache/apt/archives to a USB stick:
cp -R /var/cache/apt/archives/ /media/usb-drive/deb-pkgs/
Finally, on the machine without internet, install all of the packages from the flash drive:
cd /media/usb-drive/deb-pkgs
sudo dpkg -i *.deb
The same instructions can also be used for an offline installation of the `winehq-staging` packages.

Compiling WoW64

Ubuntu's implementation of Multiarch is still incomplete, so for now you can't simply install 32-bit and 64-bit libraries alongside each other. If you're on a 64-bit system, you'll have to create an isolated environment for installing and building with 32-bit dependencies. See Building Biarch Wine On Ubuntu for detailed instructions for Ubuntu using LXC, and Building Wine for general information.


Nhuoc diem cua cac repo cua Ubuntu

Tai qua cham
Giai phap:
add them repo khac ma tai phan mem

Google in Linux Mint

Why isn't Google included by default in Linux Mint?

Amongst commercial search engines, only the ones which share with Linux Mint the revenue Linux Mint users generate for them are included by default.

How can I add Google to Linux Mint?

Click here to add Google to your search engines.

Will Google be included by default in future releases of Linux Mint?

Yes, eventually all search engines will share the revenue our users generate for them and be included by default in Linux Mint. The process just takes time.

Sunday, November 5, 2017

APT (Debian)

The Advanced Package Tool, or APT, is a free software user interface that works with core libraries to handle the installation and removal of software on the Debian, Slackware and other Linux distributions.[3] APT simplifies the process of managing software on Unix-like computer systems by automating the retrieval, configuration and installation of software packages, either from precompiled files or by compiling source code.[3]
APT was originally designed as a front-end for dpkg to work with Debian's .deb packages, but it has since been modified to also work with the RPM Package Manager system via APT-RPM.[4] The Fink project has ported APT to Mac OS X for some of its own package management tasks,[5] and APT is also available in OpenSolaris.

Contents

Usage

There has been an apt program since version 1.0; apt is a collection of tools distributed in a package named apt. A significant part of apt is defined in a C++ library of functions; apt also includes command-line programs for dealing with packages, which use the library. Three such programs are apt, apt-get and apt-cache. They are commonly used in examples of apt because they are simple and ubiquitous. The apt package is of "important" priority in all current Debian releases, and is therefore installed in a default Debian installation. Apt can be considered a front-end to dpkg, friendlier than the older dselect front-end. While dpkg performs actions on individual packages, apt tools manage relations (especially dependencies) between them, as well as sourcing and management of higher-level versioning decisions (release tracking and version pinning).
APT is often hailed as one of Debian's best features,[6][7][8][9] which Debian developers attribute to the strict quality controls in Debian's policy.[10][11]
A major feature in APT is the way it calls dpkg — it does topological sorting of the list of packages to be installed or removed and calls dpkg in the best possible sequence. In some cases, it utilizes the --force options in dpkg. However, it only does this when it is unable to calculate how to avoid the reason dpkg requires the action to be forced.

Installing software

The user indicates one or more packages to be installed. Each package name is phrased as just the name portion of the package, not a fully qualified filename (for instance, in a Debian system, libc6 would be the argument provided, not libc6_1.9.6-2.deb). Notably, apt automatically gets and installs packages upon which the indicated package depends (if necessary). This was an original distinguishing characteristic of apt-based package management systems, as it avoided installation failure due to missing dependencies, a type of dependency hell.
Another such distinction is remote repository retrieval of packages. apt uses location configuration file (/etc/apt/sources.list) to locate the desired packages, which might be available on the network or a removable storage medium, for example, and retrieve them, and also obtain information about available (but not installed) packages.
apt provides other command options to override decisions made by apt-get's conflict resolution system. One option is to force a particular version of a package. This can downgrade a package and render dependent software inoperable, so the user must be careful.
Finally, the apt_preferences mechanism allows the user to create an alternative installation policy for individual packages.
The user can specify packages by POSIX regular expression.

apt-get

apt-get is the command line package management tool supplied with the Debian package apt. APT searches its cached list of packages and lists the dependencies that must be installed or updated.
Triggers are the treatment of deferred actions.
APT retrieves, configures and installs the dependencies automatically.

Update, upgrade and dist-upgrade

Other commands used in apt-get:
  • update is used to resynchronize the package index files from their sources. The lists of available packages are fetched from the location(s) specified in /etc/apt/sources.list. For example, when using a Debian archive, this command retrieves and scans the Packages.gz files, so that information about new and updated packages is available.
  • upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at their current version.
  • dist-upgrade, in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a "smart" conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files.[12] aptitude has a smarter dist-upgrade feature called full-upgrade.[13]

apt-file

apt-file is a command to find which package includes a specific file, or to list all files included in a package. It is packaged separately from the main APT utilities.
Example to find a package:
$ apt-file update         # Fetch the files installed by the packages in local cache

$ apt-file find vmlinuz   # Find all packages providing a filename vmlinuz
linux-image-4.8.0-17-generic: /boot/vmlinuz-4.8.0-17-generic
linux-image-4.8.0-17-lowlatency: /boot/vmlinuz-4.8.0-17-lowlatency
linux-image-4.8.0-19-generic: /boot/vmlinuz-4.8.0-19-generic
linux-image-4.8.0-19-lowlatency: /boot/vmlinuz-4.8.0-19-lowlatency
linux-signed-image-4.8.0-17-generic: /usr/lib/linux/vmlinuz-4.8.0-17-generic.efi.signature
linux-signed-image-4.8.0-17-lowlatency: /usr/lib/linux/vmlinuz-4.8.0-17-lowlatency.efi.signature
linux-signed-image-4.8.0-19-generic: /usr/lib/linux/vmlinuz-4.8.0-19-generic.efi.signature
linux-signed-image-4.8.0-19-lowlatency: /usr/lib/linux/vmlinuz-4.8.0-19-lowlatency.efi.signature
ltsp-client-core: /usr/share/ltsp/cleanup.d/50-vmlinuz
needrestart: /usr/lib/needrestart/vmlinuz-get-version

$ apt-file find /boot/vmlinuz-4.8.0-17-generic  # Find also from a full path
linux-image-4.8.0-17-generic: /boot/vmlinuz-4.8.0-17-generic

$ dpkg -S vmlinuz                               # dpkg is an alternative listing less packages
linux-image-4.8.0-16-generic: /boot/vmlinuz-4.8.0-16-generic
linux-image-4.8.0-17-generic: /boot/vmlinuz-4.8.0-17-generic
linux-image-4.8.0-11-generic: /boot/vmlinuz-4.8.0-11-generic
linux-image-4.4.0-9136-generic: /boot/vmlinuz-4.4.0-9136-generic
linux-image-4.8.0-19-generic: /boot/vmlinuz-4.8.0-19-generic

Configuration and files

/etc/apt has the apt configuration folders and files.
apt-config is the APT Configuration Query program.[14] apt-config dump shows the configuration.[15]

Files

  • /etc/apt/sources.list: Locations to fetch packages from.
  • /etc/apt/sources.list.d/: Additional source list fragments.
  • /etc/apt/apt.conf: APT configuration file.
  • /etc/apt/apt.conf.d/: APT configuration file fragments.
  • /etc/apt/preferences: version preferences file. This is where you would specify "pinning", i.e. a preference to get certain packages from a separate source or from a different version of a distribution.
  • /var/cache/apt/archives/: storage area for retrieved package files.
  • /var/cache/apt/archives/partial/: storage area for package files in transit.
  • /var/lib/apt/lists/: storage area for state information for each package resource specified in sources.list
  • /var/lib/apt/lists/partial/: storage area for state information in transit.

Sources

APT relies on the concept of repositories in order to find software and resolve dependencies. For apt, a repository is a directory containing packages along with an index file. This can be specified as a networked or CDROM location. The Debian project keeps a central repository of over 25,000 software packages ready for download and installation.
Any number of additional repositories can be added to APT's sources.list configuration file (/etc/apt/sources.list) and then be queried by APT. Graphical front-ends often allow modifying sources.list more simply (apt-setup). Once a package repository has been specified (like during the system installation), packages in that repository can be installed without specifying a source and will be kept up-to-date automatically.
In addition to network repositories, compact discs and other storage media (USB keydrive, hard disks...) can be used as well, using apt-cdrom[16] or adding file:/[17] to the source list file. Apt-cdrom can specify a different folder than a cd-rom, using the -d option (i.e. a hard disk or a USB keydrive). The Debian CDs available for download contain Debian repositories. This allows non-networked machines to be upgraded. Also one can use apt-zip.
Problems may appear when several sources offer the same package(s). Systems that have such possibly conflicting sources can use APT pinning to control which sources should be preferred.

APT pinning

The APT pinning feature allows administrators to force APT to choose particular versions of packages which may be available in different versions from different repositories. This allows administrators to ensure that packages are not upgraded to versions which may conflict with other packages on the system, or that have not been sufficiently tested for unwelcome changes.
In order to do this, the pins in APT's preferences file (/etc/apt/preferences) must be modified,[18] although graphical front-ends often make pinning simpler.

Front-ends

Synaptic Package Manager is one of the front-ends available for APT
Several other front-ends to APT exist, which provide more advanced installation functions and more intuitive interfaces. These include:
APT front-ends can:
  • Search for new packages.
  • Upgrade packages.
  • Install or remove packages.
  • Upgrade the whole system to a new release.
APT front-ends can list the dependencies of packages being installed or upgraded, ask the administrator if packages recommended or suggested by newly installed packages should be installed too, automatically install dependencies and perform other operations on the system such as removing obsolete files and packages.

History

The original effort that led to the apt-get program was the dselect replacement project known by its codename deity.[24] This project was commissioned by Brian White, the Debian Release Manager at the time. The very first functional version of apt-get was called dpkg-get and was only intended to be a test program for the core library functions that would underpin the new UI.[25]
Much of the original development of APT was done on IRC, so records have been lost. The 'Deity Creation Team' mailing list archives include only the major highlights.
The Deity name was abandoned as the official name for the project due to concerns over the religious nature of the name. The APT name was eventually decided after considerable internal and public discussion. Ultimately the name was proposed on IRC, accepted and then finalized on the mailing lists.[26]
APT was introduced in 1998 and original test builds were circulated on IRC. The first Debian version that included it was Debian 2.1, released on 9 March 1999.[27]
In the end the original goal of the Deity project of replacing the dselect user interface (UI) was a failure. Work on the UI portion of the project was abandoned (the UI directories were removed from the CVS system) after the first public release of apt-get. The response to APT as a dselect method and a command line utility was so great and positive that all development efforts focused on maintaining and improving the tool. It was not until much later that several independent people built UIs on top of libapt-pkg.
Eventually, a new team picked up the project, began to build new features and released version 0.6 of APT which introduced the Secure APT feature, using strong cryptographic signing to authenticate the package repositories.[28]

dpkg

dpkg is the software at the base of the package management system in the free operating system Debian and its numerous derivatives. dpkg is used to install, remove, and provide information about .deb packages.
dpkg (Debian Package) itself is a low level tool. APT (Advanced Packaging Tool), a higher level tool, is more commonly used than dpkg as it can fetch packages from remote locations and deal with complex package relations, such as dependency resolution. Frontends for APT like aptitude (ncurses) and synaptic (GTK+) are used for their friendlier interfaces.
The Debian package "dpkg" provides the dpkg program, as well as several other programs necessary for run-time functioning of the packaging system, including dpkg-deb, dpkg-split, dpkg-query, dpkg-statoverride, dpkg-divert and dpkg-trigger.[5] It also includes the programs such as update-alternatives and start-stop-daemon. The install-info program used to be included as well, but was later removed[6] as it is now developed and distributed separately.[7] The Debian package "dpkg-dev" includes the numerous build tools described below.

Contents

History

dpkg was originally created by Ian Murdock in January of 1994 as a Shell script,[1] Matt Welsh, Carl Streeter and Ian Murdock then rewrote it in Perl,[8] and then later the main part was rewritten in C by Ian Jackson in 1994.[9][10] The name dpkg was originally the short for "Debian package", but the meaning of that phrase has evolved significantly, as dpkg the software is orthogonal to the deb package format as well as the Debian Policy Manual which defines how Debian packages behave in Debian.

Example use

To install a .deb package:
dpkg -i filename.deb
where filename.deb is the name of the Debian package (such as pkgname_0.00-1_amd64.deb).
The list of installed packages can be obtained with:
dpkg -l [optional pattern]
To remove an installed package:
dpkg -r packagename

Development tools

dpkg-dev contains a series of development tools required to unpack, build and upload Debian source packages.[11] These include:
  • dpkg-source packs and unpacks the source files of a Debian package.
  • dpkg-gencontrol reads the information from an unpacked Debian tree source and generates a binary package control package, creating an entry for this in Debian/files.
  • dpkg-shlibdeps calculates the dependencies of runs with respect to libraries.
  • dpkg-genchanges reads the information from an unpacked Debian tree source that once constructed creates a control file (.changes).
  • dpkg-buildpackage is a control script that can be used to construct the package automatically.
  • dpkg-distaddfile adds a file input to debian/files.
  • dpkg-parsechangelog reads the changes file (changelog) of an unpacked Debian tree source and creates a conveniently prepared output with the information for those changes.

Database

The dpkg database is located under /var/lib/dpkg; the "status" file contains the list of installed software on the current system. There is no information about repositories in this database.[12]

Thursday, October 12, 2017

How to Find Files and Folders in Linux Using the Command Line

Most people use a graphical file manager to find files in Linux, such as Nautilus in Gnome, Dolphin in KDE, and Thunar in Xfce. However, there are several ways to use the command line to find files in Linux, no matter what desktop manager you use.
01_search_in_nautilus

Using the Find Command

The “find” command allows you to search for files for which you know the approximate filenames. The simplest form of the command searches for files in the current directory and recursively through its subdirectories that match the supplied search criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria.
Typing the following command at the prompt lists all files found in the current directory.
find .
The dot after “find” indicates the current directory.
02_find_dot_command
To find files that match a specific pattern, use the -name argument. You can use filename metacharacters (such as * ), but you should either put an escape character ( \ ) in front of each of them or enclose them in quotes.
For example, if we want to find all the files that start with “pro” in the Documents directory, we would use the cd Documents/ command to change to the Documents directory, and then type the following command:
find . -name pro\*
All files in the current directory starting with “pro” are listed.
NOTE: The find command defaults to being case sensitive. If you want the search for a word or phrase to be case insensitive, use the -iname option with the find command. It is the case insensitive version of the -name command.
03_find_using_name_argument
If find doesn’t locate any files matching your criteria, it produces no output.
The find command has a lot of options available for refining the search. For more information about the find command, run man find  in a Terminal window and press Enter.

Using the Locate Command

The locate command is faster than the find command because it uses a previously built database, whereas the find command searches in the real system, through all the actual directories and files. The locate command returns a list of all path names containing the specified group of characters.
The database is updated periodically from cron, but you can also update it yourself at any time so you can obtain up-to-the-minute results. To do this, type the following command at the prompt:
sudo updatedb
Enter your password when prompted.
04_updating_locate_database
The basic form of the locate command finds all the files on the file system, starting at the root, that contain all or any part of the search criteria.
locate mydata
For example, the above command found two files containing “mydata” and one file containing “data.”
05_using_basic_locate_command
If you want to find all files or directories that contain exactly and only your search criteria, use the -b option with the locate command, as follows.
locate -b ‘\mydata’
The backslash in the above command is a globbing character, which provides a way of expanding wildcard characters in a non-specific file name into a set of specific filenames. A wildcard is a symbol that can be replaced by one or more characters when the expression is evaluated. The most common wildcard symbols are the question mark ( ? ), which stands for a single character and the asterisk ( * ), which stands for a contiguous string of characters. In the above example, the backslash disables the implicit replacement of “mydata” by “*mydata*” so you end up with only results containing “mydata.”
06_locate_with_b_option
The mlocate command is a new implementation of locate. It indexes the entire file system, but the search results only include files to which the current user has access. When you update the mlocate database, it keeps timestamp information in the database. This allows mlocate to know if the contents of a directory changed without reading the contents again and makes updates to the database faster and less demanding on your hard drive.
When you install mlocate, the /usr/bin/locate binary file changes to point to mlocate. To install mlocate, if it’s not already included in your Linux distribution, type the following command at the prompt.
sudo apt-get install mlocate
NOTE: We will show you a command later in this article that allows you to determine where the executable for a command is located, if it exists.
07_installing_mlocate
The mlocate command does not use the same database file as the standard locate command. Therefore, you may want to create the database manually by typing the following command at the prompt:
sudo /etc/cron.daily/mlocate
The mlocate command will not work until the database is created either manually or when the script is run from cron.
08_creating_the_database
For more information about either the locate or the mlocate command, type man locate or man mlocate  in a Terminal window and press Enter. The same help screen displays for both commands.

Using the Which Command

The “which” command returns the absolute path of the executable that is called when a command is issued. This is useful in finding the location of an executable for creating a shortcut to the program on the desktop, on a panel, or other place in the desktop manager. For example, typing the command which firefox displays the results shown in the image below.
09_using_which_command
By default, the which command only displays the first matching executable. To display all matching executables, use the -a option with the command:
which -a firefox
You can search for multiple executables using at once, as shown in the following image. Only the paths to executables found are displayed. In the example below, only the “ps” executable was found.
10_using_which_command_multiple_programs
NOTE: The which command only searches the current user’s PATH variable. If you search for an executable that is only available for the root user as a normal user, no results will display.
For more information about the which command, type “man which” (without the quotes) at the command prompt in a Terminal window and press Enter.

Using the Whereis Command

The whereis command is used to find out where the binary, source, and man page files for a command are located. For example, typing whereis firefox at the prompt displays results as shown in the following image.
11_using_whereis_command
If you want only the path to the executable to display, and not the paths to the source and the man(ual) pages, use the -b option. For example, the command whereis -b firefox will display only /usr/bin/firefox as the result. This is handy because you will most likely search for a program’s executable file more often than you would search for source and man pages for that program. You can also search for only the source files ( -s ) or for only the man pages ( -m ).
For more information about the whereis command, type man whereis in a Terminal window and press Enter.

Understanding the Difference Between the Whereis Command and the Which Command

The whereis command shows you the location for the binary, source, and man pages for a command, whereas the which command only shows you the location of the binary for the command.
The whereis command searches through a list of specific directories for the binary, source, and man files whereas the which command searches the directories listed in the current user’s PATH environment variable. For the whereis command, the list of specific directories can be found in the FILES section of the man pages for the command.
When it comes to results displayed by default, the whereis command displays everything it finds whereas the which command only displays the first executable it finds. You can change that using the -a option, discussed earlier, for the which command.
Because the whereis command only uses paths hard-coded into the command, you may not always find what you are looking for. If you are searching for a program you think might be installed in a directory not listed in the man pages for the whereis command, you might want to use the which command with the -a option to find all occurrences of the command throughout the system.