Friday, July 3, 2015

List of usefull command line (updated)

* Last reboot time
      last reboot;

* Searching command
      greb filename;

* Searching for file in the computer
      tree -fa | grep filename;

* Real internet ip
     curl ifconfig.me;
     curl icanhazip.com;

* Real-time view of a running system.
     top
http://www.tecmint.com/12-top-command-examples-in-linux/

* vcgencmd
     vcgencmd measure_temp     vcgencmd measure_clock arm
     vcgencmd measure_volts core
http://elinux.org/RPI_vcgencmd_usage
http://www.maketecheasier.com/finding-raspberry-pi-system-information/


*Change mode of file
     chmod u=rwx,g=rx,o=r myfile

*testing PHP file
    php -f filename.php


*php information function

   <?php phpinfo();

*The sudo command can be used to obtain the privileges of other users too. I've installed the Apache web server, and the user www-data is automatically created during this process. If I want to edit a file using www-data's permissions, I can use the -u option:
  
   sudo -u www-data nano /var/www/somefile.txt


Best global ip address detecting commands

try one of this commands to obtain your global ip address in linux OS

   curl ifconfig.me



   curl icanhazip.com




DNS problem after static ip (solved) (updated)

After i changed my ip from dynamic to static
i had found that the Rpi is connected well with local network
but cant connect to internet

the solution of this problem is in these few lines


One last thing that needs to be modified is the /etc/resolv.conf file.  This file contains information of DNS name resolvers that allow your raspberry pi to resolve names to IP addresses.  For example, if you ping www.suntimebox.com the raspberry pi will have to determine the IP address of www.suntimebox.com.
Enter the following command to edit the resolv.conf file.
sudo nano /etc/resolv.conf
Enter the follow Google public dns server IP address.
nameserver 8.8.8.8
name server 8.8.4.4
Press CTRL-X to exit but remember to save the file by accepting the changes.

since i had found that after restart connection with Rpi these configuration lost
i forced the raspy to add these lines every startup and reboot by adding these two lines to the file rc.local before exit 0

    sudo nano /etc/rc.local

then adding these two lines before exit 0

    echo 'nameserver 8.8.8.8' >> /etc/resolv.conf;

    echo 'name server 8.8.4.4' >> /etc/resolv.conf;

to be the final view of rc.local file 



source of solution is from here
 http://www.suntimebox.com/raspberry-pi-tutorial-course/week-3/day-5/

this site is very wander full for whom are beginners in linux or raspberry pi


Powering Rpi with power bank (updated)


Now i had buy new power bank (InnJoo E1 10000mAh Powerbank) with specs ( Capacity: 10000mAh - Input: 5V/1A - Output: 5V/2A );

when i full charged it , it can power on the Rpi connected to wifi dongle

but i want to test how much time it will survive it

so i used this code to save the run time and save time every 30 sec

    while :; do date >> time_servive_test.txt; sleep 30; done

when i open the file "time_servive_test.txt" it will have a saving if time every 30 sec 
so to know  if it works will you can use this command line to count the numbers of test executed 


    wc -l time_servive_test.txt


i will publish the result of my test :) soon (inshaa Allah)
------------

i had updated the code to be interval every 1 minuet 
also i had added a chick  for global ip address

   echo 'start saving time';
   echo '' > time_servive_test.txt;
   while :;
   do
        date >> time_servive_test.txt;
        curl icanhazip.com; >> time_servive_test.txt;
        sleep 60;
   done

-------------------------------------------------------------------------
finally the test had been finished 
the power-bank of 10000 mAh survived the  Raspberry pi for more than 11 hours (around 12 or more).

when i used the command sudo shutdown -h now the raspy shutdown and the power disconnected , when i pressed the power of the power-bank the raspy powered on

Static WIFI address

How to use Rpi with wifi dongle and access it with fixed ip

the coming steps will lead to full control of the Rpi with wifi


first of all you have to connect to Rpi via cable connected to the local Router  (disconnect the wifi dongle ) and find its ip address to connect it via SSH . (these easy steps will be discussed later)

secondly after connection and opening SSH connection
go to /etc/network/interfaces via this command

       sudo nano /etc/network/interfaces


you will find these lines as image

change manual to static 
then add these lines and configure them according to your network settings

   allow-hotplug wlan0

   auto wlan0

   iface wlan0 inet static

   address 192.168.1.22

   netmask 255.255.255.0

   gateway 192.168.1.1


don't forget to put your own wanted ip instead of 192.168.1.22

the final look of the file /etc/network/interfaces will be 


press Ctrl+x then Enter to save the file and exit from nano editor 


now you have to enter the data of wifi name (ssid) and password
go to /etc/wpa_supplicant/wpa_supplicant.conf

       sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


copy this Template to the file and add wifi name instead of "wifi_name" and wifi password instead of "wifi_password"


   network={
            ssid="wifi_name"
            psk="wifi_password"
            key_mgmt=WPA-PSK
   }

press Ctrl+x then Enter to save the file and exit from nano editor
then reboot the Rpi to active these settings you can use this line to reboot successfully

   sudo reboot ; exit




for any questions don't hesitate to ask to seek for answer together .



---------------------
hint : i still have problem with global connection with the Rpi with static ip 
the problem is with DNS put iam seeking for solution and i will publish it "Inshaa Allah".