2011-06-26, 23:03
For many years i've been fidling around learning
ubuntu/linux and came around quite a good deal of usefull
commands. I wanted to make a register of my most used terminal commands
when fidling with problems in ubuntu/xbmc
IMPORTANT: Linux is CaSe sensitive so if a you e.g type in
the command Df -h nothing will happen because
the command is df - h with lower case characters. The same
applies to directories and files.
A nice general guide to the linux bash world:
http://ubuntuforums.org/showpost.php?p=3...ostcount=1
How to get into the linux terminal ?
U can do this 2 ways. The first is by using your local
keyboard and tv directly. If you have xbmc on the screen
you cant press CTRL ALT F2 to open a bash window
To get back to xbmc you can hit CTRL ALT F7
The way i prefer to do it is by logging into my linux box remotely
from my windows laptop. Both your xbmc box and laptop must be on the same subnet to get it working:
Download putty, it's a small free SSH/Telnet client
http://www.chiark.greenend.org.uk/~sgtat...nload.html
Get the version that matches your windows build
When installed open putty.exe and type in your xbmc box ip adress
and port 22. Save it for later use by hitting the save button (create a name for the connection in the saved session field first)
Load your XBMC saved session by double clicking it from the list
You should now be greeted with a terminal window asking you for a password
General info commands
(does not change anything and should be harmless)
Check Disk Space:
Check what linux distro you are using:
Check what linux kernel you have:
Get info about a package installed:
List all usb devices connected:
To generaly test your sound using aplay:
More Speaker Testing:
List your soundcard device:
List out all hardware detected:
Get all boot-time kernel logging for a system:
Same as above but also with timestamps:
To see what version of nvidia drivers installed:
Basic terminal commands:
To run a command with superusers privileges:
where "command" is any command you might want to run
with elevated priviliges
If you need to do extensive work as root you can do the following:
This way you keep your current users bash config and history
Or you can change to root user all together:
Be warned though, running commands inside a terminal
with root privileges is a fast way to fubar your system !!
More info about sudo:
https://help.ubuntu.com/community/RootSudo
To return to your current users home directory from anywhere:
To list content of a folder:
To navigate to a folder:
This will take you to the X11 folder inside the etc folder
Edit files:
This will open xorg.conf for editing. To close nano without
changing anything hit CTRL X
To create new file:
Your home dir is located under /home/"your username"
On a standard xbmc live install if you logon in the terminal as user xbmc your homedir is /home/xbmc
In my examples i use /home/xbmc
This will create a text file called mytestfile.txt under your home dir.
Type in something in the file and hit CTRL X and nano will now ask
if you want to save changes - select Y and ENTER
The file is now saved.
To delete a file:
To create a directory:
Will create "testdir" in your home directory.
To remove a directory and all files subdirs:
To start/stop a program:
Another way to force a program to shutdown is by using the kill command:
To check your wired network info:
To check your wireless network info:
To scan wireless networks:
To restart the network:
If you made changes to your network config you need
to restart networking services. It will also renew your dhcp leases
Turning Network interfaces on/off
Sometimes when troubleshooting it can be handy to quickly take network interfaces up/down
to reinitialize the interface
Usually your wired network adapter will be "eth0" and your wirelss netowrk adapter will be "wlan0"
You can use the iwconfig to get a valid list.
To shutdown your linux box:
or
To reboot your linux box:
Usefull commands:
Warning these commands can change your system
so do not run them unless you need to. Use it as a refference only !
To update/upgrade your installed packages:
This will upgrade all packgages to latest version. Sometime
this can break functionallity so be carefull !
To update/upgrade specific package:
This will check of you have the latest version
and if there is a newer version it will ask you if you want to upgrade.
To uninstall a package:
To completely remove a package and all dependencies:
This will also remove all dependencies and might seriously break functionality !
Another way to remove packages can be:
Can be handy if something remains from an uninstall.
To free up disk space and get rid of left behind packages:
This will clean up temporary files and should not be dangerous to use.
To search for a package:
This will give you all available packages that contains the word "XBMC"
To fix broken installs/packages:
This will try to fix broken packages in your system.
To upgrade your current linux distro to a newer version:
This is a dangerous command and can break your install so do be carefull
and make backups of anything imporant. I have done this a few times
with no problems, however this is not always possible depending on your config/setup
Okay this is what i currently remember from my head, i will ad more
if i see something is forgotten. And as always any input to my list
is welcome ! Also please report if you find something you don't like
or if you have any commands you think should be here
ubuntu/linux and came around quite a good deal of usefull
commands. I wanted to make a register of my most used terminal commands
when fidling with problems in ubuntu/xbmc
IMPORTANT: Linux is CaSe sensitive so if a you e.g type in
the command Df -h nothing will happen because
the command is df - h with lower case characters. The same
applies to directories and files.
A nice general guide to the linux bash world:
http://ubuntuforums.org/showpost.php?p=3...ostcount=1
How to get into the linux terminal ?
U can do this 2 ways. The first is by using your local
keyboard and tv directly. If you have xbmc on the screen
you cant press CTRL ALT F2 to open a bash window
To get back to xbmc you can hit CTRL ALT F7
The way i prefer to do it is by logging into my linux box remotely
from my windows laptop. Both your xbmc box and laptop must be on the same subnet to get it working:
Download putty, it's a small free SSH/Telnet client
http://www.chiark.greenend.org.uk/~sgtat...nload.html
Get the version that matches your windows build
When installed open putty.exe and type in your xbmc box ip adress
and port 22. Save it for later use by hitting the save button (create a name for the connection in the saved session field first)
Load your XBMC saved session by double clicking it from the list
You should now be greeted with a terminal window asking you for a password
General info commands
(does not change anything and should be harmless)
Check Disk Space:
Code:
df -h
Check what linux distro you are using:
Code:
lsb_release -a
Check what linux kernel you have:
Code:
uname -a
Get info about a package installed:
Code:
dpkg -s xbmc
List all usb devices connected:
Code:
lsusb
Code:
lsusb -v
To generaly test your sound using aplay:
Code:
aplay /usr/share/sounds/alsa/Front_Center.wav
aplay /usr/share/sounds/alsa/Front_Left.wav
aplay /usr/share/sounds/alsa/Front_Right.wav
aplay /usr/share/sounds/alsa/Rear_Center.wav
aplay /usr/share/sounds/alsa/Rear_Left.wav
aplay /usr/share/sounds/alsa/Rear_Right.wav
aplay /usr/share/sounds/alsa/Side_Left.wav
aplay /usr/share/sounds/alsa/Side_Right.wav
aplay /usr/share/sounds/alsa/Noise.wav
More Speaker Testing:
Code:
speaker-test -Dplug:surround51 -c6 -l1 -twav
List your soundcard device:
Code:
cat /proc/asound/cards
Code:
aplay -l
List out all hardware detected:
Code:
lspci -v | less
Get all boot-time kernel logging for a system:
Code:
dmesg | less
Same as above but also with timestamps:
Code:
less /var/log/kern.log
To see what version of nvidia drivers installed:
Code:
dpkg --status nvidia-current | grep Version | cut -f 1 -d '-' | sed 's/[^.,0-9]//g'
Basic terminal commands:
To run a command with superusers privileges:
Code:
sudo "command"
with elevated priviliges
If you need to do extensive work as root you can do the following:
This way you keep your current users bash config and history
Code:
sudo -s
Or you can change to root user all together:
Code:
sudo su
Be warned though, running commands inside a terminal
with root privileges is a fast way to fubar your system !!
More info about sudo:
https://help.ubuntu.com/community/RootSudo
To return to your current users home directory from anywhere:
Code:
cd ~
To list content of a folder:
Code:
ls
To navigate to a folder:
Code:
cd /etc/X11
Edit files:
Code:
nano /etc/X11/xorg.conf
changing anything hit CTRL X
To create new file:
Your home dir is located under /home/"your username"
On a standard xbmc live install if you logon in the terminal as user xbmc your homedir is /home/xbmc
In my examples i use /home/xbmc
Code:
nano /home/xbmc/mytestfile.txt
Type in something in the file and hit CTRL X and nano will now ask
if you want to save changes - select Y and ENTER
The file is now saved.
To delete a file:
Code:
rm /home/xbmc/mytestfile.txt
To create a directory:
Code:
mkdir /home/xbmc/testdir
To remove a directory and all files subdirs:
Code:
rmdir /home/xbmc/testdir
To start/stop a program:
Code:
service xbmc stop
Code:
service xbmc-live stop
Code:
service xbmc start
Code:
service xbmc-live start
Another way to force a program to shutdown is by using the kill command:
Code:
sudo kill -9 `pidof xbmc.bin`
To check your wired network info:
Code:
ifconfig
To check your wireless network info:
Code:
iwconfig
To scan wireless networks:
Code:
iwlist scan
To restart the network:
Code:
/etc/init.d/networking restart
to restart networking services. It will also renew your dhcp leases
Turning Network interfaces on/off
Sometimes when troubleshooting it can be handy to quickly take network interfaces up/down
to reinitialize the interface
Usually your wired network adapter will be "eth0" and your wirelss netowrk adapter will be "wlan0"
You can use the iwconfig to get a valid list.
Code:
iwconfig eth0 down
Code:
iwconfig eth0 up
Code:
iwconfig wlan0 up
Code:
iwconfig wlan0 down
To shutdown your linux box:
Code:
sudo halt
Code:
sudo shutdown -h now
To reboot your linux box:
Code:
sudo reboot
Usefull commands:
Warning these commands can change your system
so do not run them unless you need to. Use it as a refference only !
To update/upgrade your installed packages:
Code:
sudo apt-get updates
Code:
sudo apt-get upgrade
this can break functionallity so be carefull !
To update/upgrade specific package:
Code:
sudo apt-get install xbmc
Code:
sudo apt-get install xbmc-live
and if there is a newer version it will ask you if you want to upgrade.
To uninstall a package:
Code:
sudo apt-get uninstall xbmc
Code:
sudo apt-get uninstall xbmc-live
To completely remove a package and all dependencies:
Code:
sudo apt-get --purge remove xbmc
Code:
sudo apt-get --purge remove xbmc-live
Another way to remove packages can be:
Code:
sudo dpkg --purge xbmc
Code:
sudo dpkg --purge xbmc-live
To free up disk space and get rid of left behind packages:
Code:
sudo apt-get autoremove
Code:
sudo apt-get autoclean
To search for a package:
Code:
apt-cache search xbmc
To fix broken installs/packages:
Code:
sudo apt-get install --fix-broken
Code:
sudo dpkg --configure -a
To upgrade your current linux distro to a newer version:
Code:
sudo apt-get dist-upgrade
and make backups of anything imporant. I have done this a few times
with no problems, however this is not always possible depending on your config/setup
Okay this is what i currently remember from my head, i will ad more
if i see something is forgotten. And as always any input to my list
is welcome ! Also please report if you find something you don't like
or if you have any commands you think should be here