Login loop issue on Ubuntu

Had an issue with Ubuntu 14.04 version where in login into the system would result in the screen going through various screens and end up back at login page. I had previously had the same issue but was able to resolve it with the help of my friend. This time I thought I’d try to fix this myself and was able to faster than I thought.

Here’s how I resolved it after going through a few solutions :-

So basically lightdm is the display manager which comes by default with 14.04. So when you google for lightdm here’s what you find …

LightDM is an X display manager that aims to be lightweight, fast, extensible and multi-desktop. It uses various front-ends to draw login interfaces, also called Greeters.

Basically this package manages the login interface.To me that’s not a show stopper, in fact all my work starts after login.So I just thought I’d try another display manager. There are different display managers that work with ubuntu, another one being gdm. I just ran the following command to remove lightdm and install gdm.

CNTRL + ALT + F1 launches the terminal window even when user is’nt logged in.

sudo apt-get purge lightdm && sudo apt-get install gdm

This fixed my issue. Now I’m able to login to my machine without a prob. Case closed!

Advertisements

How to remove an application completely from linux

  • apt-get remove packagename will remove the binaries, but not the configuration or data files of the package packagename. It will also leave dependencies installed with it on installation time untouched.
  • apt-get purge packagename  or apt-get remove --purge packagenamewill remove about everything regarding the package packagename, but not the dependencies installed with it on installation. Both commands are equivalent.Particularly useful when you want to ‘start all over’ with an application because you messed up the configuration. However, it does not remove configuration or data files residing in users home directories, usually in hidden folders there. There is no easy way to get those removed as well.
  • apt-get autoremove  removes orphaned packages, i.e. installed packages that used to be installed as an dependency, but aren’t any longer. Use this after removing a package which had installed dependencies you’re no longer interested in.
  • aptitude remove packagename  or aptitude purge packagename (likewise)will also attempt to remove other packages which were required by packagename on but are not required by any remaining packages.

And many more exist. Lower-level dpkg-commands can be used (advanced), or GUI tools like Muon, Synaptic, Software Center, etc. There’s no single ‘correct way’ of removing applications or performing other tasks interacting with your package management.

The list you found are just examples. Make sure you understand the meanings and try out what it wants to do before accepting the action (you need to press Y before it actually performs the actions as proposed).

The asterisk version in the question is probably wrong; apt-get accepts a regular expression and not a glob pattern as the shell. So what happens with

sudo apt-get remove application*

is the following:

  1. The shell tries to expand application* looking at the files in the current directory. If (as is normally the case) it finds nothing, it returns the glob pattern unaltered (supposing bashwith default behavior here — zsh will error out).
  2. apt-get will remove the packages whose name contains a string that satisfies the regular expression application*, that is, applicatio followed by an arbitrary number of n: applicatio, application, applicationn, libapplicatio, etc.
  3. To see how this can be dangerous, try (without root for double safety) apt-get -s remove "wine*" (-s will simulate the thing instead of doing it) — it will say is going to remove all packages that has “win” in their name and the dependant, almost the entire system…

Probably, the command that was meant is really

 sudo apt-get remove "^application.*"

(note the quotes and the dot) which will remove all packages whose name starts with application.

These commands,

sudo updatedb                  # 

are completely outside the scope of the package management. Do not remove files belonging to packages without using the package manager! It will get confused and is the wrong way to do things.

If you don’t know to which package a file belongs, try this:

dpkg -S /path/to/file

Shell Scripting – Grep

Grep searches the named input FILEs (or standard input if no files are named, or the file name is given) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.

More info can be seen at http://www.tutorialspoint.com/unix_commands/grep.htm

Eg : grep “STRING %pathtofile% | cut -d -f2

        Search for a string in a file  , the “pipe” connects the stdout of one command to the stdin of another , cut with dlimiter ” and select the second term (-f2)

In the shell, what is “ 2>&1 ”?

1 is stdout. 2 is stderr.

Here is one way to remember this construct (altough it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as “redirect stderr to a file named 1“. & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.

Courtesy: Stackoverflow

Stronger Fundamentals : tee command in shell scripts

Tee Command Usage Examples

Tee command is used to store and view (both at the same time) the output of any other command.

Tee command writes to the STDOUT, and to a file at a time as shown in the examples below.

Example 1: Write output to stdout, and also to a file

The following command displays output only on the screen (stdout).

$ ls

The following command writes the output only to the file and not to the screen.

$ ls > file

The following command (with the help of tee command) writes the output both to the screen (stdout) and to the file.

$ ls | tee file

Example 2: Write the output to two commands

You can also use tee command to store the output of a command to a file and redirect the same output as an input to another command.

The following command will take a backup of the crontab entries, and pass the crontab entries as an input to sed command which will do the substituion. After the substitution, it will be added as a new cron job.

$ crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab –

Misc Tee Command Operations

By default tee command overwrites the file. You can instruct tee command to append to the file using the option –a as shown below.

$ ls | tee –a file

You can also write the output to multiple files as shown below.

$ ls | tee file1 file2 file3

***********************************************************************************************************************************************************

Courtesy: http://linux.101hacks.com/

Stronger Fundamentals: The null Device in Unix Systems

/dev/null is a simple device (implemented in software and not corresponding to any hardware device on the system).

  • /dev/null looks empty when you read from it.
  • Writing to /dev/null does nothing: data written to this device simply “disappear.”

Often a command’s standard output is silenced by redirecting it to /dev/null, and this is perhaps thenull device’s commonest use in shell scripting:

command > /dev/null

You’re using /dev/null differently. cat /dev/null outputs the “contents” of /dev/null, which is to say its output is blank. > messages (or > wtmp) causes this blank output to be redirected to the file on the right side of the > operator.

Since messages and wtmp are regular files (rather than, for example, device nodes), they are turned into blank files (i.e., emptied).

You could use any command that does nothing and produces no output, to the left of >.

An alternative way to clear these files would be to run:

echo -n > messages
echo -n > wtmp

The -n flag is required, or echo writes a newline character.

(This always works in bash. And I believe the default sh in every GNU/Linux distribution and other Unix-like system popularly used today supports the -n flag in its echo builtin. But jlliagre is right thatecho -n should be avoided for a truly portable shell script, as it’s not required to work. Maybe that’s why the guide you’re using teaches the cat /dev/null way instead.)

The echo -n way is equivalent in its effects but arguably is a better solution, in that it’s simpler.
cat /dev/null > file opens three “files”:

  • The cat executable (usually /bin/cat), a regular file.
  • The /dev/null device.
  • file

In contrast, echo -n > file opens only file (echo is a shell builtin).

Although this should be expected to improve performance, that’s not the benefit–not when just running a couple of these commands by hand, anyway. Instead, the benefit is that it’s easier to understand what’s going on.

Redirection and the trivial (blank/empty) command.

As jlliagre has pointed out (see also jlliagre’s answer), this can be shortened further by simply omitting the command on the left of > altogether. While you cannot omit the right side of a > or >>expression, the blank command is valid (it’s the command you’re running when you just press Enter on an empty prompt), and in omitting the left side you’re just redirecting the output of that command.

  • Note that this output does not contain a newline. When you press Enter on a command prompt–whether or not you’ve typed anything–the shell (running interactively) prints a newline before running the command issued. This newline is not part of the command’s output.

Redirecting from the blank command (instead of from cat /dev/null or echo -n) looks like:

>messages

>wtmp

******************************************************************************************************************************************************

Courtesy: http://askubuntu.com/questions/514748/what-does-dev-null-mean-in-a-shell-script