Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

[Origin]: http://askubuntu.com/questions/15433/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process

Remove your /var/lib/dpkg/lock file and force package reconfiguration.

sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a

It should work after this.

shareimprove this answer
Advertisements

Why use apt-get upgrade instead of apt-get dist-upgrade?

[Origin]: http://askubuntu.com/questions/194651/why-use-apt-get-upgrade-instead-of-apt-get-dist-upgrade

I typically upgrade my machines with:

sudo apt-get update && time sudo apt-get dist-upgrade

Below is an excerpt from man apt-get. Using upgrade keeps to the rule: under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. If that’s important to you, use apt-get upgrade. If you want things to “just work”, you probably want apt-get dist-upgrade to ensure dependencies are resolved.

To expand on why you’d want upgrade instead of dist-upgrade, if you are a systems administrator, you need predictability. You might be using advanced features like apt pinning or pulling from a collection of PPAs (perhaps you have an in-house PPA), with various automations in place to inspect your system and available upgrades instead of always eagerly upgrading all available packages. You would get very frustrated when apt performs unscripted behavior, particularly if this leads to downtime of a production service.

upgrade
    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. An update must be performed first so that
    apt-get knows that new versions of packages are available.

dist-upgrade
    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. So, dist-upgrade
    command may remove some packages. The /etc/apt/sources.list file
    contains a list of locations from which to retrieve desired package
    files. See also apt_preferences(5) for a mechanism for overriding
    the general settings for individual packages.
shareimprove this answer

Exclude packages from `apt-get upgrade`

[Origin]: http://askubuntu.com/questions/99774/exclude-packages-from-apt-get-upgrade

To hold a package:

In short: sudo apt-mark hold <package>

or

echo <package> hold | sudo dpkg --set-selections

To unhold a package:

In short: sudo apt-mark unhold <package>

or

echo <package> install | sudo dpkg --set-selections
shareimprove this answer

How can I change the date modified/created of a file?

[From]: http://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file

Easiest way – accessed modified will be the same:

touch -a -m t 201512180130.09 fileName.ext

Where:

-a = accessed
-m = modified
t  = timestamp - use [[CC]YY]MMDDhhmm[.ss] time format

If you wish to use NOW just drop the t and the timestamp

To verify they are all the same: stat fileName.ext

See: touch man

shareimprove this answer

Interactive Map of Linux kernel

From http://www.makelinux.com/kernel_map/intro

The interactive Linux kernel map helps you traverse complex interconnections between subsystems of the kernel while you explore its source code. A Linux hacker, trying to track down a bug or just understand how some subsystem works, can get exhausted just trying to figure out what invokes what — so the kernel map comes to the rescue!

The map depicts over 400 prominent functions and structures divided into major subsystems. You can zoom in on any function and move about the functions graphically. The relationships among all functions are shown through connecting lines, and clicking on any function takes you to source code in the Linux Cross Reference and the collection of Linux kernel documentation.

Introduction: Installing Java (JDK) and Android Studio on Arch Linux

http://dev.indywidualni.org/2015/02/introduction

Welcome, I’m Krzysztof, I live in Kraków (Poland) and a few weeks ago I decided to learn Java and Android. My programming experience is limited to C++ but it’s never too late to start. I’m gonna document problems I managed to resolve and show you some examples, especially code snippets appropriate for beginners. My main goal is to learn Android development, I’m also interested in Linux and Java. The operating system of my choice is Arch Linux.

At the links section you can find my Github account where I’m currently working on Facebook Lite, Web App for Android. I learnt a lot creating the app so it’s a great place to show you how it’s made and share my experience. But what is actually needed to start building Android apps? I personally recommend Android Studio by Google. It’s a great app for developers and the only recommended way of creating Android apps for now. But before you start you need Java Development Kit. I’m working on Arch Linux so now I’m gonna show you how to install Oracle Java (JDK) which is not present in Arch Linux (the system uses OpenJDK by default) and how to install Android Studio.

Now you are ready to go so it’s a perfect time to create your first Android app. Just create a new project with blank activity and test it on your device or start a new emulator. I’m not gonna write about the basic usage of Android Studio. It’s rather intuitive and well documented software. Instead of that I’ll share some links good to begin your programming journey.

  1. developer.android.com/training/index.html – you should begin here
  2. stackoverflow.com – it’s where you look for all the answers
  3. romannurik.github.io/AndroidAssetStudio/icons-launcher.html – Android Asset Studio: Launcher Icon Generator

Next time I will show you how to create an advanced WebView.

Manage Processes with killall and kill

https://www.linode.com/docs/tools-reference/tools/manage-processes-with-killall-and-kill

killall is a tool for ending running processes on your system based on name. In contrast, killterminates processes based on process ID number or “PID.” kill and killall can also send specific system signals to processes. Use killall and kill in conjunction with tools including ps to manage processes and end processes that have become stuck or unresponsive when necessary.

Usage

killall

The killall command takes the following form:

killall [process name]

Replace [process name] with the name of any process that you wish to terminate. killall will terminate all programs that match the name specified. Without arguments, killall sends SIGTERM, or signal number 15, which terminates running processes that match the name specified. You may specify a different signal using the -s option as follows:

killall -s 9 [process name]

This sends the SIGKILL signal which is more successful at killing some particularly unruly processes. You may also specify signals in one of the following formats:

killall -KILL [process name]
killall -SIGKILL [process name]
killall -9 [process name]

The above group of commands are equivalent.

kill

The kill command terminates individual processes as specified by their process ID numbers or “PIDs.” Commands take the following form:

kill [PID]

This sends SIGTERM to the PID specified. You may specify multiple PIDs on the command line to terminate processes with kill. You may also send alternate system signals with kill. The following examples all send the SIGKILL signal to the PID specified:

kill -s KILL [PID]
kill -KILL [PID]

System Signals

You may use kill and killall to send any of the following signals.

  1. SIGHUP
  2. SIGINT
  3. SIGQUIT
  4. SIGILL
  5. SIGTRAP
  6. SIGABRT
  7. SIGIOT
  8. SIGFPE
  9. SIGKILL
  10. SIGUSR1
  11. SIGSEGV
  12. SIGUSR2
  13. SIGPIPE
  14. SIGALRM
  15. SIGTERM
  16. SIGSTKFLT
  17. SIGCHLD
  18. SIGCONT
  19. SIGSTOP
  20. SIGSTP
  21. SIGTTIN
  22. SIGTTOU
  23. SIGURG
  24. SIGXCPU
  25. SIGXFSZ
  26. SIGVTALRM
  27. SIGPROF
  28. SIGWINCH
  29. SIGIO and SIGPOLL
  30. SIGPWR
  31. SIGSYS

Issue one of the following commands to get a list of all of the available signals:

kill -l
killall -l

If you need to convert a signal name into a signal number, or a signal number into a signal name consider the following examples:

$ kill -l 9
KILL

$ kill -l kill
9 

Finding Running Processes

You may use a utility like htop </using-linux/administration-basics#monitor_processes__memory__and_cpu_usage_with_htop> or top` to view a real time list of process and their consumption of system resources. You may also use the ps command to view processes that are currently running and their PIDs.

$ ps aux | grep "emacs" 
username  3896  0.0  2.2  56600 44468 ?        Ss   Sep30   4:29 emacs
username 22843  0.0  0.0   3900   840 pts/11   S+   08:49   0:00 grep emacs

This command filters the list of all processes that are currently running for the string emacs usinggrep. The number listed in the second column is the PID, which is 3896 in the case of the emacsprocess. The grep process will always match itself for a simple search, as in the second result. To view a hierarchical tree of all running processes, issue the following command:

ps auxf

Once you have obtained the PID or process name, use killall or kill to terminate the process as above.

Verifying Process Termination

The -w option to the killall command causes killall to wait until the process terminates before exiting. Consider the following command:

killall -w irssi

This command issues the SIGTERM system signal to the process with a name that matchesirssi.killall will wait until the matched processes have ended. If no process matches the name specified, killall returns an error message, as below:

$ killall -w irssi
irssi: no process found

This guide is published under a CC BY-ND 3.0 license.