Results 1 to 2 of 2

Thread: Help us Help you!

  1. #1
    Join Date
    Jul 2011
    Location
    South-Africa
    Beans
    678
    Distro
    Ubuntu 12.04 Precise Pangolin

    Post Help us Help you!

    Good day all,

    Here is just a quick thread to add to my signature and to share the link with people so they can "Help us help them". These are a few commands of which output is always welcome under certain debug situations. Nothing major, nothing to agressive... I hope :$.

    Feel free to shoot me a message if you feel I should include any commands or more headers etc. This is for the community to help each other save time and avoid headaches where possible.

    Great so here we go:

    First things first:
    Posting any output from a command should be in code brackets. The brackets are added to a post at the current cursor position by clicking the # sign at the top of a post sections. This should generate tags that look like this:
    [CODE ][/CODE ]
    Only without the spaces.
    Put all the output generated by a command inside like so:
    [CODE ]Here is some sample output[/CODE ]

    It is useful to put the output of each command seperately such as:
    ls
    Code:
    Some ls output
    some other command
    Code:
    Some more output
    This help us greatly when referencing back and forth.

    All commands are UP TO the # (comment). For example:
    Code:
    ls #This list the current directory's content
    Only copy and paste this into a terminal:
    Code:
    ls
    Lastly, opening up a terminal is done with:
    ctrl + alt + T
    Applications > Accessories > Terminal
    Dash > "Terminal"

    Any terminal emulator should do. But ctrl + alt + T; usualy opens up the default one for the environment.

    So here we go, for debugging and issues please see the following and choose aproprietly the commands according to their comments.

    A good title goes a LONG way:
    Here are some key ideas taken from:
    http://meta.stackoverflow.com/questi...e-a-good-title
    Please read the above article for a much more in depth look

    1. Make the topic stand out.
    2. Keep it short.
    3. Lead with the most important words.
    4. Don't start with "How do I..."
    5. Don't sweat replicating a tag keyword.
    6. "What is a ..." is fine
    GOOD examples:
    Turning Linux USB power on and off?
    How to UPSERT in Oracle (update or insert into a table)?
    Python: What OS am I running on?
    Raise an existing X11 window via command line?
    64-bit XML-RPC values?
    Move an existing X11 window via command line?
    Sum 3 columns in SQL when one column has a null value?
    Oracle: searching over a range of values?
    PostgreSQL encrypted backups
    Readable font for code presentations?
    Object Oriented vs Relational Databases
    Oracle: formatting number as xxx-xx-xxxx
    PostgreSQL Long VACUUM
    Best timing method in C?
    Map Routing, a la Google Maps?
    Constructing images using HTML markup?
    Inserting PostgreSQL BLOBs at a high-rate?
    BAD Examples:
    How can I format xxxxxxxxx like xxx-xx-xxxx in Oracle?
    How can I programmatically enable and disable the power to a particular USB port on Linux?
    How can I raise an existing window via command line in X11?
    How can I quickly insert a BLOB in PostgreSQL?
    How can I move an existing window via command line in X11?
    How can I store multiple items in an XML file for easy parsing?
    What is a good font for code presentations?
    How can I sum 3 columns when one column has a null value?
    How can I construct images using HTML markup?
    What is the best book for software design?
    How can I generate unique random numbers in PHP?
    How can I quickly insert a BLOB in PostgreSQL?
    How can I tell what OS am I running on in Python?
    For ANY ISSUE please include the output of the following:
    Code:
    uname -a #Displays current linux and kernel versions.
    lsb_release -a #Displays the current release information.
    For ANY harware related issues:
    Code:
    lspci -v #List all PCI devices and gives information on PCI buses. Verbose.
    lsusb -v #List all USB devices and gives information on USB buses. Verbose.
    lsmod    #List all Modules (Drivers) loaded by the kernel.
    dmesg | tail -n100 #Prints the last 100 entries of the kernel ring buffer.
    Please note the following command needs SUDO privleges to execute but does not alter the system in any way.
    Code:
    sudo lshw #list all hardware. Can substitute "lspci, lsusb"



    For graphic issues:
    Code:
    cat /etc/X11/xorg.conf #Gives the content of the current xorg.conf file.
    For network related issues:
    Wired:
    Code:
    ifconfig -a -v #List current status and configuration of ALL networking devices. Verbose.
    Wireless:
    Code:
    iwconfig #List current status and configuration of wireless networking devices.
    cat /proc/net/wireless #Gives wireless connection information.
    Misc:
    Code:
    route #Display current Kernel IP routing table.
    For all filesystem related issues:
    Code:
    df -h #display current disk usage and mount locations.
    cat /etc/fstab #Display the current fstab file
    lsblk #list block devices
    Please note the following command needs SUDO privleges to execute but does not alter the system in any way.
    Code:
    sudo parted -l #List partition layouts on all block devices
    For any BOOT related problems including GRUB:
    https://help.ubuntu.com/community/Boot-Repair
    https://help.ubuntu.com/community/Boot-Info

    Boot Info Script:
    http://bootinfoscript.sourceforge.net/

    For Sound related problems start here:
    https://help.ubuntu.com/community/SoundTroubleshooting


    I did something in the terminal and now my computer is broken!
    Code:
    cat ~/.bash_history #This gives the last bunch of commands entered into the terminal
    #Alternative:
    history #shows the history of commands ran in the terminal up to maximum set in ~/.bashrc by line "export HISTFILESIZE=n".
    If you installed or removed any software packages:
    Code:
    cat /var/log/apt/term.log  #This gives the output from the last few apt-get requests, note: more distant logs are archived in same folder
    I want to list all my currently installed programs (and re-install them later):
    source: http://ubuntuforums.org/showthread.php?t=261366
    Thanks: jrib for telling me apt-get alternative (dselect is not installed by default)
    Code:
    dpkg --get-selections > installed-software #save list of installed packages in current working directory
    dpkg --set-selections < installed-software && apt-get dselect-upgrade #select and install all packages from list in current working directory
    Alternative:
    Creating a backup of the actual *.deb packages to reinstall later (or off-line):
    http://ubuntuforums.org/showthread.php?t=819396



    That concludes the post for the time being. Feel free to ask me to include any relevent information for "Helping us to help you". This was done somewhat quickly and I am SURE I missed a lot of useful information.

    Also once this thread has been expanded sufficiently I might write a script to collect system information on all of the above (selected by the user which type of "problem" the system has) to help in some of the more complicated commands where certain information needs to be extracted from the output of a command.

    Cheers and hoping to hear from you. Please share the link so we can speed up the "Please help" threads to being marked as solved.

    Last edited by zero2xiii; September 4th, 2013 at 07:43 PM. Reason: Updated
    Switched away from windows XP to Ubuntu 9.04. Never turned around to look back.

  2. #2
    Join Date
    Jul 2011
    Location
    South-Africa
    Beans
    678
    Distro
    Ubuntu 12.04 Precise Pangolin

    Debug script.

    Hay all,

    So it has been a while and still I have had no feed back. So I assumed there is not much more to include just yet. Today I am releasing the first ALPHA version of the script for comunity input.

    I am by no means a hardcore scriptor, but it works so far. More options will be added as time passes. This is really just to get some reaction from the crowd, so that I do not wander off the course TO far lol.

    So here you are (I will attach a file as well):

    SOURCE:

    Code:
    #!/bin/bash
    clear
    
    echo "Welcome to the DebugTool ALPHA V1.0"
    echo "Please follow the onscreen instructions carefully and select the most apropriate option."
    echo "This tool is still in development phase and more functions will be added as time passes and suggestions are received."
    echo "Thank you for helping us so we can help you. :)"
    echo ""
    read -p "Press any key to continue..." -n1 -s
    clear
    
    #=============All functions set==================#
    
    function reset_vars(){
        #Set working path:
            path=`echo $(pwd)`
    
        #Set working file:
            work_file="debug.txt" #default name for error handeling.
    } #END reset_vars function
    
    function reset_jobs(){
        #include this ALWAYS:
            do_uname="1"
            do_release="1"
    
        #list attached hardware related:
            do_lspci="0"
            do_lsusb="0"
    
        #list all loaded modules:
            do_lsmod="0"
    
        #give kernel ring buffer:
            do_dmesg="0"
    
        #give network related information:
    
            #wired network:
            do_ifconfig="0"
    
            #wireless network:
            do_iwconfig="0"
            do_cat_wireless="0" #cat /proc/net/wireless
    
            #routing table:
            do_route="0"
    
        #give filesystem and mount information:
            do_df="0"
            do_fstab="0"
    
            #requires ROOT:
            do_parted="0"
    
        #gives history of recent changes to computer:
            do_terminal="0"
            do_terminal_root="0"
            do_apt_history="0"
    
    general_area
    } #END reset_jobs function
    
    function set_all_jobs(){
    #include this ALWAYS:
            do_uname="1"
            do_release="1"
    
        #list attached hardware related:
            do_lspci="1"
            do_lsusb="1"
    
        #list all loaded modules:
            do_lsmod="1"
    
        #give kernel ring buffer:
            do_dmesg="1"
    
        #give network related information:
    
            #wired network:
            do_ifconfig="1"
    
            #wireless network:
            do_iwconfig="1"
            do_cat_wireless="1" #cat /proc/net/wireless
    
            #routing table:
            do_route="1"
    
        #give filesystem and mount information:
            do_df="1"
            do_fstab="1"
    
            #requires ROOT:
            do_parted="1"
    
        #gives history of recent changes to computer:
            do_terminal="1"
            do_terminal_root="1"
            do_apt_history="1"
    
    $called_from #Jumps back to function that called this function. There must be a better way...
    }
    
    function general_area(){
    clear
        echo "Please select the general area of the problem:"
        echo ""
        echo "1. Hardware related"
        echo "2. Software related"
        echo "Or:"
        echo "a. Advance, quick"
        echo "x. Exit the tool"
        echo ""
        echo "Enter choice"
        read -n1 choice
            if [ $choice = "x" ]; then  exit
                else
                    if [ $choice = "a" ]; then advance_menu
                        else
                            if [ $choice = "1" ]; then hardware
                                else
                                    if [ $choice = "2" ]; then software
                                        else
                                            clear
                                            echo "Please select a valid option!"
                                            read -p "Press any key to return to the selection menu" -n1 -s
                                            general_area
                                    fi #Software
    
                            fi #Hardware
    
                    fi #advance menu
            fi #exit
    } #END general_area function
    
    function advance_menu(){
    clear
    echo "Welcome to the advance menu!"
    echo "Here you can select each of the individual commands you wish to include in the report."
    echo "This is recommend to use be used by advance people only."
    echo "To toggle a parameter, simply enter the corresponding number."
    echo ""
    echo "The command with its current status is shown below:"
    echo "01. uname: \"$do_uname\""
    echo "02. lsb_release: \"$do_release\""
    echo "03. lspci: \"$do_lspci\""
    echo "04. lsusb: \"$do_lsusb\""
    echo "05. lsmod: \"$do_lsmod\""
    echo "06. dmesg: \"$do_dmesg\""
    echo "07. ifconfig: \"$do_ifconfig\""
    echo "08. iwconfig: \"$do_iwconfig\""
    echo "09. cat /proc/net/wireless: \"$do_cat_wireless\""
    echo "10. route: \"$do_route\""
    echo "11. df: \"$do_df\""
    echo "12. fstab: \"$do_fstab\""
    echo "13. parted: \"$do_parted\""
    echo "14. Termianl history: \"$do_terminal\""
    echo "15. Terminal history ROOT: \"$do_terminal_root\""
    echo "16. apt-get history: \"$do_apt_history\""
    echo ""
    echo "a. Set to run all"
    echo "r. Run selected commands"
    echo "x. Exit"
    echo ""
    echo "Please enter selction"
    read -n2 choice
    
    adv_choice_loop
    } #END advance_menu function
    
    function adv_choice_loop(){
        #Set working file
        work_file=advance.txt
        
        #Set jump position
        called_from="advance_menu"
    
        #toggle jobs
        #Credit to "matt_symes" for helping me with the toggle command below.
        [ "$choice" = "01" ] && { [ $do_uname = "0" ] && do_uname="1" || do_uname="0"; }
        [ "$choice" = "02" ] && { [ $do_release = "0" ] && do_release="1" || do_release="0"; }
        [ "$choice" = "03" ] && { [ $do_lspci = "0" ] && do_lspci="1" || do_lspci="0"; }
        [ "$choice" = "04" ] && { [ $do_lsusb = "0" ] && do_lsusb="1" || do_lsusb="0"; }
        [ "$choice" = "05" ] && { [ $do_lsmod = "0" ] && do_lsmod="1" || do_lsmod="0"; }
        [ "$choice" = "06" ] && { [ $do_dmesg = "0" ] && do_dmesg="1" || do_dmesg="0"; }
        [ "$choice" = "07" ] && { [ $do_ifconfig = "0" ] && do_ifconfig="1" || do_ifconfig="0"; }
        [ "$choice" = "08" ] && { [ $do_iwconfig = "0" ] && do_iwconfig="1" || do_iwconfig="0"; }
        [ "$choice" = "09" ] && { [ $do_cat_wireless = "0" ] && do_cat_wireless="1" || do_cat_wireless="0"; }
        [ "$choice" = "10" ] && { [ $do_route = "0" ] && do_route="1" || do_route="0"; }
        [ "$choice" = "11" ] && { [ $do_df = "0" ] && do_df="1" || do_df="0"; }
        [ "$choice" = "12" ] && { [ $do_fstab = "0" ] && do_fstab="1" || do_fstab="0"; }
        [ "$choice" = "13" ] && { [ $do_parted = "0" ] && do_parted="1" || do_parted="0"; }
        [ "$choice" = "14" ] && { [ $do_terminal = "0" ] && do_terminal="1" || do_terminal="0"; }
        [ "$choice" = "15" ] && { [ $do_terminal_root = "0" ] && do_terminal_root="1" || do_terminal_root="0"; }
        [ "$choice" = "16" ] && { [ $do_apt_history = "0" ] && do_apt_history="1" || do_apt_history="0"; }
    
        #all, run or exit
        if [ $choice = "a" ]; then set_all_jobs; fi
        if [ $choice = "r" ]; then do_jobs; fi
        if [ $choice = "x" ]; then exit; fi
        
    
        advance_menu
        } #END adv_choice_loop function
    
    function hardware(){
        clear
        echo "This will collect all harware related information related to your system."
        echo "No personal information is collected!"
        echo "Progress will be shown on screen:"
        echo "Creating file $(pwd)/hardware.txt"
        echo "START OF HARDWARE COLLECTION" > hardware.txt
        work_file="hardware.txt"
        echo ""
    
        #Set all jobs to do:
            do_uname="1"
            do_release="1"
            do_lspci="1"
            do_lsusb="1"
            do_lsmod="1"
            do_dmesg="1"
    do_jobs
    } #END hardware function
    
    function software(){
    echo "software placeholder."
    echo "This function is not implimented yet and will be implimented soon."
    read -p "Press any key to return to the main menu..." -n1 -s
    } #END software function
    
    function do_jobs(){
    
        if [ $do_uname = "1" ]; then do_uname; fi
    
        if [ $do_release = "1" ]; then do_release; fi
    
        if [ $do_lspci = "1" ]; then do_lspci; fi
    
        if [ $do_lsmod = "1" ]; then do_lsmod; fi
    
        if [ $do_dmesg = "1" ]; then do_dmesg; fi
    
        if [ $do_ifconfig = "1" ]; then do_ifconfig; fi
    
        if [ $do_iwconfig = "1" ]; then do_iwconfig; fi
    
        if [ $do_cat_wireless = "1" ]; then do_cat_wireless; fi
    
        if [ $do_route = "1" ]; then do_route; fi
    
        if [ $do_df = "1" ]; then do_df; fi
    
        if [ $do_fstab = "1" ]; then do_fstab; fi
    
        if [ $do_parted = "1" ]; then _do_parted; fi
    
        if [ $do_terminal = "1" ]; then do_terminal; fi
    
        if [ $do_terminal_root = "1" ]; then do_terminal_root; fi
    
        if [ $do_apt_history = "1" ]; then do_apt_history; fi
    
    read -p "All jobs are done, press any key to exit..." -n1
    exit
    
    } #END do_jobs function
    
    function do_uname(){
        echo "Running uname -a"
        echo "uname -a" >> $work_file
        echo "===================================" >> $work_file
        uname -a >> $work_file
        echo "================END================" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_uname="0"
    } #END do_uname function
    
    function do_release(){
        echo "Running lsb_release -a"
        echo "lsb_release -a" >> $work_file
        echo "==================================" >> $work_file
        lsb_release -a >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_release="0"
    } #END do_release function
    
    function do_lspci(){
        echo "Running lspci -v"
        echo "lspci -v" >> $work_file
        echo "==================================" >> $work_file
        lspci -v >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_lspci="0"
    } #END do_lspci function
    
    function do_lsusb(){
        echo "Running lsusb -v"
        echo "lsusb -v" >> $working_file
        echo "==================================" >> $work_file
        lsusb -v >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_lsusb="0"
    } #END do_lsusb function
    
    function do_lsmod(){
        echo "Running lsmod"
        echo "lsmod" >> $work_file
        echo "==================================" >> $work_file
        lsmod >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_lsmod="0"
    } #END do_lsmod function
    
    function do_dmesg(){
        echo "Running dmesg"
        echo "dmesg" >> $work_file
        echo "==================================" >> $work_file
        dmesg >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_dmesg="0"
    } #END do_dmesg function
    
    function do_ifconfig(){
        echo "Running ifconfig -av"
        echo "ifconfig -av" >> $work_file
        echo "==================================" >> $work_file
        ifconfig -av >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_ifconfig="0"
    } #END do_ifconfig function
    
    function do_iwconfig(){
        echo "Running iwconfig"
        echo "iwconfig" >> $work_file
        echo "==================================" >> $work_file
        iwconfig >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_iwconfig="0"
    } #END do_iwnconfig function
    
    function do_cat_wireless(){
        echo "Running cat /proc/net/wireless"
        echo "/proc/net/wireless" >> $work_file
        echo "==================================" >> $work_file
        cat /proc/net/wireless >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_cat_wireless="0"
    } #END do_cat_wireless function
    
    function do_route(){
    echo "Running route -eev"
        echo "route -eev" >> $work_file
        echo "==================================" >> $work_file
        route -eev >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_route="0"
    } #END do_route function
    
    function do_df(){
        echo "Running df -ahl --total"
        echo "df -ahl --total" >> $work_file
        echo "==================================" >> $work_file
        df -ahl --total >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_df="0"
    } #END do_df function
    
    function do_fstab(){
        echo "Running cat /etc/fstab"
        echo "/etc/fstab" >> $work_file
        echo "==================================" >> $work_file
        cat /etc/fstab >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_fstab="0"
    } #END do_fstab function
    
    function do_parted(){
        echo "Running parted --list"
        echo "This command requires SUDO privledges to execute"
        echo "These privledges are temporary and the command does not modify the system in any way"
        echo "sudo parted --list" >> $work_file
        echo "==================================" >> $work_file
        sudo parted --list >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_parted="0"
    } #END do_parted function
    
    function do_terminal(){
        echo "Running history for current user"
        echo "History - Normal user" >> $work_file
        echo "==================================" >> $work_file
        history>> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_terminal="0"
    } #END do_terminal function
    
    function do_terminal_root(){
        echo "Running history for ROOT user"
        echo "This command requires SUDO privledges to execute"
        echo "These privledges are temporary and the command does not modify the system in any way"
        echo "History - ROOT user" >> $work_file
        echo "==================================" >> $work_file
        sudo -i
        history>> $work_file
        exit 
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_terminal_root="0"
    } #END do_terminal function
    
    function do_apt_history(){
        echo "Running cat /var/log/apt/term.log"
        echo "cat /var/log/apt/term.log" >> $work_file
        echo "==================================" >> $work_file
        cat /var/log/apt/term.log >> $work_file
        echo "================END===============" >> $work_file
        echo "" >> $work_file
        echo "done"
        do_apt_history="0"
    } #END do_apt_history function
    
    #start script, start by resetting job variables:
    reset_jobs
    
    #something went wrong, exit with code 1
    exit 1
    debug_v1.sh

    Please note I plan on this becoming a very advance script for helping newcomers find and supply information to help members of the community to debug their systems.
    It might be expanded to a few scripts called from one, but time will tell.

    For now, feel free to comment, but please do not shoot me.
    Last edited by zero2xiii; May 6th, 2013 at 03:37 PM.
    Switched away from windows XP to Ubuntu 9.04. Never turned around to look back.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •