How to fix any Linux problem
Linux issues begone!
No blinking desktop
I applied some system updates as notified by my Ubuntu desktop. After the next reboot I was faced with a black screen, a login prompt, a blinking cursor and nothing else. I could log in as my user, but there was still no desktop.
This happened because the system update installed a new kernel, which became the default when you rebooted. If you are using a graphics card with third party drivers, such as Nvidia, you have to reinstall the drivers before you can get your desktop back.
If you installed the drivers through the Software Center, it should have taken care of the reinstallation, but if you installed the drivers manually it became your responsibility, and graphics card drivers need a kernel module to function.
If you use an open source driver, the module is included with the kernel, so the process of switching kernels is transparent. With the binary drivers, the module is compiled and installed by the driver installer, so you have to redo this for a new kernel.
The good news is that you can reboot, select your previous kernel from the boot menu and your desktop will be back. Then you can install the drivers again, in the same way you did last time.
User error, replace user
Program XYZ has started misbehaving, no longer acting as it used to. I have tried reinstalling it but it makes no difference.
Have you recently updated the program or one of the libraries it uses? Look at your package manager's log files so see what has been installed recently (users of Ubuntu or Debian-based distros can look in /var/log/apt/history.log).
Get the best Black Friday deals direct to your inbox, plus news, reviews, and more.
Sign up to be the first to know about unmissable Black Friday deals on top tech, plus get all your favorite TechRadar content.
If it has not been changed, this is most likely a configuration issue. Reinstalling a package does not affect the users' settings, stored somewhere in your home directory. The easiest way to test this is to create a new user, log in as them and try the same software, which will take you back to a default configuration.
If the problem disappears, it is an issue with your configuration. The next step is to find where the program stores its configuration. KDE programs store settings in /.kde4/share/config, but most other programs use .config, .local or write their configuration files directory in your home directory.
An easy way to find files modified by a program is to use the find command. First create a file with the current time stamp
touch /now
Then run your program, make a config change and exit it. Now you can find any files in your home directory that were changed with
find -newer /now
Once you've found the configuration file or directory for the offending program, you'll need to rename it and run the program again to return to a standard setup. Remember the idea of creating a new user with no settings – it can save you a lot of time in the future.
Login refused
I've had repeated problems trying to get Ubuntu to accept my password, which I know is correct. Originally I had set automatic install but nevertheless was presented with the login screen but my password was not accepted. If I booted into recovery mode my same password was OK!
The problem is not with your password; otherwise you would not be able to log into the recovery console either. Something else is preventing you from logging into the desktop, which is why you see the login window even though you have auto-login turned on. It tries to log you in, fails and returns to the login screen.
This is usually caused by incorrect ownership on files the desktop needs to write to. You may have inadvertently made a critical file owned by root, usually as a result of trying to fix something else.
Boot into recovery again and log in as the affected user, then run this command to reset ownership of all files in your home directory back to you.
sudo chown -R ${USER}:
The chown command is used to CHange OWNership of files. The -R option tells it to recursively change all files below the given path. The environment variable ${USER} is expanded to your user name (this is why you need to be logged in as the affected user for it to work). The colon (:) following the user name instructs chown to also change the group ownership to the default group for that user.
Finally, the shell expands to the path to your home directory. You need to run it with sudo as you need root permissions to change ownership of anything that does not belong to you, and those are the files we are interested in. If it still fails, check .xsession-errors in your home directory.
Device locked
When I try to eject a DVD or remove a USB flash drive, it sometimes refuses to do so, along with a message along the lines of "Operation failed: device in use". How do I get around this without rebooting, which does seem to work?
Some program somewhere has a lock on a file or directory on the filesystem you want to unmount, so the operating system is refusing to do what you want.
The lsof command lists all open files, including directories and device nodes. By passing its output through grep, you can find the guilty process, for example:
# lsof | grep /media/cdrom
bash 15243 nelz cwd DIR 11,0 6144 1856 /media/
cdrom
This shows that Bash, running under my user, has cwd locked on that directory. cwd is Change Working Directory – in other words I have a shell open that is displaying the CD's directory. Simply issuing a cd command in that shell, to switch back to my home directory, will release the lock and let me unmount the CD.
Once you know which program is locking the device, you can deal with it. An alternative command is fuser, which simply returns the process ID of the program locking the file:
# fuser /media/cdrom
/media/cdrom: 15243c
You'll see it is the same PID as given by lsof. This may look less useful, and indeed it is in this case, because I only need to find the shell and change directories, but fuser has a trick up its sleeve. Using
fuser -k /media/cdrom
will find the PID and send it a KILL signal, terminating the program immediately and releasing the lock, which is useful if a crashed program has left a lock on the device. This is safer than removing the device without unmounting, which can cause data loss.
Where's that file?
I don't know if it's my age or what, but I have a habit of saving files and then forgetting where I saved them, leaving me with the prospect of trawling through many gigabytes of files in my home directory. Is there any help for the terminally forgetful?
Apart from things like KDE's semantic desktop, which indexes all files you create, there are some general options. The first is find, which (surprise!) locates files based on various criteria. For example, if you know roughly when you saved the file, you can use -mtime to search on the last modified time stamp of the file:
find -type f -mtime 0
find /documents -type f -mtime +7 -mtime -14
The first finds all files in your home directory modified in the last 24 hours; the second looks in your documents directory for files more than a week but less than two weeks old. We need -type f to stop it matching on directories.
You can also match on file names to look for spreadsheets modified in the last week:
find -mtime -7 -name '*.ods'
If it is a text file and you know some of the file's contents, you can use grep:
grep -rI "some text"
This is a lot slower because it has to read every file, so try to narrow it down. The -r option searches recursively while -I tells grep to ignore binary files. There are also graphical find commands with most desktops, but what they cannot do is combine find and grep, such as
grep -I "some text" $(find -type f -mtime 0)
This runs find to generate a list of files, then passes them to grep for searching.
- Enjoyed this article? Expand your knowledge of Linux, get more from your code, and discover the latest open source developments inside Linux Format. Read our sampler today and take advantage of the offer inside.