Re: Commonly Used Sudo Code for (*)Ubuntu/Unity Crash Recovery
Here are some common codes of interest to help with Precise recovery in the event of a crash.
How to find your souces.list- this list is used to set repositories and can be done manually. It is also informative to have on hand if you decide to do a transitional upgrade from Oneiric Ocelot to Precise Pangolin, Precise Pangolin to Quantal Quetzel, Quantal Quetzel to Raring Ringtail, Raring Ringtail to Saucy Salamander, Saucy Salamander to Trusty Tahr, Trusty Tahr to Utopic Unicorn, UU to Vivid Vervet, VV to Wily Werewolf, WW to Xenial Xerus, XX to Yakkety Yak, YY to Zesty Zapus, ZZ to Artful Ardvarrk to Bionic Beaver(current development release).
Code:
/etc/apt/sources.list
Trusty Tahr will not install: From initial boot screen from LiveCD or LiveUSB you may receive verbose characters or only purple or black screen:
- check here: [/COLOR]http://ubuntuforums.org/showpost.php...47&postcount=5
Your beta version of Firefox is Broken- here are two possible fixes:
http://ubuntuforums.org/showpost.php...9&postcount=18
http://ubuntuforums.org/showpost.php...0&postcount=19
Here is a list of commonly used Ubuntu/Linux terminal Codes (not neccessarily in order and open to interperetation) of PP Crash Recovery Codes -To be updated:
1. This command is used to auto edit the sources.list file on a previous install and could be considered as a first step to converting to Trusty Tahr. However this and other commands may be moot after Alpha .iso are released. You can still play it safe and test the kernels but breakage may occur nonetheless.
Code:
sudo sed -i 's/artful/bionic/g' /etc/apt/sources.list
2. This command will update your repositories to BB.
Code:
sudo apt-get update && sudo apt-get dist-upgrade
3.This command is inclusive in #2. but is always good to run after removing or purging stuff.
Code:
sudo apt-get update
4.This command is also included in #2. and upgrades any new files that are set in the repositories.
Code:
sudo apt-get dist-upgrade
4.(a)Update-manager is a fairly important component of the Ubuntu distribution. As we are supposed to be testing during the development phase, this application would be helped by testing and bug reporting as well.You can always make a judgement call as to whether the changes proposed by update-manager seem safe or not. If in doubt I think the best way to proceed is with aptitude:
Code:
aptitude update && aptitude safe-upgrade
This alleviates the concern when packages/dependencies may not be fully synced in the repos. They will be held back until dependencies are satisfied.
5.This command is an essential command if you are a elementary beta tester as it will upgrade the GRUB bootloader after changes to the system using other commands, are made (like upgrading a kernel). If you have tried to carry out a proceedure and wonder why it had not taken effect on the next boot, it is likely that you did not sudo update-grub. 6.This command will give you simple information about your system, most commonly used to discover your video adapter. 7.This command will display version information of the kernel you are using. 8.This command will tell you what Version of Ubuntu you are using. It will help validate and document that the prior commands have worked properly. 9.This command will continue to install packages that may have been broken during download or if your download unexpectedly terminated or if you have had a power-failure.
Code:
sudo -i dpkg --configure -a
10.These two commands can be used separately if you are at the terminal prompt from startup. You can get to the terminal (if you have no desktop) by pressing the keys <Crtl+Alt+F1> It makes booting and restarting quicker and more efficient than if you were in a desktop shell.
Code:
sudo reboot -sudo poweroff
11.One that I have found helpful for fixing broken packages is .
Code:
sudo apt-get -f install
12.Will install any packages necessary to fix the broken package if they are available . If some necessary packages are not available you can use this to remove the broken one .
Code:
sudo apt-get -f remove
13.Do not rely on any inaccurate information from the user as to whether he has (or not) added PPAs to his install. We just get the PPAs and read them. Then we parse the PPAs (from ppa-file-name.list to PPApaname/package format - which is the format required by the command ppa-purge)
Code:
if [[ -d /etc/apt/sources.list.d && $(ls -l /etc/apt/sources.list.d/* | wc -l) -gt 0 ]]; then echo -e "\n\nPPA dir exists and is not empty\n\n"; for PPA_FILE in $(ls /etc/apt/sources.list.d/*); do cat ${PPA_FILE} | grep "deb http" | sed -e 's|deb http:\/\/||' | sed -e 's|.launchpad.net/||' | sed -e 's|/ubuntu||' | sed -e 's|natty||' | sed -e 's|maverick||' | sed -e 's|oneiric||' | sed -e 's|main||' | tee -a $HOME/ppa-sources.list; done; echo "PPA list saved at $HOME/ppa-sources.list"; else echo -e "\n\nEmpty or inexistent PPA directory\n\n"; fi
14.Attempts to fix a broken OO Install for NVidia 173 users
Code:
#!/bin/bash ################################################## # fix_oneiric.sh # Attempts to fix a broken OO Install for NVidia 173 users # Effenberg0x0@Launchpad.net # ################################################## # # Save this file to a known location, such as your Home Folder # Execute it with sudo chmod +x fix-oneiric.sh && sudo bash ./fix-oneiric.sh # ################################################## # Assume the env vars we need may be wrong and get them # from safer sources ROOT_PARTITION=$(mount | grep -i "on / type" | awk '{ print $1}') ROOT_FS=$(mount | grep -i "on / type" | awk '{ print $5}') ROOT_WRITE=$(mount | grep -i "on / type" | awk '{ print $6 }') FIX_USER=$(cat /etc/passwd | grep 1000 | awk 'BEGIN { FS=":" }; {print $1}') ################################################## # Checks for a rw filesystem and remounts if needed if [ $ROOT_WRITE == "(ro)" ]; then mount -f -o remount,rw -t $ROOT_FS $ROOT_PARTITION / fi ################################################## # Make sure GUI sessions are stopped service stop lightdm service kill -s KILL $(pidof lightdm) service stop gdm service kill -s KILL $(pidof gdm) killall -s KILL /usr/bin/X ################################################## # Fixes user home permissions and ownership chown $FIX_USER:$FIX_USER /home/$FIX_USER -R && sudo chmod 750 /home/$FIX_USER -R ################################################## # Fixes Xauthority bug mv /home/$FIX_USER/.Xauthority /home/$FIX_USER/.Xauthority.backup ################################################## # Removes all nvidia remains cd /home/$FIX_USER mkdir nvidia_driver cd nvidia_driver apt-get remove --purge gdm nvidia-173 nvidia-96 nvidia-cg-toolkit nvidia-current-updates nvidia-173-dev nvidia-96-dev nvidia-common nvidia-current-updates-dev nvidia-173-updates nvidia-96-updates nvidia-current nvidia-settings nvidia-173-updates-dev nvidia-96-updates-dev nvidia-current-dev nvidia-settings-updates ################################################## # Downloads nvidia 173 driver wget http://us.download.nvidia.com/XFree8...14.31-pkg1.run ################################################## # Exports needed and correct environment variables export DISPLAY=:0.0 export XDG_CURRENT_DESKTOP=Unity export XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/ export COMPIZ_CONFIG_PROFILE=ubuntu export GDMSESSION=ubuntu export DESKTOP_SESSION=ubuntu export PATH=/home/$USER:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games export XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0 export XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 export DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path ################################################## # Run nvidia installer chmod +x NV* ./NV* ################################################## # Reinstalls all critical DM/DE packages apt-get install --reinstall --fix-broken --allow-unauthenticated lightdm lightdm-gtk-greeter unity unity-2d unity-2d-launcher unity-2d-panel unity unity-2d-places unity-greeter unity-lens-music unity-services unity-2d unity-2d-spread unity-lens-applications unity-place-applications unity-2d-launcher unity-asset-pool unity-lens-files unity-place-files unity-2d-panel unity-common unity-lens-gwibber unity-scope-musicstores compiz compiz-dev compiz-kde compiz-plugins-main-default compizconfig-backend-gconf compiz-fusion-bcop compiz-plugins compiz-plugins-main-dev compizconfig-backend-kconfig compiz-fusion-plugins-extra compiz-plugins-default compizconfig-settings-manager compiz-fusion-plugins-main compiz-plugins-extra compiz-core compiz-gnome compiz-plugins-main ################################################## # Makes sure lightdm was not started service lightdm stop ################################################## # Fixes lightm config bug (if needed) if [ ! -f /etc/lightdm/lightdm.conf ]; then sudo touch /etc/lightdm/lightdm.conf echo -e "[SeatDefaults]\r\nuser-session=ubuntu\r\ngreeter-session=unity-greeter" | tee /etc/lightdm/lightdm.conf ################################################## # Fixes default-display-manager bug (if needed) if [ ! -f /etc/X11/default-display-manager ]; then touch /etc/X11/default-display-manager echo -e "/usr/sbin/lightdm" | tee /etc/X11/default-display-manager ################################################## # Makes sure compiz/compiz-config settings are resetted gconftool-2 --recursive-unset /apps/compiz-1 gconftool-2 --recursive-unset /apps/compizconfig-1 ################################################## # Backup of compiz/configconfig settings mv $FIX_USER/.config/compiz-1/compizconfig $FIX_USER/.config/compiz-1/compizconfig.old mv $FIX_USER/.config/compiz-1 $FIX_USER/.config/compiz.old mv $FIX_USER/.compiz-1 $FIX_USER/.compiz-1.old mv $FIX_USER/.cache/compizconfig-1 $FIX_USER/.cache/compizconfig-1.old ################################################## # Update/upgrade the system and reboot apt-get update && apt-get upgrade reboot now
15.Unsolvable weird crash messages at most init procedures, ending in a "black screen" (or a console screen), no DM/DE after many attempts to fix a user setup (video driver, env vars, packages, etc).
A: Check for missing /run, or lack of permissions to write to it. Happens when users upgrade from old releases (that used /var/run and /var/lock instead of /run and /run/lock). Somehow the new install misses the creation of /run and /run/lock.
Check/Fix:
Code:
if [ ! -d /run -a -d /var ]; then sudo ln -s /var/run /run && sudo mkdir -p /run/lock; fi
16.Unable to run apt-get. "Archive directory /var/cache/apt/archives/partial is missing"
Check/Fix:
Code:
if [ ! -d /var/cache/apt/archives/partial ]; then sudo mkdir -p /var/cache/apt/archives/partial && sudo touch /var/cache/apt/archives/partial/lock && sudo chmod 640 /var/apt/cache/archives/lock && sudo apt-get clean; fi
17.System mounted in "Read Only" mode. User is unable to edit config files or install any package, so no one can help him. All requested procedures will fail until it is set rw again. Happens when user has errors=remount-ro in fstab.
Check/Fix:
Code:
if [ $(sudo mount | grep -i "on / type" | awk '{ print $6 }') == "(ro)" ]; then sudo mount -f -o remount,rw -t $(sudo mount | grep -i "on / type" | awk '{ print $5}') $(sudo mount | grep -i "on / type" | awk '{ print $1}') /; fi
18.Just tried installing Precise for the first time today, using Alpha 1. I have an nvidia gs7600 card.
Installation went fine but on reboot the system repeatedly hung without booting to the Desktop. The 'nomodeset' option did not help.
Updating the packages from the recovery mode terminal didn't work either, nor did trying to start lightdm after a terminal log in.
What finally allowed booting to the Desktop was removing all nvidia packages and then reinstalling nvidia-current (which also installed nvidia-settings).
Code:
sudo apt-get purge nvidia* sudo apt-get install nvidia-current
Last edited by cariboo907; December 22nd, 2011 at 04:09 PM.. Reason: remove hard to read color formatting