Wednesday 6 November 2013

Raspberry Pi useful commands


This post is very much an evolving, growing thing, that I will add to as I am exploring the world of raspberry pi. N00bs galore!

SYSTEM UPDATES and CONFIGURATION


To check the current version of Linux:

uname -r

To get to the raspberry pi config utility: 

sudo raspi-config

To verify the installed packages:

dpkg -l 


Graceful shutdown

sudo shutdown -hP now

sudo shutdown -r now

Reboot:

sudo reboot



Updating the OS and or components:

apt-get update     This will update the list of available packages, but will not actually upgrade them   

apt-get upgrade -y  After updating the list (apt-get update),the package manager knows about the available updates for the software you have installed. This is why you want to run apt-get update first

Removing components is as follows (example):

sudo apt-get remove php5 php5-cgi php5-fpm

sudo apt-get install php5 php5-cgi php5-fpm
packages are stored in /var/cache/apt/archives and you can refer back to them, if needed for instances

# dpkg -i --force-depends /var/cache/apt/archives/"php5-fpm_5.3.6-2_i386.deb"


To find out which packages have been installed:
(can be use in conjunction with "grep")

root@raspberrypi:/var/run# dpkg -l | grep openm
rc  openmediavault                 3.0.59                          all          Open network attached storage solution
rc  openmediavault-flashmemory     3.4.3                           all          folder2ram plugin for OpenMediaVault
ii  openmediavault-keyring         1.0                             all          GnuPG archive keys of the OpenMediaVault archive
rc  openmediavault-omvextrasorg    3.4.16                          all          OMV-Extras.org Package Repositories for OpenMediaVault
rc  openmediavault-resetperms      3.2                             all          Reset Permissions




DIAGNOSTICS:

Bootlog:

dmesg

this will also give you an overview of the linux version, cpu etc. that you have


Tracing

strace -e trace=open motion

Overview of USB devices:

lsusb                  =overview of all USB devices

ldd <ex.motion>      =shows the shared library dependency (motion for ex.)



Most log file can be found in 

 /var/log/   use vi to view the contents of the log files.



FILES AND FOLDERS and MOUNTS

ls -l                                                                  = to view long listings, files and folders permissions
find /usr/lib -iname libjpeg*     =search function 

find . -size -900000c -delete     =search and delete all files smaller than 900000 bytes


cat /proc/mounts                                     =check which devices are mounted



PERMISSIONS, USERS AND USER GROUPS


sudo usermod -a -G video pi  = this will add the user "pi" to the "video" permissions group

su - <user>                                      = change the user for example   su - pi , will change the user to "pi"

id -u pi                                   = will display the UID of the user "pi", in this case 1000.     



Find Files

use grep or find

Example: find . -name "www.conf"





Using vi

Vi uses what is called command mode; this does not allow you to edit a file straight away.

so to insert a line, press "i" and start adding/editing text.

To go back into command mode, press ":"  then you can issue "w" to write the changes and "q" to quit vi.

to remove a hole line, where the cursor is situated: use "dd"

Services

to check and see what services are running use "ps aux"




Camera

raspistill -o image.jpg -w 640 -h 480     =Take a 640x480 shot 



raspivid -t 20000 -o video.h264                      =Capture 20s of h264 video  (t=time o=output file)

No comments:

Post a Comment